diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 75fc4d2765..1f0de53737 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -74,7 +74,6 @@ - @@ -160,6 +159,7 @@ Disabled true 1Byte + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true @@ -172,13 +172,15 @@ Disabled true true - true + + MultiThreaded 1Byte 4013 false + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 7350319a76..559453fe4d 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -269,9 +269,6 @@ Windows - - Source Files - Windows diff --git a/src/addresses.h b/src/addresses.h index 073d85bdd4..0feedba137 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -48,11 +48,17 @@ #define RCT2_ADDRESS_APP_PATH 0x009AA214 +#define RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER 0x009AAC6E +#define RCT2_ADDRESS_CONFIG_MUSIC 0x009AAC72 #define RCT2_ADDRESS_CONFIG_FLAGS 0x009AAC74 +#define RCT2_ADDRESS_CONFIG_SOUND_QUALITY 0x009AAC77 #define RCT2_ADDRESS_CONFIG_METRIC 0x009AAC78 -#define RCT2_ADDRESS_CONFIG_FAHRENHEIT 0x009AAC79 +#define RCT2_ADDRESS_CONFIG_TEMPERATURE 0x009AAC79 #define RCT2_ADDRESS_CONFIG_KEYBOARD_SHORTCUTS 0x009AAC7A #define RCT2_ADDRESS_CONFIG_EDGE_SCROLLING 0x009AACBA +#define RCT2_ADDRESS_CONFIG_CURRENCY 0x009AACBB +#define RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS 0x009AACBD +#define RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER 0x009AACBF #define RCT2_ADDRESS_EXPANSION_NAMES 0x009AACC0 #define RCT2_ADDRESS_EXPANSION_FLAGS 0x009AB4C0 diff --git a/src/climate.c b/src/climate.c index dd2275be2a..6c1d4a1fd7 100644 --- a/src/climate.c +++ b/src/climate.c @@ -41,9 +41,9 @@ static const rct_weather_transition* climate_transitions[4]; static void climate_determine_future_weather(); -int climate_celcius_to_fahrenheit(int celcius) +int climate_celsius_to_fahrenheit(int celsius) { - return (celcius * 29) / 16 + 32; + return (celsius * 29) / 16 + 32; } /** diff --git a/src/climate.h b/src/climate.h index 2c035b86f7..814039f10f 100644 --- a/src/climate.h +++ b/src/climate.h @@ -41,7 +41,7 @@ typedef struct { extern int gClimateNextWeather; extern const rct_weather climate_weather_data[6]; -int climate_celcius_to_fahrenheit(int celcius); +int climate_celsius_to_fahrenheit(int celsius); void climate_reset(int climate); void climate_update(); diff --git a/src/config.c b/src/config.c index f1b2ddd385..ee2d964fdd 100644 --- a/src/config.c +++ b/src/config.c @@ -103,7 +103,7 @@ void config_load() return; RCT2_GLOBAL(0x009AB4C6, sint8) = 1; RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, sint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FAHRENHEIT, sint8) = 1; + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, sint8) = 1; RCT2_GLOBAL(0x009AACBB, sint8) = 1; RCT2_GLOBAL(0x009AACBD, sint16) = 0; if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS)) @@ -137,10 +137,10 @@ void config_save() HANDLE hFile; DWORD bytesWritten; - hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(get_file_path(PATH_ID_GAMECFG), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { WriteFile(hFile, &MagicNumber, 4, &bytesWritten, NULL); - WriteFile(hFile, 0x009AAC5C, 2155, &bytesWritten, NULL); + WriteFile(hFile, (LPCVOID)0x009AAC5C, 2155, &bytesWritten, NULL); CloseHandle(hFile); } } @@ -252,7 +252,7 @@ static void config_create_default(char *path) */ static void config_parse_settings(FILE *fp) { - int c = NULL, pos = 0; + int pos = 0; char *setting; char *value; char *section; @@ -389,36 +389,36 @@ static int config_parse_setting(FILE *fp, char *setting){ * @param value a pointer to where to store the value * @return < 0 if EOF is reached */ -static int config_parse_value(FILE *fp, char *value){ +static int config_parse_value(FILE *fp, char *value) +{ long start, end; int size, c, pos = 0; start = ftell(fp); c = fgetc(fp); - while (isspace(c)){ + while (isspace(c)) { start = ftell(fp); c = fgetc(fp); - } - while (c != EOF && c != '\n'){ + while (c != EOF && c != '\n') { c = fgetc(fp); } + end = ftell(fp); size = end - start; - if (size > MAX_CONFIG_LENGTH){ + if (size > MAX_CONFIG_LENGTH) config_error("One of your settings is too long"); - } + fseek(fp, start, SEEK_SET); c = fgetc(fp); - while (c != EOF && c != '\n'){ - + while (c != EOF && c != '\n') { value[pos] = (char)c; c = fgetc(fp); pos++; } value[pos] = '\0'; - return; + return 0; } /** diff --git a/src/config.h b/src/config.h index 65ee7b4752..35b4b1e0b2 100644 --- a/src/config.h +++ b/src/config.h @@ -27,7 +27,8 @@ enum { CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES = (1 << 0), CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS = (1 << 1), - CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE = (1 << 2) + CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE = (1 << 2), + CONFIG_FLAG_SAVE_PLUGIN_DATA = (1 << 3) }; enum { diff --git a/src/finance.c b/src/finance.c index 86eb3d1508..7db4b107b0 100644 --- a/src/finance.c +++ b/src/finance.c @@ -23,6 +23,7 @@ #include "sprite.h" #include "park.h" #include "peep.h" +#include "ride.h" #include "window.h" // monthly cost @@ -102,6 +103,35 @@ void finance_pay_interest() finance_payment((sint32)tempcost, RCT_EXPENDITURE_TYPE_INTEREST); } +/** + * + * rct2: 0x006AC885 + */ +void finance_pay_ride_upkeep() +{ + rct_ride* ride; + for (int i = 0; i < MAX_RIDES; i++) { + ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); + if (ride->type == RIDE_TYPE_NULL) + continue; + + if (!(ride->var_1D0 & 0x1000)) { + ride->build_date = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); + ride->var_196 = 25855; // durability? + + } + if (ride->status != RIDE_STATUS_CLOSED && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x800)) { + sint16 upkeep = ride->upkeep_cost; + if (upkeep != -1) { + ride->var_158 -= upkeep; + ride->var_14D |= 2; + finance_payment(upkeep, RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP); + } + } + } +} + + /** * * rct2: 0x0069DEFB diff --git a/src/finance.h b/src/finance.h index 3fc80726fb..7bb126cc01 100644 --- a/src/finance.h +++ b/src/finance.h @@ -28,6 +28,7 @@ typedef int rct_expenditure_type; enum { + RCT2_EXPENDITURE_TYPE_RIDE_UPKEEP = 1, RCT_EXPENDITURE_TYPE_WAGES = 10, RCT_EXPENDITURE_TYPE_RESEARCH = 12, RCT_EXPENDITURE_TYPE_INTEREST = 13 @@ -38,6 +39,7 @@ void finance_payment(int amount, rct_expenditure_type type); void finance_pay_wages(); void finance_pay_research(); void finance_pay_interest(); +void finance_pay_ride_upkeep(); void finance_init(); #endif \ No newline at end of file diff --git a/src/game.c b/src/game.c index ad0852b179..c3f7c0f44c 100644 --- a/src/game.c +++ b/src/game.c @@ -195,13 +195,14 @@ void game_handle_input() if (RCT2_GLOBAL(0x009ABDF2, uint8) != 0) { for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, (int)w, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006EA73F); RCT2_CALLPROC_EBPSAFE(0x006E8346); // update_cursor_position { - int eax, ebx, ecx, edx, esi, edi, ebp; + // int eax, ebx, ecx, edx, esi, edi, ebp; + int eax, ebx, ecx; for (;;) { game_get_next_input(&eax, &ebx, &ecx); @@ -228,7 +229,7 @@ void game_handle_input() } for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_08], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_08], 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -288,11 +289,9 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex); */ static void game_handle_input_mouse(int x, int y, int state) { - rct_window *w, *w2; + rct_window *w; rct_widget *widget; int widgetIndex; - rct_windowclass windowClass; - rct_windownumber windowNumber; // Get window and widget under cursor position w = window_find_from_point(x, y); @@ -347,7 +346,7 @@ static void game_handle_input_mouse(int x, int y, int state) break; case INPUT_STATE_WIDGET_PRESSED: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_DRAGGING: // RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0); @@ -370,7 +369,7 @@ static void game_handle_input_mouse(int x, int y, int state) } else if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34); @@ -382,7 +381,7 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, (int)w, 0, 0); } break; case INPUT_STATE_VIEWPORT_DRAG: @@ -460,13 +459,13 @@ static void game_handle_input_mouse(int x, int y, int state) break; } case INPUT_STATE_DROPDOWN_ACTIVE: - RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_VIEWPORT_LEFT: - RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_SCROLL_LEFT: - RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; case INPUT_STATE_RESIZING: // RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0); @@ -482,7 +481,7 @@ static void game_handle_input_mouse(int x, int y, int state) if (state == 2) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); + RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass); RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber); } @@ -498,7 +497,7 @@ static void game_handle_input_mouse(int x, int y, int state) RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; break; case 9: - RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, (int)w, (int)widget, 0); break; } } @@ -527,8 +526,8 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; - esi = w; - edi = widget; + esi = (int)w; + edi = (int)widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; @@ -537,7 +536,7 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) if (ecx < 0) goto showTooltip; if (ecx == 0) { - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, (int)w, 0, 0); goto showTooltip; } else { @@ -585,8 +584,6 @@ 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) { - rct_window *w; - // Check if widget cursor was over has changed if (windowClass != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) || windowNumber != RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber) || @@ -597,8 +594,8 @@ static void input_mouseover_widget_check(rct_windowclass windowClass, rct_window // Set new cursor over widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) = windowClass; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windowclass) = windowNumber; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windowclass) = widgetIndex; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber) = windowNumber; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, uint16) = widgetIndex; // Invalidate new widget cursor is on if widget is a flat button if (windowClass != 255) @@ -612,7 +609,7 @@ static void input_mouseover_widget_flatbutton_invalidate() if (w == NULL) return; - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); if (w->widgets[RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)].type == WWT_FLATBTN) widget_invalidate(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, rct_windownumber)); } @@ -676,7 +673,7 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) if (w == NULL) break; - RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), (int)w, 0, 0); RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 4); break; case WWT_CAPTION: @@ -698,8 +695,8 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; - esi = w; - edi = widget; + esi = (int)w; + edi = (int)widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; @@ -708,42 +705,42 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) RCT2_GLOBAL(0x009DE548, uint16) = ecx; RCT2_GLOBAL(0x009DE54C, uint32) = edx; - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, (int)w, (int)widget, 0); switch (ecx) { case SCROLL_PART_VIEW: - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, (int)w, (int)widget, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT: // 0x006E9A60 - RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT: // 0x006E9ABF - RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH: // 0x006E9B47 - RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH: // 0x006E9BB7 - RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP: // 0x006E9C37 - RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM: // 0x006E9C96 - RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP_TROUGH: // 0x006E9D1E - RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, (int)w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH: // 0x006E9D8E - RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, (int)w, 0, 0); break; } break; @@ -757,14 +754,14 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) // Set new cursor down widget RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber; - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, rct_windowclass) = widgetIndex; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber) = windowNumber; + RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 0); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_WIDGET_PRESSED; RCT2_GLOBAL(0x009DE528, uint16) = 1; widget_invalidate(windowClass, windowNumber, widgetIndex); - RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, (int)w, (int)widget, 0); break; } } @@ -877,7 +874,7 @@ void handle_shortcut_command(int shortcutIndex) case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS: if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) window_close_all(); - else if (RCT2_ADDRESS(0x0141F570, uint8) == 1) + else if (RCT2_GLOBAL(0x0141F570, uint8) == 1) window_close_top(); break; case SHORTCUT_CANCEL_CONSTRUCTION_MODE: @@ -897,7 +894,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ZOOM_VIEW_OUT: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -908,7 +905,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ZOOM_VIEW_IN: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -919,7 +916,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ROTATE_VIEW: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -963,7 +960,7 @@ void handle_shortcut_command(int shortcutIndex) RCT2_CALLPROC_X(0x0066CF8A, 11, 0, 0, 0, 0, 0, 0); break; case SHORTCUT_ADJUST_LAND: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -974,7 +971,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_ADJUST_WATER: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -985,7 +982,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_SCENERY: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -996,7 +993,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_PATHS: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1007,7 +1004,7 @@ void handle_shortcut_command(int shortcutIndex) } break; case SHORTCUT_BUILD_NEW_RIDE: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1072,7 +1069,7 @@ void handle_shortcut_command(int shortcutIndex) window_news_open(); break; case SHORTCUT_SHOW_MAP: - if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_ADDRESS(0x0141F570, uint8) == 1) { + if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) { if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) { window = window_find_by_id(WC_TOP_TOOLBAR, 0); if (window != NULL) { @@ -1133,7 +1130,7 @@ void set_shortcut(int key) void game_handle_keyboard_input() { rct_window *w; - int key, i; + int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) @@ -1182,7 +1179,7 @@ void game_handle_keyboard_input() if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } @@ -1190,7 +1187,7 @@ void game_handle_keyboard_input() if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { - RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, w, RCT2_GLOBAL(0x009DEA72, uint16), 0); + RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } @@ -1311,9 +1308,7 @@ int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int eb */ static void game_pause_toggle() { - rct_window *w; - char input_bl, input_dl; - short input_di; + char input_bl; __asm mov input_bl, bl @@ -1335,7 +1330,6 @@ static void game_pause_toggle() */ static void game_load_or_quit() { - rct_window *w; char input_bl, input_dl; short input_di; @@ -1344,7 +1338,7 @@ static void game_load_or_quit() __asm mov input_di, di if (!(input_bl & 1)) - return 0; + return; // 0; switch (input_dl) { case 0: @@ -1368,13 +1362,15 @@ static void game_load_or_quit() */ static int open_landscape_file_dialog() { - format_string(0x0141ED68, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); - strcpy(0x0141EF68, RCT2_ADDRESS_LANDSCAPES_PATH); - format_string(0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); + int result; + format_string((char*)0x0141ED68, STR_LOAD_LANDSCAPE_DIALOG_TITLE, 0); + strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_LANDSCAPES_PATH); + format_string((char*)0x0141EE68, STR_RCT2_LANDSCAPE_FILE, 0); pause_sounds(); - osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6;*.SV4;*.SC6", 0x0141EE68); + result = osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6;*.SV4;*.SC6", (char*)0x0141EE68); unpause_sounds(); // window_proc + return result; } /** @@ -1384,11 +1380,11 @@ static int open_landscape_file_dialog() static int open_load_game_dialog() { int result; - format_string(0x0141ED68, STR_LOAD_GAME_DIALOG_TITLE, 0); - strcpy(0x0141EF68, RCT2_ADDRESS_SAVED_GAMES_PATH); - format_string(0x0141EE68, STR_RCT2_SAVED_GAME, 0); + format_string((char*)0x0141ED68, STR_LOAD_GAME_DIALOG_TITLE, 0); + strcpy((char*)0x0141EF68, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH); + format_string((char*)0x0141EE68, STR_RCT2_SAVED_GAME, 0); pause_sounds(); - result = osinterface_open_common_file_dialog(1, 0x0141ED68, 0x0141EF68, "*.SV6", 0x0141EE68); + result = osinterface_open_common_file_dialog(1, (char*)0x0141ED68, (char*)0x0141EF68, "*.SV6", (char*)0x0141EE68); unpause_sounds(); // window_proc return result; @@ -1404,7 +1400,7 @@ static void load_landscape() gfx_invalidate_screen(); } else { // Set default filename - char *esi = 0x0141EF67; + char *esi = (char*)0x0141EF67; while (1) { esi++; if (*esi == '.') @@ -1414,7 +1410,7 @@ static void load_landscape() strcpy(esi, ".SC6"); break; } - strcpy(0x009ABB37, 0x0141EF68); + strcpy((char*)0x009ABB37, (char*)0x0141EF68); RCT2_CALLPROC_EBPSAFE(0x006758C0); // landscape_load if (1) { @@ -1456,11 +1452,11 @@ int game_load_save() return 0; } - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SAVEDGAME) { // Read packed objects if (s6Header->num_packed_objects > 0) { @@ -1475,14 +1471,14 @@ int game_load_save() object_read_and_load_entries(hFile); // Read flags (16 bytes) - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_MONTH_YEAR); // Read map elements - memset(RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_MAP_ELEMENTS); + memset((void*)RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_MAP_ELEMENTS); // Read game data, including sprites - sawyercoding_read_chunk(hFile, 0x010E63B8); + sawyercoding_read_chunk(hFile, (uint8*)0x010E63B8); CloseHandle(hFile); @@ -1540,7 +1536,7 @@ static void load_game() gfx_invalidate_screen(); } else { // Set default filename - char *esi = 0x0141EF67; + char *esi = (char*)0x0141EF67; while (1) { esi++; if (*esi == '.') @@ -1550,7 +1546,7 @@ static void load_game() strcpy(esi, ".SV6"); break; } - strcpy(0x009ABB37, 0x0141EF68); + strcpy((char*)0x009ABB37, (char*)0x0141EF68); if (game_load_save()) { gfx_invalidate_screen(); @@ -1602,10 +1598,10 @@ void game_load_or_quit_no_save_prompt() static uint32 game_do_command_table[58] = { 0x006B2FC5, 0x0066397F, - game_pause_toggle, + (uint32)game_pause_toggle, 0x006C511D, 0x006C5B69, - game_load_or_quit, + (uint32)game_load_or_quit, 0x006B3F0F, 0x006B49D9, 0x006B4EA6, diff --git a/src/gfx.c b/src/gfx.c index 410e012255..07e3b1659d 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -445,13 +445,84 @@ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bot */ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short right, short bottom, int colour, short _si) { - RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, dpi, colour); + RCT2_CALLPROC_X(0x006E6F81, left, right, top, bottom, _si, (int)dpi, colour); } #define RCT2_Y_RELATED_GLOBAL_1 0x9E3D12 //uint16 #define RCT2_Y_RELATED_GLOBAL_2 0x9ABDAC //sint16 #define RCT2_X_RELATED_GLOBAL_1 0x9E3D10 //uint16 #define RCT2_X_RELATED_GLOBAL_2 0x9ABDA8 //sint16 + +void sub_0x67AA18(int* source_bits_pointer, int* dest_bits_pointer, rct_drawpixelinfo *dpi){ + if (RCT2_GLOBAL(0xEDF81C, uint32) & 0x2000000){ + return; //0x67AAB3 + } + + if (RCT2_GLOBAL(0xEDF81C, uint32) & 0x4000000){ + return; //0x67AFD8 + } + + int ebx = RCT2_GLOBAL(0xEDF808, uint32); + ebx = RCT2_GLOBAL(ebx * 2 + source_bits_pointer,uint16); + int ebp = dest_bits_pointer; + ebx += (int)source_bits_pointer; + +StartLoop: + ebx = ebx; + int cx = RCT2_GLOBAL(ebx, uint16); + RCT2_GLOBAL(0x9ABDB4, uint8) = cx & 0xFF; + ebx += 2; + cx &= 0xFF7F; + int esi = ebx; + int edx = (cx & 0xFF00) >> 8; + ebx += cx; + edx -= RCT2_GLOBAL(0xEDF80C, sint32); + int edi = ebp; + if (edx > 0){ + edi += edx; + } + else{ + esi -= edx; + cx += edx & 0xFFFF; + if (cx <= 0){ + goto TestLoop; + //jump to 0x67AA97 + } + edx &= 0xFFFF0000; + } + edx += cx; + edx -= RCT2_GLOBAL(0x9ABDA8, sint16); + if (edx > 0){ + cx -= edx; + if (cx <= 0){ + goto TestLoop; + //jump to 0x67AA97 + } + } + if (cx & 1){ + cx >>= 1; + RCT2_GLOBAL(edi, uint8) = RCT2_GLOBAL(esi, uint8); + } + else cx >>= 1; + + if (cx & 1){ + cx >>= 1; + RCT2_GLOBAL(edi, uint16) = RCT2_GLOBAL(esi, uint16); + } + else cx >>= 1; + + for (int i = cx; i > 0; --i, edi++, esi++){ + RCT2_GLOBAL(edi, uint16) = RCT2_GLOBAL(esi, uint16); + } +TestLoop: + if (!(RCT2_GLOBAL(0x9ABDB4, uint8) & 0x80)) goto StartLoop; + edx = RCT2_GLOBAL(0x9ABDB0, sint16); + ebp += edx; + RCT2_GLOBAL(0x9ABDAC, sint16)--; + if (RCT2_GLOBAL(0x9ABDAC, sint16))goto StartLoop; + +} + /* * rct2: 0x67A934 title screen bitmaps on buttons * This function readies all the global vars for copying the sprite data onto the screen @@ -508,6 +579,9 @@ void sub_0x67A934(rct_drawpixelinfo *dpi, int x, int y){ RCT2_GLOBAL(0x9ABDB0, uint16) = dpi->width + dpi->pitch; // I dont think it uses ecx, edx but just in case + //esi is the source and bits_pointer is the destination + //sub_0x67AA18(RCT2_GLOBAL(0x9E3D08, int*), (int*)bits_pointer, dpi); + RCT2_CALLPROC_X_EBPSAFE(0x67AA18, 0, 0, translated_x, translated_y, RCT2_GLOBAL(0x9E3D08, uint32), bits_pointer, dpi); } @@ -524,14 +598,24 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y) //return; int eax = 0, ebx = image_id, ecx = x, edx = y, esi = 0, edi = dpi, ebp = 0; - eax = image_id; - eax >>= 26; - RCT2_GLOBAL(0x00EDF81C, uint32) = image_id & 0xE0000000; - eax &= 0x7; - eax = RCT2_GLOBAL(0x009E3CE4 + eax*4, uint32); - RCT2_GLOBAL(0x009E3CDC, uint32) = eax; - if ((image_id & (1 << 31)) && (image_id & (1 << 29))){ + RCT2_GLOBAL(0x00EDF81C, uint32) = image_id & 0xE0000000; + eax = (image_id >> 26) & 0x7; + //eax = RCT2_GLOBAL(0x009E3CE4 + eax*4, uint32); + RCT2_GLOBAL(0x009E3CDC, uint32) = RCT2_GLOBAL(0x009E3CE4 + eax * 4, uint32); + + if (((image_id)& 0xE0000000) && !(image_id & (1 << 31))) { + RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); + // + return;//jump into 0x67a445 + } + else if (((image_id)& 0xE0000000) && !(image_id & (1 << 29))){ + char* find = "FINDMEDUNCAN"; + RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); + return;//jump into 0x67a361 + } + else if ((image_id)& 0xE0000000){ + RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); /* eax = image_id; RCT2_GLOBAL(0x9E3CDC, uint32) = 0; @@ -562,12 +646,6 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y) RCT2_GLOBAL(0x9ABDA4, uint32) = 0x009ABE0C; RCT2_GLOBAL(0x9ABEDE, uint32) = ebp;*/ return; - } else if ((image_id & (1 << 31))){ - return; - //jump into 0x67a361 - } else if ((image_id & (1 << 30))){ - return; - //jump into 0x67a445 } ebx &= 0x7FFFF; @@ -592,15 +670,11 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y) RCT2_GLOBAL(0x9E3D14, uint32) = *((uint32*)ebx + 3); if (RCT2_GLOBAL(0x9E3D14, uint32) & (1 << 2)){ //Title screen bitmaps + //RCT2_CALLPROC_X(0x0067A934, eax, ebx, x, y, 0, dpi, ebp); sub_0x67A934(dpi, x, y); return; } - - RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); - return; - //There is a mistake in the code below this point calling the above to skip it. - //dpi on stack int translated_x, translated_y; char* bits_pointer; @@ -673,22 +747,19 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y) } if (!(RCT2_GLOBAL(0x9E3D14, uint16) & 0x02)){ - eax = (RCT2_GLOBAL(RCT2_Y_RELATED_GLOBAL_2, sint16) & 0xFF) << 8; + eax = (RCT2_GLOBAL(RCT2_Y_RELATED_GLOBAL_2, uint8)) << 8; edx = RCT2_GLOBAL(0x9ABDAE, sint16); ebp = RCT2_GLOBAL(0x9ABDB0, sint16); ebx = RCT2_GLOBAL(0xEDF81C, uint32); ecx = 0xFFFF&translated_x; //ebx, esi, edi, ah used in 0x67a690 - //Calling is wrong - //esi or bits is most likely wrong - RCT2_CALLPROC_X(0x67A690, eax, ebx, ecx, edx, esi, bits_pointer, ebp); + RCT2_CALLPROC_X_EBPSAFE(0x67A690, eax, ebx, ecx, edx, esi, bits_pointer, ebp); return; } //0x67A60A + RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, dpi, 0); esi -= RCT2_GLOBAL(0x9E3D08, sint32); return; - - } /** @@ -730,7 +801,7 @@ void gfx_transpose_palette(int pal, unsigned char product) */ void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args) { - RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, args, dpi, 0); + RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, (int)args, (int)dpi, 0); } /** @@ -787,7 +858,6 @@ void gfx_set_dirty_blocks(int left, int top, int right, int bottom) void gfx_draw_all_dirty_blocks() { int x, y, xx, yy, columns, rows; - short left, top, right, bottom; uint8 *screenDirtyBlocks = RCT2_ADDRESS(0x00EDE408, uint8); for (x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_COLUMNS, sint32); x++) { @@ -880,7 +950,7 @@ int gfx_get_string_width(char *buffer) { int eax, ebx, ecx, edx, esi, edi, ebp; - esi = buffer; + esi = (int)buffer; RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return ecx & 0xFFFF; @@ -900,7 +970,7 @@ int gfx_get_string_width(char *buffer) */ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y, int width) { - RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, args, dpi, width); + RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, (int)args, (int)dpi, width); //char* buffer; @@ -925,7 +995,7 @@ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args */ void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width) { - RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, args, dpi, width); + RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, (int)args, (int)dpi, width); //char* buffer; //short text_width; @@ -986,8 +1056,8 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i ebx = format; ecx = x; edx = y; - esi = args; - edi = dpi; + esi = (int)args; + edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C1E53, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); @@ -1013,8 +1083,8 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *format, int x, in ebx = colour; ecx = x; edx = y; - esi = format; - edi = dpi; + esi = (int)format; + edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); @@ -1057,8 +1127,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *format, int colour, int x, in ebx = 0; ecx = x; edx = y; - esi = format; - edi = dpi; + esi = (int)format; + edi = (int)dpi; ebp = 0; RCT2_CALLFUNC_X(0x00682702, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); diff --git a/src/gfx.h b/src/gfx.h index de0411b258..162ccd121f 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -31,7 +31,7 @@ typedef struct { short width; // 0x08 short height; // 0x0A short pitch; // 0x0C note: this is actually (pitch - width) - uint16 pad_0E; // 0x0E + uint8 pad_0E; // 0x0E char var_0F; // 0x0F } rct_drawpixelinfo; diff --git a/src/map.c b/src/map.c index 581eabdf30..935f059ee0 100644 --- a/src/map.c +++ b/src/map.c @@ -146,7 +146,6 @@ void map_update_tile_pointers() */ int map_element_height(int x, int y) { - int i; rct_map_element *mapElement; // Off the map @@ -298,13 +297,13 @@ void sub_68B089() i++; if (i >= MAX_TILE_MAP_ELEMENT_POINTERS) i = 0; - } while (TILE_MAP_ELEMENT_POINTER(i) == 0xFFFFFFFF); + } while (TILE_MAP_ELEMENT_POINTER(i) == TILE_UNDEFINED_MAP_ELEMENT); RCT2_GLOBAL(0x0010E63B8, uint32) = i; mapElementFirst = mapElement = TILE_MAP_ELEMENT_POINTER(i); do { mapElement--; - if (mapElement < RCT2_ADDRESS_MAP_ELEMENTS) + if (mapElement < (rct_map_element*)RCT2_ADDRESS_MAP_ELEMENTS) break; } while (mapElement->base_height == 255); mapElement++; diff --git a/src/map.h b/src/map.h index 88e76d7e11..108e339a82 100644 --- a/src/map.h +++ b/src/map.h @@ -180,7 +180,7 @@ enum { #define MAX_MAP_ELEMENTS 196608 #define MAX_TILE_MAP_ELEMENT_POINTERS (256 * 256) -#define TILE_UNDEFINED_MAP_ELEMENT -1 +#define TILE_UNDEFINED_MAP_ELEMENT (rct_map_element*)-1 void map_init(); void map_update_tile_pointers(); diff --git a/src/news_item.c b/src/news_item.c index 70c0f1f01e..4b5fa14e7c 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -191,7 +191,7 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * *z = map_element_height(*x, *y); break; case NEWS_ITEM_PEEP_ON_RIDE: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; *x = peep->x; *y = peep->y; *z = peep->z; @@ -212,16 +212,16 @@ void news_item_get_subject_location(int type, int subject, int *x, int *y, int * } // Find the first car of the train peep is on - car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]); + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[ride->train_car_map[peep->current_train]]).car; // Find the actual car peep is on for (i = 0; i < peep->current_car; i++) - car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]); + car = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[car->next_car]).car; *x = car->x; *y = car->y; *z = car->z; break; case NEWS_ITEM_PEEP: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; *x = peep->x; *y = peep->y; *z = peep->z; @@ -252,7 +252,7 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) // find first open slot while (newsItem->type != NEWS_ITEM_NULL) { - if (newsItem + sizeof(newsItem) >= 0x13CB1CC) + if (newsItem + sizeof(newsItem) >= (rct_news_item*)0x13CB1CC) news_item_close_current(); else newsItem++; @@ -263,12 +263,12 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc) newsItem->flags = 0; newsItem->assoc = assoc; newsItem->ticks = 0; - newsItem->month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); - newsItem->day = (days_in_month[(newsItem->month & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16; + 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; - format_string(0x0141EF68, string_id, 0x013CE952); // overflows possible? + format_string((char*)0x0141EF68, string_id, (void*)0x013CE952); // overflows possible? newsItem->colour = ((char*)0x0141EF68)[0]; - strncpy(newsItem->text, 0x0141EF68, 255); + strncpy(newsItem->text, (char*)0x0141EF68, 255); newsItem->text[254] = 0; // blatant disregard for what happens on the last element. @@ -295,8 +295,8 @@ void news_item_open_subject(int type, int subject) { break; case NEWS_ITEM_PEEP_ON_RIDE: case NEWS_ITEM_PEEP: - peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]); - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[subject]).peep; + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); break; case NEWS_ITEM_MONEY: // Open finances window diff --git a/src/news_item.h b/src/news_item.h index f7e5333af1..a82aa29b0f 100644 --- a/src/news_item.h +++ b/src/news_item.h @@ -48,8 +48,7 @@ typedef struct { uint8 flags; // 0x01 uint32 assoc; // 0x02 uint16 ticks; // 0x06 - uint8 month; // 0x08 - uint8 pad_09; // 0x09 + uint16 month_year; // 0x08 uint8 day; // 0x0A uint8 pad_0B; // 0x0B uint8 colour; // 0x0C diff --git a/src/object.c b/src/object.c index ba642157c2..1a98a2a482 100644 --- a/src/object.c +++ b/src/object.c @@ -34,7 +34,7 @@ void object_load_list() * * rct2: 0x006AA0C6 */ -void object_read_and_load_entries(HFILE hFile) +void object_read_and_load_entries(HANDLE hFile) { RCT2_CALLPROC_EBPSAFE(0x006AA0C6); diff --git a/src/object.h b/src/object.h index 54c5f76220..3549548bab 100644 --- a/src/object.h +++ b/src/object.h @@ -35,7 +35,7 @@ typedef struct { } rct_object_entry; void object_load_list(); -void object_read_and_load_entries(HFILE hFile); +void object_read_and_load_entries(HANDLE hFile); int object_load_packed(); #endif diff --git a/src/osinterface.c b/src/osinterface.c index 7e070518d0..2956a88c9e 100644 --- a/src/osinterface.c +++ b/src/osinterface.c @@ -33,8 +33,8 @@ typedef void(*update_palette_func)(char*, int, int); openrct2_cursor gCursorState; -unsigned char* gKeysState; -unsigned char* gKeysPressed; +const unsigned char *gKeysState; +unsigned char *gKeysPressed; unsigned int gLastKeyPressed; static void osinterface_create_window(); @@ -240,8 +240,8 @@ void osinterface_process_messages() } break; case SDL_MOUSEBUTTONUP: - *((int*)0x01424318) = e.button.x; - *((int*)0x0142431C) = e.button.y; + RCT2_GLOBAL(0x01424318, int) = e.button.x; + RCT2_GLOBAL(0x0142431C, int) = e.button.y; switch (e.button.button) { case SDL_BUTTON_LEFT: RCT2_CALLPROC_1(0x00406C96, int, 2); @@ -325,12 +325,12 @@ int osinterface_open_common_file_dialog(int type, char *title, char *filename, c openFileName.lpstrTitle = title; // Copy filter name - strcpy(0x01423800, filterName); + strcpy((char*)0x01423800, filterName); // Copy filter pattern - strcpy(0x01423800 + strlen(filterName) + 1, filterPattern); + strcpy((char*)0x01423800 + strlen(filterName) + 1, filterPattern); *((char*)(0x01423800 + strlen(filterName) + 1 + strlen(filterPattern) + 1)) = 0; - openFileName.lpstrFilter = 0x01423800; + openFileName.lpstrFilter = (char*)0x01423800; // tmp = RCT2_GLOBAL(0x009E2C74, uint32); diff --git a/src/osinterface.h b/src/osinterface.h index 9c6211ec73..f2925be48b 100644 --- a/src/osinterface.h +++ b/src/osinterface.h @@ -37,8 +37,8 @@ typedef struct { } openrct2_cursor; extern openrct2_cursor gCursorState; -extern unsigned char* gKeysState; -extern unsigned char* gKeysPressed; +extern const unsigned char *gKeysState; +extern unsigned char *gKeysPressed; extern unsigned int gLastKeyPressed; void osinterface_init(); diff --git a/src/park.c b/src/park.c index 911d10997e..bc39ff3d46 100644 --- a/src/park.c +++ b/src/park.c @@ -89,7 +89,7 @@ void park_init() RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) = PARK_FLAGS_11 | PARK_FLAGS_SHOW_REAL_GUEST_NAMES; park_reset_awards_and_history(); - rct_s6_info *info = 0x0141F570; + rct_s6_info *info = (rct_s6_info*)0x0141F570; info->name[0] = '\0'; format_string(info->details, STR_NO_DETAILS_YET, NULL); } diff --git a/src/peep.c b/src/peep.c index 194c255704..2e7af42148 100644 --- a/src/peep.c +++ b/src/peep.c @@ -63,11 +63,11 @@ void peep_update_all() sprite_index = peep->next; if ((i & 0x7F) != (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x7F)) { - RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0); + RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); } else { - RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, peep, 0, 0); + RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, (int)peep, 0, 0); if (peep->var_08 == 4) - RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, peep, 0, 0); + RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); } i++; @@ -87,7 +87,7 @@ void peep_problem_warnings_update() uint16 guests_in_park = RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16); int hunger_counter = 0, lost_counter = 0, noexit_counter = 0, thirst_counter = 0, litter_counter = 0, disgust_counter = 0, bathroom_counter = 0 ,vandalism_counter = 0; - static int warning_throttle[6] = { 0, 0, 0, 0, 0, 0 }; + static int warning_throttle[7] = { 0, 0, 0, 0, 0, 0, 0 }; RCT2_GLOBAL(RCT2_ADDRESS_RIDE_COUNT, sint16) = ride_get_count(); // refactor this to somewhere else diff --git a/src/rct2.c b/src/rct2.c index d4cc2fe042..a53a31bf22 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -17,8 +17,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . *****************************************************************************/ - -#define _CRT_SECURE_NO_WARNINGS + +#pragma warning(disable : 4996) // GetVersionExA deprecated #include #include @@ -43,7 +43,6 @@ #include "title.h" #include "track.h" #include "viewport.h" -#include "settings.h" void rct2_init_directories(); @@ -231,16 +230,16 @@ void check_cmdline_arg() } processed_arg[j ++] = 0; - if(!stricmp(processed_arg + last_period, "sv6")) + if (!_stricmp(processed_arg + last_period, "sv6")) { - strcpy(0x00141EF68, processed_arg); + strcpy((char*)0x00141EF68, processed_arg); game_load_save(); } - else if(!stricmp(processed_arg + last_period, "sc6")) + else if (!_stricmp(processed_arg + last_period, "sc6")) { //TODO: scenario install } - else if(!stricmp(processed_arg + last_period, "td6") || !stricmp(processed_arg + last_period, "td4")) + else if (!_stricmp(processed_arg + last_period, "td6") || !_stricmp(processed_arg + last_period, "td4")) { //TODO: track design install } @@ -321,7 +320,7 @@ void get_system_info() GetSystemInfo(&sysInfo); // RCT2 only has 2 bytes reserved for OEM_ID even though it should be a DWORD - RCT2_GLOBAL(RCT2_ADDRESS_SYS_OEM_ID, uint16) = sysInfo.dwOemId; + RCT2_GLOBAL(RCT2_ADDRESS_SYS_OEM_ID, uint16) = (uint16)sysInfo.dwOemId; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_LEVEL, uint16) = sysInfo.wProcessorLevel; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_REVISION, uint16) = sysInfo.wProcessorRevision; RCT2_GLOBAL(RCT2_ADDRESS_SYS_CPU_NUMBER, uint32) = sysInfo.dwNumberOfProcessors; @@ -332,9 +331,9 @@ void get_system_info() RCT2_GLOBAL(RCT2_ADDRESS_MEM_TOTAL_VIRTUAL, uint32) = memInfo.dwTotalVirtual; uint32 size = 80; - GetUserName(RCT2_ADDRESS_OS_USER_NAME, &size); + GetUserName((char*)RCT2_ADDRESS_OS_USER_NAME, &size); size = 80; - GetComputerName(RCT2_ADDRESS_OS_COMPUTER_NAME, &size); + GetComputerName((char*)RCT2_ADDRESS_OS_COMPUTER_NAME, &size); // Screen Display Width/Height but RCT_ADDRESS_SCREEN_HEIGHT/WIDTH already taken? RCT2_GLOBAL(0x01423C08, sint32) = GetSystemMetrics(SM_CXSCREEN); diff --git a/src/ride.c b/src/ride.c index bb4d8e7164..42f32287ff 100644 --- a/src/ride.c +++ b/src/ride.c @@ -20,6 +20,9 @@ #include "addresses.h" #include "ride.h" +#include "sprite.h" +#include "peep.h" +#include "window.h" #define GET_RIDE(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[x])) #define GET_RIDE_MEASUREMENT(x) (&(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_MEASUREMENTS, rct_ride_measurement)[x])) @@ -166,4 +169,34 @@ void reset_all_ride_build_dates() { ride->build_date -= RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16); } } -} \ No newline at end of file +} + +/** + * rct2: 0x006AC916 + */ +void ride_update_favourited_stat() +{ + rct_ride *ride; + rct_peep* peep; + + for (int i = 0; i < MAX_RIDES; i++) { + ride = GET_RIDE(i); + if (ride->type != RIDE_TYPE_NULL) + ride->guests_favourite = 0; + + } + for (int sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) { + peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep); + if (peep->var_08 != 4) + return; + if (peep->favourite_ride != 0xff) { + ride = GET_RIDE(peep->favourite_ride); + ride->guests_favourite++; + ride->var_14D |= 1; + + } + + } + window_invalidate_by_id(WC_RIDE_LIST, 0); +} + diff --git a/src/ride.h b/src/ride.h index f7152bf3e5..84eb778120 100644 --- a/src/ride.h +++ b/src/ride.h @@ -74,7 +74,8 @@ typedef struct { uint16 var_158; uint8 pad_15A[0x26]; uint16 build_date; - uint8 pad_182[0x14]; + sint16 upkeep_cost; // 0x182 + uint8 pad_184[0x12]; uint16 var_196; uint8 pad_198; uint8 var_199; @@ -260,5 +261,6 @@ int ride_get_total_queue_length(rct_ride *ride); int ride_get_max_queue_time(rct_ride *ride); void ride_init_all(); void reset_all_ride_build_dates(); +void ride_update_favourited_stat(); #endif diff --git a/src/sawyercoding.c b/src/sawyercoding.c index c5393e02d4..7e7a59928b 100644 --- a/src/sawyercoding.c +++ b/src/sawyercoding.c @@ -31,16 +31,15 @@ static void decode_chunk_rotate(char *buffer, int length); * * rct2: 0x00676FD2 */ -int sawyercoding_validate_checksum(HFILE hFile) +int sawyercoding_validate_checksum(HANDLE hFile) { - int i; - uint32 checksum, fileChecksum; + uint32 i, checksum, fileChecksum; DWORD dataSize, bufferSize, numBytesRead; uint8 buffer[1024]; // Get data size if ((dataSize = SetFilePointer(hFile, 0, NULL, FILE_END)) < 8) - return; + return 0; dataSize -= 4; // Calculate checksum @@ -74,7 +73,7 @@ int sawyercoding_validate_checksum(HFILE hFile) * rct2: 0x0067685F * buffer (esi) */ -int sawyercoding_read_chunk(HFILE hFile, uint8 *buffer) +int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer) { DWORD numBytesRead; sawyercoding_chunk_header chunkHeader; @@ -145,7 +144,7 @@ static int decode_chunk_rle(char *buffer, int length) static int decode_chunk_repeat(char *buffer, int length) { int i, j, count; - uint8 *src, *dst, *copyOffset, rleCodeByte; + uint8 *src, *dst, *copyOffset; // Backup buffer src = malloc(length); diff --git a/src/sawyercoding.h b/src/sawyercoding.h index 7b30566703..02b63b6209 100644 --- a/src/sawyercoding.h +++ b/src/sawyercoding.h @@ -36,7 +36,7 @@ enum { CHUNK_ENCODING_ROTATE }; -int sawyercoding_validate_checksum(HFILE hFile); -int sawyercoding_read_chunk(HFILE hFile, uint8 *buffer); +int sawyercoding_validate_checksum(HANDLE hFile); +int sawyercoding_read_chunk(HANDLE hFile, uint8 *buffer); #endif diff --git a/src/scenario.c b/src/scenario.c index 954f2d489c..4e4461e635 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -18,8 +18,6 @@ * along with this program. If not, see . *****************************************************************************/ -#define _CRT_SECURE_NO_WARNINGS - #include #include "addresses.h" #include "date.h" @@ -103,9 +101,8 @@ void scenario_load_list() static void scenario_list_add(char *path) { - int i; rct_scenario_basic *scenario; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; // Check if scenario already exists in list, likely if in scores scenario = get_scenario_by_filename(path); @@ -138,7 +135,7 @@ static void scenario_list_add(char *path) } // Check if the scenario list buffer has room for another scenario - if ((RCT2_NUM_SCENARIOS + 1) * sizeof(rct_scenario_basic) > _scenarioListSize) { + if ((RCT2_NUM_SCENARIOS + 1) * (int)sizeof(rct_scenario_basic) > _scenarioListSize) { // Allocate more room _scenarioListSize += 16 * sizeof(rct_scenario_basic); RCT2_SCENARIO_LIST = (rct_scenario_basic*)rct2_realloc(RCT2_SCENARIO_LIST, _scenarioListSize); @@ -267,8 +264,8 @@ static int scenario_load_basic(char *path) { HANDLE hFile; int _eax; - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; hFile = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL @@ -277,10 +274,10 @@ static int scenario_load_basic(char *path) RCT2_GLOBAL(0x009E382C, HANDLE*) = hFile; // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SCENARIO) { // Read second chunk - sawyercoding_read_chunk(hFile, s6Info); + sawyercoding_read_chunk(hFile, (uint8*)s6Info); CloseHandle(hFile); RCT2_GLOBAL(0x009AA00C, uint8) = 0; if (s6Info->flags != 255) { @@ -322,8 +319,8 @@ void scenario_load(char *path) { HANDLE hFile; int i, j; - rct_s6_header *s6Header = 0x009E34E4; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_header *s6Header = (rct_s6_header*)0x009E34E4; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; hFile = CreateFile( path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL @@ -338,10 +335,10 @@ void scenario_load(char *path) } // Read first chunk - sawyercoding_read_chunk(hFile, s6Header); + sawyercoding_read_chunk(hFile, (uint8*)s6Header); if (s6Header->type == S6_TYPE_SCENARIO) { // Read second chunk - sawyercoding_read_chunk(hFile, s6Info); + sawyercoding_read_chunk(hFile, (uint8*)s6Info); // Read packed objects if (s6Header->num_packed_objects > 0) { @@ -355,35 +352,35 @@ void scenario_load(char *path) object_read_and_load_entries(hFile); // Read flags (16 bytes) - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_MONTH_YEAR); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_MONTH_YEAR); // Read map elements - memset(RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_MAP_ELEMENTS); + memset((void*)RCT2_ADDRESS_MAP_ELEMENTS, 0, MAX_MAP_ELEMENTS * sizeof(rct_map_element)); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_MAP_ELEMENTS); // Read game data, including sprites - sawyercoding_read_chunk(hFile, 0x010E63B8); + sawyercoding_read_chunk(hFile, (uint8*)0x010E63B8); // Read number of guests in park and something else - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_GUESTS_IN_PARK); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_GUESTS_IN_PARK); // Read ? - sawyercoding_read_chunk(hFile, 0x01357BC8); + sawyercoding_read_chunk(hFile, (uint8*)0x01357BC8); // Read park rating - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_PARK_RATING); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_PARK_RATING); // Read ? - sawyercoding_read_chunk(hFile, 0x01357CF2); + sawyercoding_read_chunk(hFile, (uint8*)0x01357CF2); // Read ? - sawyercoding_read_chunk(hFile, 0x0135832C); + sawyercoding_read_chunk(hFile, (uint8*)0x0135832C); // Read ? - sawyercoding_read_chunk(hFile, RCT2_ADDRESS_CURRENT_PARK_VALUE); + sawyercoding_read_chunk(hFile, (uint8*)RCT2_ADDRESS_CURRENT_PARK_VALUE); // Read more game data, including research items and rides - sawyercoding_read_chunk(hFile, 0x01358740); + sawyercoding_read_chunk(hFile, (uint8*)0x01358740); CloseHandle(hFile); @@ -411,7 +408,7 @@ void scenario_load(char *path) void scenario_load_and_play(rct_scenario_basic *scenario) { rct_window *mainWindow; - rct_s6_info *s6Info = 0x0141F570; + rct_s6_info *s6Info = (rct_s6_info*)0x0141F570; RCT2_GLOBAL(0x009AA0F0, uint32) = RCT2_GLOBAL(0x00F663B0, uint32) ^ timeGetTime(); RCT2_GLOBAL(0x009AA0F4, uint32) = RCT2_GLOBAL(0x00F663B4, uint32) ^ timeGetTime(); @@ -422,7 +419,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_ADDRESS(RCT2_ADDRESS_SCENARIOS_PATH, char), scenario->path ); - scenario_load(0x0141EF68); + scenario_load((char*)0x0141EF68); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_PLAYING; viewport_init_all(); game_create_windows(); @@ -461,24 +458,24 @@ void scenario_load_and_play(rct_scenario_basic *scenario) RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); - if (RCT2_ADDRESS(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) + if (RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8) != OBJECTIVE_NONE) window_park_objective_open(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16) = calculate_park_rating(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint16) = calculate_park_value(); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_COMPANY_VALUE, sint16) = calculate_company_value(); RCT2_GLOBAL(0x013587D0, sint16) = RCT2_GLOBAL(0x013573DC, sint16) - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, sint16); - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint16) = ENCRYPT_MONEY(RCT2_GLOBAL(0x013573DC, sint32)); + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(RCT2_GLOBAL(0x013573DC, sint32)); RCT2_CALLPROC_EBPSAFE(0x0069E869); // (loan related) - strcpy(0x0135924A, s6Info->details); - strcpy(0x0135920A, s6Info->name); + strcpy((char*)0x0135924A, s6Info->details); + strcpy((char*)0x0135920A, s6Info->name); if (RCT2_GLOBAL(0x009ADAE4, sint32) != -1) { char *ebp = RCT2_GLOBAL(0x009ADAE4, char*); // - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 2, uint16), 0); // Set park name RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16) = STR_CANT_RENAME_PARK; @@ -487,22 +484,22 @@ void scenario_load_and_play(rct_scenario_basic *scenario) game_do_command(0, 1, 0, *((int*)(0x0141ED68 + 24)), 33, *((int*)(0x0141ED68 + 32)), *((int*)(0x0141ED68 + 28))); // - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0); - strncpy(RCT2_ADDRESS_SCENARIO_NAME, 0x0141ED68, 31); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 0, uint16), 0); + strncpy((char*)RCT2_ADDRESS_SCENARIO_NAME, (char*)0x0141ED68, 31); ((char*)RCT2_ADDRESS_SCENARIO_NAME)[31] = '\0'; // Set scenario details - format_string(0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0); - strncpy(RCT2_ADDRESS_SCENARIO_DETAILS, 0x0141ED68, 255); + format_string((char*)0x0141ED68, RCT2_GLOBAL(ebp + 4, uint16), 0); + strncpy((char*)RCT2_ADDRESS_SCENARIO_DETAILS, (char*)0x0141ED68, 255); ((char*)RCT2_ADDRESS_SCENARIO_DETAILS)[255] = '\0'; } // Set the last saved game path - strcpy(0x009ABB37, 0x009AB5DA); - format_string(0x009ABB37 + strlen(0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), 0x0013573D8); - strcat(0x009ABB37, ".SV6"); + strcpy((char*)0x009ABB37, (char*)0x009AB5DA); + format_string((char*)0x009ABB37 + strlen((char*)0x009ABB37), RCT2_GLOBAL(0x0013573D4, uint16), (void*)0x0013573D8); + strcat((char*)0x009ABB37, ".SV6"); - memset(0x001357848, 0, 56); + memset((void*)0x001357848, 0, 56); RCT2_GLOBAL(0x0135832C, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32) = 0; RCT2_GLOBAL(0x01358334, uint32) = 0; @@ -519,7 +516,7 @@ void scenario_load_and_play(rct_scenario_basic *scenario) park_calculate_size(); RCT2_CALLPROC_EBPSAFE(0x006C1955); RCT2_GLOBAL(0x01358840, uint8) = 0; - memset(0x001358102, 0, 20); + memset((void*)0x001358102, 0, 20); RCT2_GLOBAL(0x00135882E, uint16) = 0; // Open park with free entry when there is no money @@ -572,7 +569,7 @@ void scenario_success() RCT2_CALLPROC_EBPSAFE(0x0069BE9B); // celebration for (i = 0; i < RCT2_GLOBAL(RCT2_ADDRESS_NUM_SCENARIOS, sint32); i++) { - char* cur_scenario_name = RCT2_ADDRESS(0x135936C, char*); + char *cur_scenario_name = RCT2_ADDRESS(0x135936C, char); scenario = &(RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_LIST, rct_scenario_basic*)[i]); if (0 == strncmp(cur_scenario_name, scenario->path, 256)){ @@ -604,7 +601,7 @@ void scenario_objective5_check() memset(type_already_counted, 0, 256); - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { uint8 subtype_id; uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); @@ -640,7 +637,7 @@ void scenario_objective8_check() memset(type_already_counted, 0, 256); - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { uint8 subtype_id; uint32 subtype_p; ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); @@ -660,7 +657,7 @@ void scenario_objective8_check() for (int j = 0; j < limit; ++j) { sum += ((uint32*)&ride->pad_088[92])[j]; } - if ((sum >> 16) > objective_length) { + if ((sum >> 16) > (uint32)objective_length) { type_already_counted[subtype_id]++; rcs++; } @@ -741,7 +738,7 @@ void scenario_objectives_check() { rct_ride* ride; int rcs = 0; - for (int i = 0; i < 255; i++) { + for (int i = 0; i < MAX_RIDES; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->status && ride->excitement > objective_currency) rcs++; @@ -847,7 +844,7 @@ void scenario_update() uint32 month_tick = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16), next_month_tick = month_tick + 4; uint8 month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7, - current_days_in_month = days_in_month[month], + current_days_in_month = (uint8)days_in_month[month], objective_type = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8); if (screen_flags & (~SCREEN_FLAGS_PLAYING)) // only in normal play mode @@ -875,7 +872,7 @@ void scenario_update() scenario_marketing_update(); peep_problem_warnings_update(); RCT2_CALLPROC_EBPSAFE(0x006B7A5E); // check ride reachability - RCT2_CALLPROC_EBPSAFE(0x006AC916); // ride update favourited + ride_update_favourited_stat(); if (month <= 1 && RCT2_GLOBAL(0x009ADAE0, sint32) != -1 && RCT2_GLOBAL(0x009ADAE0 + 14, uint16) & 1) { for (int i = 0; i < 100; ++i) { @@ -893,11 +890,11 @@ void scenario_update() //if ( (unsigned int)((2 * current_day) & 0xFFFF) >= 0xFFF8) { if (next_month_tick % 0x8000 == 0) { - // biweekly checks - RCT2_CALLPROC_EBPSAFE(0x006AC885); + // fortnightly + finance_pay_ride_upkeep(); } - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = next_month_tick; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16) = (uint16)next_month_tick; if (next_month_tick >= 0x10000) { // month ends actions RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16)++; diff --git a/src/screenshot.c b/src/screenshot.c index af65bf976b..25595520b8 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -117,9 +117,9 @@ int screenshot_dump_bmp() BitmapFileHeader header; BitmapInfoHeader info; - int i, x, y, index, width, height, stride; - char *buffer, path[MAX_PATH], *row, *dst; - HFILE hFile; + int i, y, index, width, height, stride; + char *buffer, path[MAX_PATH], *row; + HANDLE hFile; DWORD bytesWritten; // Get a free screenshot path @@ -127,7 +127,7 @@ int screenshot_dump_bmp() return -1; // Open file for writing - hFile = CreateFile(path, GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + hFile = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) return -1; diff --git a/src/settings.c b/src/settings.c deleted file mode 100644 index 6e281aa97a..0000000000 --- a/src/settings.c +++ /dev/null @@ -1,28 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2014 Ted John -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#include -#include -#include -#include -#include -#include "settings.h" -#include "screenshot.h" - diff --git a/src/settings.h b/src/settings.h deleted file mode 100644 index d5e2452ac0..0000000000 --- a/src/settings.h +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** -* Copyright (c) 2014 Ted John, Peter Hill -* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. -* -* This file is part of OpenRCT2. -* -* OpenRCT2 is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. - -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. - -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*****************************************************************************/ - -#ifndef _SETTINGS_H_ -#define _SETTINGS_H_ - -#include -#include -#include "rct2.h" - - - - - - -#endif \ No newline at end of file diff --git a/src/sprites.h b/src/sprites.h index 869f35ddc7..9dd8bec070 100644 --- a/src/sprites.h +++ b/src/sprites.h @@ -79,6 +79,22 @@ enum { SPR_TAB_STATS_5 = SPR_TAB_STATS_0 + 5, SPR_TAB_STATS_6 = SPR_TAB_STATS_0 + 6, + SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY = 5284, + SPR_PEEP_LARGE_FACE_VERY_UNHAPPY = 5285, + SPR_PEEP_LARGE_FACE_UNHAPPY = 5286, + SPR_PEEP_LARGE_FACE_NORMAL = 5287, + SPR_PEEP_LARGE_FACE_HAPPY = 5288, + SPR_PEEP_LARGE_FACE_VERY_HAPPY = 5289, + SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY = 5290, + SPR_PEEP_LARGE_FACE_TIRED = 5291, + SPR_PEEP_LARGE_FACE_VERY_TIRED = 5292, + SPR_PEEP_LARGE_FACE_SICK = 5293, + SPR_PEEP_LARGE_FACE_VERY_SICK = 5294, + + SPR_PEEP_LARGE_FACE_VERY_VERY_SICK = 5298, + + SPR_PEEP_LARGE_FACE_ANGRY = 5314, + SPR_TAB_SHOPS_AND_STALLS_0 = 5351, SPR_TAB_SHOPS_AND_STALLS_1 = SPR_TAB_SHOPS_AND_STALLS_0 + 1, SPR_TAB_SHOPS_AND_STALLS_2 = SPR_TAB_SHOPS_AND_STALLS_0 + 2, @@ -140,6 +156,20 @@ enum { SPR_MOST_CONFUSING_LAYOUT = SPR_AWARD_MOST_UNTIDY + 15, SPR_BEST_GENTLE_RIDES = SPR_AWARD_MOST_UNTIDY + 16, + SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY = 5486, + SPR_PEEP_SMALL_FACE_VERY_UNHAPPY = 5487, + SPR_PEEP_SMALL_FACE_UNHAPPY = 5488, + SPR_PEEP_SMALL_FACE_NORMAL = 5489, + SPR_PEEP_SMALL_FACE_HAPPY = 5490, + SPR_PEEP_SMALL_FACE_VERY_HAPPY = 5491, + SPR_PEEP_SMALL_FACE_VERY_VERY_HAPPY = 5492, + SPR_PEEP_SMALL_FACE_TIRED = 5493, + SPR_PEEP_SMALL_FACE_VERY_TIRED = 5494, + SPR_PEEP_SMALL_FACE_SICK = 5495, + SPR_PEEP_SMALL_FACE_VERY_SICK = 5496, + SPR_PEEP_SMALL_FACE_VERY_VERY_SICK = 5497, + SPR_PEEP_SMALL_FACE_ANGRY = 5498, + SPR_LAND_TOOL_DECREASE = 5499, SPR_LAND_TOOL_INCREASE = 5501, diff --git a/src/strings.c b/src/strings.c index 540e644252..fc50c8f1b6 100644 --- a/src/strings.c +++ b/src/strings.c @@ -32,7 +32,7 @@ */ void format_string(char *dest, rct_string_id format, void *args) { - RCT2_CALLPROC_X(0x006C2555, format, 0, args, 0, 0, dest, 0); + RCT2_CALLPROC_X(0x006C2555, format, 0, (int)args, 0, 0, (int)dest, 0); } void generate_string_file() diff --git a/src/strings.h b/src/strings.h index 7a92046a84..679a0a996c 100644 --- a/src/strings.h +++ b/src/strings.h @@ -280,6 +280,8 @@ enum { STR_SUMMARISED_GUESTS_TIP = 1753, STR_ADMISSION_PRICE = 1756, + STR_OFF = 1775, + STR_ON = 1776, STR_MUSIC = 1777, STR_ACTIONS = 1814, @@ -322,7 +324,7 @@ enum { STR_SHOW_SUBJECT_TIP = 1937, - STR_CELCIUS_VALUE = 2216, + STR_CELSIUS_VALUE = 2216, STR_FAHRENHEIT_VALUE = 2217, STR_PARK_RATING_LABEL = 2220, @@ -330,14 +332,6 @@ enum { STR_GUESTS_IN_PARK_LABEL = 2223, - STR_NUMBER_OF_RIDES_LABEL = 2321, - STR_STAFF_LABEL = 2322, - STR_PARK_SIZE_METRIC_LABEL = 2323, - STR_PARK_SIZE_IMPERIAL_LABEL = 2324, - - SPR_BUY_LAND_RIGHTS_TIP = 2325, - SPR_BUY_CONSTRUCTION_RIGHTS_TIP = 2326, - STR_PARK_INFORMATION_TIP = 2233, STR_RECENT_MESSAGES = 2234, @@ -360,19 +354,43 @@ enum { STR_CHANGE_VERTICAL_LAND_TIP = 2295, STR_SOUND_QUALITY = 2317, + STR_SOUND_LOW = 2318, + STR_SOUND_MEDIUM = 2319, + STR_SOUND_HIGH = 2320, + STR_NUMBER_OF_RIDES_LABEL = 2321, + STR_STAFF_LABEL = 2322, + STR_PARK_SIZE_METRIC_LABEL = 2323, + STR_PARK_SIZE_IMPERIAL_LABEL = 2324, + SPR_BUY_LAND_RIGHTS_TIP = 2325, + SPR_BUY_CONSTRUCTION_RIGHTS_TIP = 2326, STR_CURRENCY = 2328, STR_DISTANCE_AND_SPEED = 2329, STR_TEMPERATURE = 2330, STR_HEIGHT_LABELS = 2331, STR_UNITS = 2332, STR_SOUND = 2333, + STR_POUNDS = 2334, + STR_DOLLARS = 2335, + STR_FRANC = 2336, + STR_DEUTSCHMARK = 2337, + STR_YEN = 2338, + STR_PESETA = 2339, + STR_LIRA = 2340, + STR_GUILDERS = 2341, + STR_KRONA = 2342, + STR_EUROS = 2343, + STR_IMPERIAL = 2344, + STR_METRIC = 2345, STR_DISPLAY = 2346, + //STR_UNITS = 2358, + STR_REAL_VALUES = 2359, STR_DISPLAY_RESOLUTION = 2360, STR_TILE_SMOOTHING = 2361, STR_TILE_SMOOTHING_TIP = 2362, STR_GRIDLINES = 2363, STR_GRIDLINES_TIP = 2364, - + STR_CELSIUS = 2366, + STR_FAHRENHEIT = 2367, //STR_NONE = 2368, STR_LOW = 2369, STR_AVERAGE = 2370, @@ -494,6 +512,8 @@ enum { STR_UNABLE_TO_LOAD_FILE = 3010, STR_FILE_CONTAINS_INVALID_DATA = 3011, + STR_WHITE = 3055, + STR_TRANSLUCENT = 3056, STR_CONSTRUCTION_MARKER = 3057, STR_BEGINNER_PARKS = 3064, diff --git a/src/title.c b/src/title.c index ec26fb9133..1664250b60 100644 --- a/src/title.c +++ b/src/title.c @@ -154,7 +154,7 @@ static void title_update_showcase() rct_window* w; uint8 script_opcode, script_operand; short x, y, z; - int i, _edx; + int i; if (_scriptWaitCounter <= 0) { do { @@ -223,7 +223,7 @@ static void title_update_showcase() _currentScript = _magicMountainScript; if (gRandomShowcase) { if (_currentScript != NULL) - free(_currentScript); + free((uint8*)_currentScript); _currentScript = generate_random_script(); } break; @@ -322,7 +322,7 @@ static void title_play_music() strcat(musicPath, "\\data\\css50.dat"); } - if (RCT2_CALLFUNC_3(0x0040194E, int, int, int, int, 3, musicPath, 0)) // play music + if (RCT2_CALLFUNC_3(0x0040194E, int, int, char*, int, 3, musicPath, 0)) // play music RCT2_CALLPROC_5(0x00401999, int, int, int, int, int, 3, 1, 0, 0, 0); RCT2_GLOBAL(0x009AF600, uint8) = 1; @@ -333,7 +333,7 @@ static uint8 *generate_random_script() int i, j; const int views = 16; - srand(time(NULL)); + srand((unsigned int)time(NULL)); uint8 *script = malloc(views * 8 + 2); i = 0; diff --git a/src/viewport.c b/src/viewport.c index a22af3cf24..b005bafad2 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -78,7 +78,7 @@ void viewport_create(rct_window *w, int x, int y, int width, int height, int ecx { x &= 0xFFFF; y &= 0xFFFF; - RCT2_CALLPROC_X(0x006EB009, (y << 16) | x, (height << 16) | width, ecx, edx, w, 0, 0); + RCT2_CALLPROC_X(0x006EB009, (y << 16) | x, (height << 16) | width, ecx, edx, (int)w, 0, 0); } /** @@ -103,7 +103,7 @@ void viewport_update_pointers() */ void viewport_update_position(rct_window *window) { - RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, window, 0, 0); + RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, (int)window, 0, 0); } /** @@ -112,7 +112,7 @@ void viewport_update_position(rct_window *window) */ void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, int top, int right, int bottom) { - RCT2_CALLPROC_X(0x00685C02, left , top, 0, right, viewport, dpi, bottom); + RCT2_CALLPROC_X(0x00685C02, left , top, 0, right, (int)viewport, (int)dpi, bottom); } /** diff --git a/src/widget.c b/src/widget.c index 14af17a500..1ea2c83ed8 100644 --- a/src/widget.c +++ b/src/widget.c @@ -250,7 +250,6 @@ static void widget_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget { rct_widget* widget; int l, t, r, b, press; - uint32 image; uint8 colour; // Get the widget @@ -333,8 +332,7 @@ static void widget_tab_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetInd static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, press; - uint32 image; + int l, t, r, b; uint8 colour; if (!widget_is_disabled(w, widgetIndex) && widget_is_highlighted(w, widgetIndex)) { @@ -377,7 +375,7 @@ static void widget_flat_button_draw(rct_drawpixelinfo *dpi, rct_window *w, int w static void widget_text_button(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press, stringId; + int l, t, r, b, press; uint8 colour; // Get the widget @@ -407,7 +405,7 @@ static void widget_text_button(rct_drawpixelinfo *dpi, rct_window *w, int widget static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press, stringId; + int l, t, r, b, stringId; uint8 colour; // Get the widget @@ -435,7 +433,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge gfx_draw_string_left_clipped( dpi, stringId, - 0x013CE952, + (void*)0x013CE952, colour, l + 1, t, @@ -447,7 +445,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge gfx_draw_string_centred_clipped( dpi, stringId, - 0x013CE952, + (void*)0x013CE952, colour, (w->x + w->x + widget->left + widget->right + 1) / 2 - 1, t, @@ -463,7 +461,7 @@ static void widget_text_unknown(rct_drawpixelinfo *dpi, rct_window *w, int widge static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press; + int l, t, r, b; uint8 colour; // Get the widget @@ -483,7 +481,7 @@ static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; - gfx_draw_string_left(dpi, widget->image, 0x013CE952, colour, l + 1, t); + gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l + 1, t); } /** @@ -493,7 +491,7 @@ static void widget_text(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) static void widget_text_inset(rct_drawpixelinfo *dpi, rct_window *w, int widgetIndex) { rct_widget* widget; - int l, t, r, b, width, press; + int l, t, r, b; uint8 colour; // Get the widget @@ -570,7 +568,7 @@ static void widget_groupbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg colour = w->colours[widget->colour] & 0x7F; if (widget_is_disabled(w, widgetIndex)) colour |= 0x40; - gfx_draw_string_left(dpi, widget->image, 0x013CE952, colour, l, t); + gfx_draw_string_left(dpi, widget->image, (void*)0x013CE952, colour, l, t); textRight = gLastDrawStringX + 1; } @@ -764,7 +762,7 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget rct_widget* widget; rct_scroll* scroll; int scrollIndex; - int l, t, r, b, press, ebp; + int l, t, r, b; int cl, ct, cr, cb; uint8 colour; rct_drawpixelinfo scroll_dpi; @@ -826,7 +824,7 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget // Draw the scroll contents if (scroll_dpi.width > 0 && scroll_dpi.height > 0) - RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, w, &scroll_dpi, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_PAINT], 0, 0, 0, 0, (int)w, (int)&scroll_dpi, 0); } static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour) @@ -914,20 +912,20 @@ static void widget_draw_image(rct_drawpixelinfo *dpi, rct_window *w, int widgetI colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC4A, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; - memset(0x009DED74, colour, 256); + memset((void*)0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; image &= 0x7FFFF; - RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, dpi, 0); + RCT2_CALLPROC_X(0x0067A46E, 0, image, l + 1, t + 1, 0, (int)dpi, 0); // Draw greyed out (dark) colour = w->colours[widget->colour]; colour = RCT2_ADDRESS(0x00141FC48, uint8)[(colour & 0x7F) * 8] & 0xFF; RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009DED74; - memset(0x009DED74, colour, 256); + memset((void*)0x009DED74, colour, 256); RCT2_GLOBAL(0x009DED74, uint8) = 0; RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000; - RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, dpi, 0); + RCT2_CALLPROC_X(0x0067A46E, 0, image, l, t, 0, (int)dpi, 0); } else { if (image & 0x80000000) { // ? diff --git a/src/window.c b/src/window.c index f41a874ff6..11a43c5567 100644 --- a/src/window.c +++ b/src/window.c @@ -111,7 +111,7 @@ void window_dispatch_update_all() RCT2_GLOBAL(0x01423604, sint32)++; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16)++; for (w = RCT2_LAST_WINDOW; w >= RCT2_FIRST_WINDOW; w--) - RCT2_CALLPROC_X(w->event_handlers[WE_UPDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UPDATE], 0, 0, 0, 0, (int)w, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006EE411); // handle_text_input } @@ -142,7 +142,7 @@ void window_update_all() if (RCT2_GLOBAL(0x009DEB7C, sint16) >= 1000) { RCT2_GLOBAL(0x009DEB7C, sint16) = 0; for (w = RCT2_LAST_WINDOW; w >= RCT2_FIRST_WINDOW; w--) - RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, (int)w, 0, 0); } // Border flash invalidation @@ -164,7 +164,7 @@ void window_update_all() */ static void window_scroll_wheel_input(rct_window *w, int scrollIndex, int wheel) { - int widgetIndex, newValue, size; + int widgetIndex, size; rct_scroll *scroll; rct_widget *widget; @@ -238,7 +238,7 @@ static void window_viewport_wheel_input(rct_window *w, int wheel) */ static void window_all_wheel_input() { - int i, raw, wheel, widgetIndex; + int raw, wheel, widgetIndex; rct_window *w; rct_widget *widget; rct_scroll *scroll; @@ -402,9 +402,9 @@ rct_window *window_create_auto_pos(int width, int height, uint32 *event_handlers ebx = (height << 16) | width; ecx = (flags << 8) | cls; - edx = event_handlers; + edx = (int)event_handlers; RCT2_CALLFUNC_X(0x006EA9B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return esi; + return (rct_window*)esi; } /** @@ -421,7 +421,7 @@ void window_close(rct_window* window) return; // Call close event of window - RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, window, 0, 0); + RCT2_CALLPROC_X(window->event_handlers[WE_CLOSE], 0, 0, 0, 0, (int)window, 0, 0); window = window_find_by_id(window->classification, window->number); @@ -498,22 +498,22 @@ rct_window *window_find_by_id(rct_windowclass cls, rct_windownumber number) * * rct2: 0x006E403C */ -void window_close_top() { - rct_window* w; +void window_close_top() +{ + rct_window* w; - window_close_by_id(WC_DROPDOWN, 0); + window_close_by_id(WC_DROPDOWN, 0); - if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) { - if (RCT2_ADDRESS(0x0141F570, uint8) != 1) { - return; - } - } - for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++){ - if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { - window_close(w); - return; - } - } + if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) + if (RCT2_GLOBAL(0x0141F570, uint8) != 1) + return; + + for (w = RCT2_FIRST_WINDOW; w < RCT2_LAST_WINDOW; w++) { + if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { + window_close(w); + return; + } + } } /** @@ -540,7 +540,7 @@ void window_close_all() { */ rct_window *window_find_from_point(int x, int y) { - rct_window *w, *w2; + rct_window *w; rct_widget *widget; int widget_index; @@ -576,7 +576,7 @@ int window_find_widget_from_point(rct_window *w, int x, int y) int i, widget_index; // Invalidate the window - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); // Find the widget at point x, y widget_index = -1; @@ -709,7 +709,7 @@ void window_init_scroll_widgets(rct_window *w) */ void window_update_scroll_widgets(rct_window *w) { - RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006EAE4E, 0, 0, 0, 0, (int)w, 0, 0); } int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *height) @@ -717,7 +717,7 @@ int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *heig rct_widget *widget = window_get_scroll_widget(w, scrollIndex); int widgetIndex = window_get_widget_index(w, widget); - int eax = 0, ebx = scrollIndex * sizeof(rct_scroll), ecx = 0, edx = 0, esi = w, edi = widgetIndex * sizeof(rct_widget), ebp = 0; + int eax = 0, ebx = scrollIndex * sizeof(rct_scroll), ecx = 0, edx = 0, esi = (int)w, edi = widgetIndex * sizeof(rct_widget), ebp = 0; RCT2_CALLFUNC_X(w->event_handlers[WE_SCROLL_GETSIZE], & eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); *width = ecx; *height = edx; @@ -858,7 +858,7 @@ rct_window *window_get_main() */ void window_scroll_to_location(rct_window *w, int x, int y, int z) { - RCT2_CALLPROC_X(0x006E7C9C, x, 0, y, z, w, 0, 0); + RCT2_CALLPROC_X(0x006E7C9C, x, 0, y, z, (int)w, 0, 0); } /** @@ -867,7 +867,7 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z) */ void window_rotate_camera(rct_window *w) { - RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -876,7 +876,7 @@ void window_rotate_camera(rct_window *w) */ void window_zoom_in(rct_window *w) { - RCT2_CALLPROC_X(0x006887A6, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006887A6, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -885,7 +885,7 @@ void window_zoom_in(rct_window *w) */ void window_zoom_out(rct_window *w) { - RCT2_CALLPROC_X(0x006887E0, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006887E0, 0, 0, 0, 0, (int)w, 0, 0); } /** @@ -894,7 +894,7 @@ void window_zoom_out(rct_window *w) */ void window_show_textinput(rct_window *w, int widgetIndex, uint16 title, uint16 text, int value) { - RCT2_CALLPROC_X(0x006EE308, title, text, value, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006EE308, title, text, value, widgetIndex, (int)w, 0, 0); } /** @@ -911,11 +911,6 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom) rct_drawpixelinfo *dpi, copy; int overflow; - char *copyBits; - int copyLeft; - int copyWidth; - int copyPitch; - // RCT2_CALLPROC_X(0x006E756C, left, top, 0, right, w, 0, bottom); // return; @@ -989,10 +984,10 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom) RCT2_GLOBAL(0x0141F743, uint8) = v->colours[3] & 0x7F; // Invalidate the window - RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, v, 0, 0); + RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)v, 0, 0); // Paint the window - RCT2_CALLPROC_X(v->event_handlers[WE_PAINT], 0, 0, 0, 0, v, dpi, 0); + RCT2_CALLPROC_X(v->event_handlers[WE_PAINT], 0, 0, 0, 0, (int)v, (int)dpi, 0); } } @@ -1115,8 +1110,8 @@ void window_resize(rct_window *w, int dw, int dh) w->width = clamp(w->min_width, w->width + dw, w->max_width); w->height = clamp(w->min_height, w->height + dh, w->max_height); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], w->width, w->height, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], w->width, w->height, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); // Update scroll widgets for (i = 0; i < 3; i++) { @@ -1217,7 +1212,7 @@ void tool_cancel() RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) ); if (w != NULL) - RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), (int)w, 0, 0); } } } @@ -1226,7 +1221,8 @@ void tool_cancel() * * rct2: 0x0068F083 */ -void window_guest_list_init_vars_a() { +void window_guest_list_init_vars_a() +{ RCT2_GLOBAL(0x013B0E6C, uint32) = 1; RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; RCT2_GLOBAL(0x00F1EE02, uint32) = 0xFFFFFFFF; @@ -1237,7 +1233,8 @@ void window_guest_list_init_vars_a() { * * rct2: 0x0068F050 */ -void window_guest_list_init_vars_b() { +void window_guest_list_init_vars_b() +{ RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_TAB, uint8) = 0; RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_GUEST_LIST_SELECTED_VIEW, uint8) = 0; RCT2_GLOBAL(0x00F1AF1C, uint32) = 0xFFFFFFFF; @@ -1249,8 +1246,7 @@ void window_guest_list_init_vars_b() { /** * Wrapper for window events so C functions can call them */ -void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event) { - - RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, w, 0, 0); - +void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event) +{ + RCT2_CALLPROC_X(w->event_handlers[event], 0, 0, 0, widgetIndex, (int)w, 0, 0); } diff --git a/src/window_about.c b/src/window_about.c index c6657996f8..4250d65cdd 100644 --- a/src/window_about.c +++ b/src/window_about.c @@ -46,7 +46,7 @@ static void window_about_emptysub() { } static void window_about_mouseup(); static void window_about_paint(); -static uint32 window_about_events[] = { +static void* window_about_events[] = { window_about_emptysub, window_about_mouseup, window_about_emptysub, @@ -83,7 +83,6 @@ static uint32 window_about_events[] = { */ void window_about_open() { - int x, y; rct_window* window; // Check if window is already open @@ -96,7 +95,7 @@ void window_about_open() max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 165), 400, 330, - window_about_events, + (uint32*)window_about_events, WC_ABOUT, 0 ); @@ -115,7 +114,6 @@ void window_about_open() */ static void window_about_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -155,40 +153,40 @@ static void window_about_paint() // Version RCT2_GLOBAL(0x009C383C, uint8) = 49; - gfx_draw_string_centred(dpi, STR_VERSION_X, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_VERSION_X, x, y, 0, (void*)0x009E2D28); // Credits RCT2_GLOBAL(0x009C383C, uint8) = 48; y += 10; - gfx_draw_string_centred(dpi, STR_COPYRIGHT_CS, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_COPYRIGHT_CS, x, y, 0, (void*)0x009E2D28); y += 79; - gfx_draw_string_centred(dpi, STR_DESIGNED_AND_PROGRAMMED_BY_CS, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_DESIGNED_AND_PROGRAMMED_BY_CS, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_GRAPHICS_BY_SF, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_GRAPHICS_BY_SF, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_SOUND_AND_MUSIC_BY_AB, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_SOUND_AND_MUSIC_BY_AB, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_ADDITIONAL_SOUNDS_RECORDED_BY_DE, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_ADDITIONAL_SOUNDS_RECORDED_BY_DE, x, y, 0, (void*)0x009E2D28); y += 13; - gfx_draw_string_centred(dpi, STR_REPRESENTATION_BY_JL, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_REPRESENTATION_BY_JL, x, y, 0, (void*)0x009E2D28); y += 25; - gfx_draw_string_centred(dpi, STR_THANKS_TO, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_THANKS_TO, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_THANKS_TO_PEOPLE, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_THANKS_TO_PEOPLE, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_1, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_1, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_2, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_2, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_3, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_3, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_4, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_4, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_5, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_5, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_6, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_6, x, y, 0, (void*)0x009E2D28); y += 10; - gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_7, x, y, 0, 0x009E2D28); + gfx_draw_string_centred(dpi, STR_CREDIT_SPARE_7, x, y, 0, (void*)0x009E2D28); // Images gfx_draw_sprite(dpi, SPR_CREDITS_CHRIS_SAWYER_SMALL, w->x + 92, w->y + 40); diff --git a/src/window_banner.c b/src/window_banner.c index 89bf755a46..8f930d330b 100644 --- a/src/window_banner.c +++ b/src/window_banner.c @@ -61,7 +61,7 @@ static void window_banner_textinput(); static void window_banner_invalidate(); static void window_banner_paint(); -static uint32 window_banner_events[] = { +static void* window_banner_events[] = { window_banner_emptysub, window_banner_mouseup, window_banner_emptysub, @@ -82,7 +82,7 @@ static uint32 window_banner_events[] = { window_banner_emptysub, window_banner_emptysub, window_banner_textinput, - 0x006BA7B5, + (void*)0x006BA7B5, window_banner_emptysub, window_banner_emptysub, window_banner_emptysub, @@ -100,7 +100,6 @@ void window_banner_open() { rct_windownumber windownumber; rct_window* w; - rct_viewport *viewport; rct_widget *viewportWidget; //__asm mov windownumber, ax // not quite right I think @@ -111,7 +110,7 @@ void window_banner_open() if (w != NULL) return; - w = window_create_auto_pos(113, 96, window_banner_events, WC_BANNER, 0); + w = window_create_auto_pos(113, 96, (uint32*)window_banner_events, WC_BANNER, 0); w->widgets = window_banner_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | diff --git a/src/window_cheats.c b/src/window_cheats.c index 4e9b188f53..8dfbb32e21 100644 --- a/src/window_cheats.c +++ b/src/window_cheats.c @@ -84,7 +84,7 @@ static void window_cheats_invalidate(); static void window_cheats_paint(); static void window_cheats_set_page(rct_window *w, int page); -static uint32 window_cheats_money_events[] = { +static void* window_cheats_money_events[] = { window_cheats_emptysub, window_cheats_money_mouseup, window_cheats_emptysub, @@ -115,7 +115,7 @@ static uint32 window_cheats_money_events[] = { window_cheats_emptysub }; -static uint32 window_cheats_guests_events[] = { +static void* window_cheats_guests_events[] = { window_cheats_emptysub, window_cheats_guests_mouseup, window_cheats_emptysub, @@ -146,7 +146,7 @@ static uint32 window_cheats_guests_events[] = { window_cheats_emptysub }; -static uint32 *window_cheats_page_events[] = { +static void* window_cheats_page_events[] = { window_cheats_money_events, window_cheats_guests_events, }; @@ -167,7 +167,7 @@ void window_cheats_open() if (window != NULL) return; - window = window_create(32, 32, WW, WH, window_cheats_money_events, WC_CHEATS, 0); + window = window_create(32, 32, WW, WH, (uint32*)window_cheats_money_events, WC_CHEATS, 0); window->widgets = window_cheats_money_widgets; window->enabled_widgets = window_cheats_page_enabled_widgets[0]; window_init_scroll_widgets(window); @@ -211,7 +211,6 @@ static void window_cheats_money_mouseup() static void window_cheats_guests_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -260,7 +259,7 @@ static void window_cheats_invalidate() __asm mov w, esi strcpy((char*)0x009BC677, "Cheats"); - rct_widget **widgets = window_cheats_page_widgets[w->page]; + rct_widget *widgets = window_cheats_page_widgets[w->page]; if (w->widgets != widgets) { w->widgets = widgets; window_init_scroll_widgets(w); @@ -269,7 +268,7 @@ static void window_cheats_invalidate() // Set correct active tab for (i = 0; i < 7; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); } static void window_cheats_paint() diff --git a/src/window_clear_scenery.c b/src/window_clear_scenery.c index f5a708f83d..81cc447c78 100644 --- a/src/window_clear_scenery.c +++ b/src/window_clear_scenery.c @@ -53,7 +53,7 @@ static void window_clear_scenery_update(); static void window_clear_scenery_invalidate(); static void window_clear_scenery_paint(); -static uint32 window_clear_scenery_events[] = { +static void* window_clear_scenery_events[] = { window_clear_scenery_close, window_clear_scenery_mouseup, window_clear_scenery_emptysub, @@ -96,7 +96,7 @@ void window_clear_scenery_open() if (window_find_by_id(WC_CLEAR_SCENERY, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 67, window_clear_scenery_events, WC_CLEAR_SCENERY, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 67, (uint32*)window_clear_scenery_events, WC_CLEAR_SCENERY, 0); window->widgets = window_clear_scenery_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_INCREMENT) | (1 << WIDX_DECREMENT); window_init_scroll_widgets(window); diff --git a/src/window_dropdown.c b/src/window_dropdown.c index 14c27202a2..84607a4632 100644 --- a/src/window_dropdown.c +++ b/src/window_dropdown.c @@ -57,7 +57,7 @@ uint32 gDropdownItemsChecked; static void window_dropdown_emptysub() { } static void window_dropdown_paint(); -static uint32 window_dropdown_events[] = { +static void* window_dropdown_events[] = { window_dropdown_emptysub, window_dropdown_emptysub, window_dropdown_emptysub, @@ -130,12 +130,10 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width) { rct_window* w; - int i, string_width, max_string_width; - char buffer[256]; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); + memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -159,7 +157,7 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo x, y + extray, window_dropdown_widgets[WIDX_BACKGROUND].right + 1, window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1, - window_dropdown_events, + (uint32*)window_dropdown_events, WC_DROPDOWN, 0x02 ); @@ -199,12 +197,12 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo */ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns) { - int i, width, height; + int width, height; rct_window* w; // Copy the formats and arguments until all use of it is decompiled - memcpy(0x009DEBA4, gDropdownItemsFormat, 40 * 2); - memcpy(0x009DEBF4, gDropdownItemsArgs, 40 * 8); + memcpy((void*)0x009DEBA4, gDropdownItemsFormat, 40 * 2); + memcpy((void*)0x009DEBF4, gDropdownItemsArgs, 40 * 8); RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02); if (flags & 0x80) @@ -237,7 +235,7 @@ void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 fl x, y + extray, window_dropdown_widgets[WIDX_BACKGROUND].right + 1, window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1, - window_dropdown_events, + (uint32*)window_dropdown_events, WC_DROPDOWN, WF_STICK_TO_FRONT ); @@ -312,7 +310,7 @@ static void window_dropdown_paint() item = gDropdownItemsFormat[i]; if (item == (uint16)-1 || item == (uint16)-2) { // Image item - image = gDropdownItemsArgs[i]; + image = *((uint32*)&gDropdownItemsArgs[i]); if (item == (uint16)-2 && _dropdown_highlighted_index == i) image++; diff --git a/src/window_footpath.c b/src/window_footpath.c index 44ab834559..38da0c66e6 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -116,7 +116,7 @@ static void window_footpath_toolup(); static void window_footpath_invalidate(); static void window_footpath_paint(); -static uint32 window_footpath_events[] = { +static void* window_footpath_events[] = { window_footpath_close, window_footpath_mouseup, window_footpath_emptysub, @@ -174,7 +174,7 @@ void window_footpath_open() 29, 106, 381, - window_footpath_events, + (uint32*)window_footpath_events, WC_FOOTPATH, 0 ); @@ -305,25 +305,25 @@ static void window_footpath_mousedown() window_footpath_show_footpath_types_dialog(w, widget, 1); break; case WIDX_DIRECTION_NW: - RCT2_CALLPROC_X(0x006A8111, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8111, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_NE: - RCT2_CALLPROC_X(0x006A8135, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8135, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_SW: - RCT2_CALLPROC_X(0x006A815C, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A815C, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_DIRECTION_SE: - RCT2_CALLPROC_X(0x006A8183, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8183, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_SLOPEDOWN: - RCT2_CALLPROC_X(0x006A81AA, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81AA, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_LEVEL: - RCT2_CALLPROC_X(0x006A81C5, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81C5, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_SLOPEUP: - RCT2_CALLPROC_X(0x006A81E0, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A81E0, 0, 0, 0, 0, (int)w, 0, 0); break; } } @@ -388,10 +388,9 @@ static void window_footpath_dropdown() */ static void window_footpath_toolupdate() { - int x, y, z; + int x, y; short widgetIndex; rct_window *w; - rct_map_element *mapElement; __asm mov x, eax __asm mov y, ebx @@ -401,7 +400,7 @@ static void window_footpath_toolupdate() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_set_provisional_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A8388, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8388, 0, 0, 0, 0, (int)w, 0, 0); } } @@ -411,10 +410,9 @@ static void window_footpath_toolupdate() */ static void window_footpath_tooldown() { - int x, y, z; + int x, y; short widgetIndex; rct_window *w; - rct_map_element *mapElement; __asm mov x, eax __asm mov y, ebx @@ -424,7 +422,7 @@ static void window_footpath_tooldown() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_place_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A840F, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A840F, x, y, 0, 0, (int)w, 0, 0); } } @@ -444,7 +442,7 @@ static void window_footpath_tooldrag() __asm mov w, esi if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - RCT2_CALLPROC_X(0x006A82C5, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A82C5, x, y, 0, 0, (int)w, 0, 0); } } @@ -464,7 +462,7 @@ static void window_footpath_toolup() __asm mov w, esi if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - RCT2_CALLPROC_X(0x006A8380, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x006A8380, x, y, 0, 0, (int)w, 0, 0); } } @@ -649,7 +647,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) x = eax & 0xFFFF; z = ebx & 0xFF; y = ecx & 0xFFFF; - mapElement = edx; + mapElement = (rct_map_element*)edx; if (z == 0) { RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~1; @@ -686,8 +684,7 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) */ static int window_footpath_set_provisional_path(int type, int x, int y, int z, int slope) { - int cost; - int eax, ebx, ecx, edx, esi, edi, ebp; + int eax, cost; RCT2_CALLPROC_EBPSAFE(0x006A77FF); @@ -732,7 +729,7 @@ static void window_footpath_place_path_at_point(int x, int y) x = eax & 0xFFFF; z = ebx & 0xFF; y = ecx & 0xFFFF; - mapElement = edx; + mapElement = (rct_map_element*)edx; if (z == 0) return; @@ -775,7 +772,7 @@ static void window_footpath_construct() */ static void window_footpath_remove() { - int x, y, z, lastTile; + int x, y, lastTile; rct_map_element *mapElement; // RCT2_CALLPROC_EBPSAFE(0x006A7863); diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c index 00eacc24e3..1545a57e8c 100644 --- a/src/window_game_bottom_toolbar.c +++ b/src/window_game_bottom_toolbar.c @@ -77,7 +77,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w); static void window_game_bottom_toolbar_draw_tutorial_text(rct_drawpixelinfo *dpi, rct_window *w); -static uint32 window_game_bottom_toolbar_events[] = { +static void* window_game_bottom_toolbar_events[] = { window_game_bottom_toolbar_emptysub, window_game_bottom_toolbar_mouseup, window_game_bottom_toolbar_emptysub, @@ -119,7 +119,7 @@ void window_game_bottom_toolbar_open() window = window_create( 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, - window_game_bottom_toolbar_events, + (uint32*)window_game_bottom_toolbar_events, WC_BOTTOM_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 ); @@ -204,28 +204,27 @@ static void window_game_bottom_toolbar_tooltip() { int month, day; short widgetIndex; - rct_window *w, *mainWindow; - rct_news_item *newsItem; + rct_window *w; __asm mov widgetIndex, dx __asm mov w, esi switch (widgetIndex) { case WIDX_MONEY: - *((int*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32); - *((int*)0x013CE956) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); + RCT2_GLOBAL(0x013CE952, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PROFIT, sint32); + RCT2_GLOBAL(0x013CE956, int) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_VALUE, sint32); widgetIndex = 0; break; case WIDX_PARK_RATING: - *((short*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16); + RCT2_GLOBAL(0x013CE952, short) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16); widgetIndex = 0; break; case WIDX_DATE: month = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16) & 7; day = ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, sint16) * days_in_month[month]) >> 16) & 0xFF; - - *((short*)0x013CE952) = STR_DATE_DAY_1 + day; - *((short*)0x013CE954) = STR_MONTH_MARCH + month; + + RCT2_GLOBAL(0x013CE952, short) = STR_DATE_DAY_1 + day; + RCT2_GLOBAL(0x013CE954, short) = STR_MONTH_MARCH + month; widgetIndex = 0; break; } @@ -332,7 +331,6 @@ void window_game_bottom_toolbar_invalidate_news_item() */ static void window_game_bottom_toolbar_paint() { - int x, y, imgId; rct_window *w; rct_drawpixelinfo *dpi; @@ -388,10 +386,10 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r // Draw money if (!(RCT2_GLOBAL(0x0013573E4, uint32) & 0x800)) { - *((int*)0x013CE952) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); + RCT2_GLOBAL(0x013CE952, int) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); gfx_draw_string_centred( dpi, - (*((int*)0x013CE952) < 0 ? 1391 : 1390), + (RCT2_GLOBAL(0x013CE952, int) < 0 ? 1391 : 1390), x, y - 3, (RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass) == 2 && RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WIDGETINDEX, sint32) == WIDX_MONEY ? 2 : w->colours[0] & 0x7F), (void*)0x013CE952 @@ -458,7 +456,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, y = window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top + w->y + 2; // Date - *((short*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); + RCT2_GLOBAL(0x013CE952, short) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); gfx_draw_string_centred( dpi, 1845, @@ -473,12 +471,12 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, y += 11; temperature = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8); - format = STR_CELCIUS_VALUE; - if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FAHRENHEIT, uint8)) { - temperature = climate_celcius_to_fahrenheit(temperature); + format = STR_CELSIUS_VALUE; + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8)) { + temperature = climate_celsius_to_fahrenheit(temperature); format = STR_FAHRENHEIT_VALUE; } - *((short*)0x013CE952) = temperature; + RCT2_GLOBAL(0x013CE952, short) = temperature; gfx_draw_string_left(dpi, format, (void*)0x013CE952, 0, x, y + 6); x += 30; @@ -525,7 +523,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc (window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right) / 2 + w->x, w->y + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].top + 11, 0, - dpi, + (int)dpi, (newsItem->ticks << 16) | (window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right - window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left - 62) ); diff --git a/src/window_game_top_toolbar.c b/src/window_game_top_toolbar.c index d64bb1b862..f6d893d16d 100644 --- a/src/window_game_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -82,7 +82,7 @@ static void window_game_top_toolbar_dropdown(); static void window_game_top_toolbar_invalidate(); static void window_game_top_toolbar_paint(); -static uint32 window_game_top_toolbar_events[] = { +static void* window_game_top_toolbar_events[] = { window_game_top_toolbar_emptysub, window_game_top_toolbar_mouseup, window_game_top_toolbar_emptysub, @@ -92,11 +92,11 @@ static uint32 window_game_top_toolbar_events[] = { window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, - 0x0066CB25, - 0x0066CB73, - 0x0066CB4E, - 0x0066CC5B, - 0x0066CA58, + (void*)0x0066CB25, + (void*)0x0066CB73, + (void*)0x0066CB4E, + (void*)0x0066CC5B, + (void*)0x0066CA58, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, window_game_top_toolbar_emptysub, @@ -124,7 +124,7 @@ void window_game_top_toolbar_open() window = window_create( 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, - window_game_top_toolbar_events, + (uint32*)window_game_top_toolbar_events, WC_TOP_TOOLBAR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5 ); @@ -356,7 +356,7 @@ static void window_game_top_toolbar_dropdown() break; } - char *src = 0x0141EF67; + char *src = (char*)0x0141EF67; do { src++; } while (*src != '.' && *src != '\0'); diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 0dbd247bb3..9e66016aac 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -84,7 +84,7 @@ static void window_guest_list_invalidate(); static void window_guest_list_paint(); static void window_guest_list_scrollpaint(); -static uint32 window_guest_list_events[] = { +static void* window_guest_list_events[] = { window_guest_list_emptysub, window_guest_list_mouseup, window_guest_list_resize, @@ -146,7 +146,7 @@ void window_guest_list_open() if (window != NULL) return; - window = window_create_auto_pos(350, 330, window_guest_list_events, WC_GUEST_LIST, 0x0400); + window = window_create_auto_pos(350, 330, (uint32*)window_guest_list_events, WC_GUEST_LIST, 0x0400); window->widgets = window_guest_list_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -184,7 +184,6 @@ void window_guest_list_open() */ static void window_guest_list_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -442,7 +441,7 @@ static void window_guest_list_scrollmousedown() if (i == 0) { // Open guest window - RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, peep, 0, 0, 0); + RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); break; } else { i--; @@ -505,7 +504,7 @@ static void window_guest_list_invalidate() w->pressed_widgets &= ~(1 << WIDX_TAB_1); w->pressed_widgets &= ~(1 << WIDX_TAB_2); - w->pressed_widgets |= (1 << (_window_guest_list_selected_tab + WIDX_TAB_1)); + w->pressed_widgets |= (1LL << (_window_guest_list_selected_tab + WIDX_TAB_1)); window_guest_list_widgets[WIDX_INFO_TYPE_DROPDOWN].image = STR_ACTIONS + _window_guest_list_selected_view; window_guest_list_widgets[WIDX_MAP].type = WWT_EMPTY; @@ -540,10 +539,9 @@ static void window_guest_list_paint() // Widgets window_draw_widgets(w, dpi); - // Tab 1 image i = (_window_guest_list_selected_tab == 0 ? w->var_490 & 0x0FFFFFFFC : 0); - i += ((int*)*((int*)0x00982708))[0] + 1; + i += RCT2_ADDRESS(RCT2_GLOBAL(0x00982708, int), int)[0] + 1; i |= 0xA1600000; gfx_draw_sprite( dpi, @@ -576,14 +574,14 @@ static void window_guest_list_paint() } else { format = STR_ALL_GUESTS_SUMMARISED; } - gfx_draw_string_left_clipped(dpi, format, 0x00F1EDF6, 0, x, y, 310); + gfx_draw_string_left_clipped(dpi, format, (void*)0x00F1EDF6, 0, x, y, 310); // Number of guests (list items) if (_window_guest_list_selected_tab == PAGE_INDIVIDUAL) { x = w->x + 4; y = w->y + window_guest_list_widgets[WIDX_GUEST_LIST].bottom + 2; RCT2_GLOBAL(0x013CE952, sint16) = w->var_492; - gfx_draw_string_left(dpi, (w->var_492 == 1 ? 1755 : 1754), 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, (w->var_492 == 1 ? 1755 : 1754), (void*)0x013CE952, 0, x, y); } } @@ -594,7 +592,7 @@ static void window_guest_list_paint() static void window_guest_list_scrollpaint() { int eax, ebx, ecx, edx, esi, edi, ebp; - int spriteIdx, format, numGuests, i, j, x, y; + int spriteIdx, format, numGuests, i, j, y; rct_window *w; rct_drawpixelinfo *dpi; rct_peep *peep; @@ -645,7 +643,7 @@ static void window_guest_list_scrollpaint() // Guest name RCT2_GLOBAL(0x013CE952, uint16) = peep->name_string_idx; RCT2_GLOBAL(0x013CE954, uint32) = peep->id; - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 113); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 0, y - 1, 113); switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: @@ -665,7 +663,7 @@ static void window_guest_list_scrollpaint() RCT2_GLOBAL(0x013CE952, uint16) = ebx; RCT2_GLOBAL(0x013CE952 + 2, uint16) = ecx; RCT2_GLOBAL(0x013CE952 + 4, uint32) = edx; - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 133, y - 1, 314); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 133, y - 1, 314); break; case VIEW_THOUGHTS: // For each thought @@ -686,7 +684,7 @@ static void window_guest_list_scrollpaint() RCT2_GLOBAL(0x013CE952, uint16) = ebx; RCT2_GLOBAL(0x013CE952 + 2, uint32) = *((uint32*)esi); RCT2_GLOBAL(0x013CE952 + 6, uint16) = *((uint16*)(esi + 4)); - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 118, y - 1, 329); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 118, y - 1, 329); break; } break; @@ -726,11 +724,11 @@ static void window_guest_list_scrollpaint() RCT2_GLOBAL(0x013CE952 + 2, uint16) = _window_guest_list_groups_argument_1[i] >> 16; RCT2_GLOBAL(0x013CE952 + 4, uint32) = _window_guest_list_groups_argument_2[i]; RCT2_GLOBAL(0x013CE952 + 10, uint32) = numGuests; - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 0, y - 1, 414); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 0, y - 1, 414); // Draw guest count RCT2_GLOBAL(0x013CE95A, uint16) = STR_GUESTS_COUNT_COMMA_SEP; - gfx_draw_string_right(dpi, format, 0x0013CE95A, 0, 326, y - 1); + gfx_draw_string_right(dpi, format, (void*)0x0013CE95A, 0, 326, y - 1); } y += 21; } @@ -750,7 +748,7 @@ static int window_guest_list_is_peep_in_filter(rct_peep* peep) temp = _window_guest_list_selected_view; _window_guest_list_selected_view = _window_guest_list_selected_filter; - esi = peep; + esi = (int)peep; RCT2_CALLFUNC_X(0x0069B7EA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ebx &= 0xFFFF; @@ -798,6 +796,8 @@ static int sub_69B7EA(rct_peep *peep, int *outEAX) *outEAX = 0; return 0; } + + return 0; } /** @@ -934,26 +934,27 @@ static void window_guest_list_find_groups() static int get_guest_face_sprite_small(rct_peep *peep) { int sprite; - sprite = 0x157A; + sprite = SPR_PEEP_SMALL_FACE_ANGRY; if (peep->var_F3) return sprite; + sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK; - sprite = 0x1579; if (peep->nausea > 200) return sprite; - sprite--; + sprite--; //VERY_SICK if (peep->nausea > 170) return sprite; - sprite--; + sprite--; //SICK if (peep->nausea > 140) return sprite; - sprite = 0x1576; + sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED; if (peep->energy < 46) return sprite; - sprite--; + sprite--; //TIRED if (peep->energy < 70) return sprite; - sprite = 0x156E; + sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; + //There are 7 different happiness based faces for (int i = 37; peep->happiness >= i; i += 37) { sprite++; @@ -968,26 +969,27 @@ static int get_guest_face_sprite_small(rct_peep *peep) */ static int get_guest_face_sprite_large(rct_peep* peep){ int sprite; - sprite = 5314; + sprite = SPR_PEEP_LARGE_FACE_ANGRY; if (peep->var_F3) return sprite; + sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK; - sprite = 5298; if (peep->nausea > 200) return sprite; - sprite = 0x14AE; + sprite = SPR_PEEP_LARGE_FACE_VERY_SICK; if (peep->nausea > 170) return sprite; - sprite = 0x14AD; + sprite = SPR_PEEP_LARGE_FACE_SICK; if (peep->nausea > 140) return sprite; - sprite = 0x14AC; + sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED; if (peep->energy < 46) return sprite; - sprite--; + sprite--; //TIRED if (peep->energy < 70) return sprite; - sprite = 0x14A4; + sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY; + //There are 7 different happiness based faces for (int i = 37; peep->happiness >= i; i += 37) { sprite++; diff --git a/src/window_land.c b/src/window_land.c index ca9b9ea295..2a2c90e7b5 100644 --- a/src/window_land.c +++ b/src/window_land.c @@ -58,7 +58,7 @@ static void window_land_update(); static void window_land_invalidate(); static void window_land_paint(); -static uint32 window_land_events[] = { +static void* window_land_events[] = { window_land_close, window_land_mouseup, window_land_emptysub, @@ -122,7 +122,7 @@ void window_land_open() if (window_find_by_id(WC_LAND, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 126, window_land_events, WC_LAND, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 98, 29, 98, 126, (uint32*)window_land_events, WC_LAND, 0); window->widgets = window_land_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -277,7 +277,7 @@ static void window_land_dropdown() type = (dropdownIndex == -1) ? _selectedFloorTexture : - gDropdownItemsArgs[dropdownIndex] - SPR_FLOOR_TEXTURE_GRASS; + *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - SPR_FLOOR_TEXTURE_GRASS; if (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) == type) { RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_SURFACE, uint8) = 255; @@ -293,7 +293,7 @@ static void window_land_dropdown() type = (dropdownIndex == -1) ? _selectedWallTexture : - gDropdownItemsArgs[dropdownIndex] - SPR_WALL_TEXTURE_ROCK; + *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - SPR_WALL_TEXTURE_ROCK; if (RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) == type) { RCT2_GLOBAL(RCT2_ADDRESS_SELECTED_TERRAIN_EDGE, uint8) = 255; @@ -368,19 +368,19 @@ static void window_land_paint() RCT2_GLOBAL(0x009BC678, char) = FORMAT_COMMA16; RCT2_GLOBAL(0x009BC679, char) = 0; RCT2_GLOBAL(0x013CE952, sint16) = RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16); - gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 3165, x, y - 2, 0, (void*)0x013CE952); } y = w->y + window_land_widgets[WIDX_PREVIEW].bottom + 5; // Draw raise cost amount if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_RAISE_COST, uint32) != 0) - gfx_draw_string_centred(dpi, 984, x, y, 0, RCT2_ADDRESS_LAND_RAISE_COST); + gfx_draw_string_centred(dpi, 984, x, y, 0, (void*)RCT2_ADDRESS_LAND_RAISE_COST); y += 10; // Draw lower cost amount if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0x80000000 && RCT2_GLOBAL(RCT2_ADDRESS_LAND_LOWER_COST, uint32) != 0) - gfx_draw_string_centred(dpi, 985, x, y, 0, RCT2_ADDRESS_LAND_LOWER_COST); + gfx_draw_string_centred(dpi, 985, x, y, 0, (void*)RCT2_ADDRESS_LAND_LOWER_COST); y += 50; // Draw paint price @@ -393,7 +393,7 @@ static void window_land_paint() if (price != 0 && !(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY)) { RCT2_GLOBAL(0x013CE952, sint32) = price; - gfx_draw_string_centred(dpi, 986, x, y, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 986, x, y, 0, (void*)0x013CE952); } } diff --git a/src/window_main.c b/src/window_main.c index 2c95d7cbc8..314fe51d94 100644 --- a/src/window_main.c +++ b/src/window_main.c @@ -34,14 +34,14 @@ rct_widget window_main_widgets[] = { void window_main_open() { rct_window* window; - rct_widget* main_widgets = 0x009A9414; + rct_widget* main_widgets = (rct_widget*)0x009A9414; main_widgets[0].right = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16); main_widgets[0].bottom = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16); window = window_create( 0, 0, window_main_widgets[0].right, window_main_widgets[0].bottom, - 0x0097C0BC, + (uint32*)0x0097C0BC, WC_MAIN_WINDOW, WF_STICK_TO_BACK ); diff --git a/src/window_news.c b/src/window_news.c index 1e849ce080..4fa036bae0 100644 --- a/src/window_news.c +++ b/src/window_news.c @@ -52,7 +52,7 @@ static void window_news_tooltip(); static void window_news_paint(); static void window_news_scrollpaint(); -static uint32 window_news_events[] = { +static void* window_news_events[] = { window_news_emptysub, window_news_mouseup, window_news_emptysub, @@ -89,7 +89,6 @@ static uint32 window_news_events[] = { */ void window_news_open() { - int x, y; rct_window* window; // Check if window is already open @@ -98,7 +97,7 @@ void window_news_open() window = window_create_auto_pos( 400, 300, - window_news_events, + (uint32*)window_news_events, WC_RECENT_NEWS, 0 ); @@ -127,7 +126,6 @@ void window_news_open() */ static void window_news_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -276,7 +274,6 @@ static void window_news_tooltip() */ static void window_news_paint() { - int x, y; rct_window *w; rct_drawpixelinfo *dpi; @@ -318,12 +315,12 @@ static void window_news_scrollpaint() // Date text RCT2_GLOBAL(0x013CE952, uint16) = STR_DATE_DAY_1 + newsItem->day - 1; - RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month % 8); - gfx_draw_string_left(dpi, 2235, 0x013CE952, 2, 4, y); + RCT2_GLOBAL(0x013CE952 + 2, uint16) = STR_MONTH_MARCH + (newsItem->month_year % 8); + gfx_draw_string_left(dpi, 2235, (void*)0x013CE952, 2, 4, y); // Item text RCT2_GLOBAL(0x009B5F2C, uint8) = newsItem->colour; - strcpy(0x009B5F2D, newsItem->text); + strcpy((char*)0x009B5F2D, newsItem->text); gfx_draw_string_left_wrapped(dpi, 0, 2, y + 10, 325, 1926, 14); // Subject button diff --git a/src/window_options.c b/src/window_options.c index a9f81e2eeb..87ddb27245 100644 --- a/src/window_options.c +++ b/src/window_options.c @@ -19,7 +19,11 @@ *****************************************************************************/ #include "addresses.h" +#include "audio.h" +#include "config.h" +#include "gfx.h" #include "strings.h" +#include "viewport.h" #include "widget.h" #include "window.h" #include "window_dropdown.h" @@ -103,8 +107,10 @@ static void window_options_mousedown(); static void window_options_dropdown(); static void window_options_update(); static void window_options_paint(); +static void window_options_draw_dropdown_box(w, widget, num_items); +static void window_options_update_height_markers(); -static uint32 window_options_events[] = { +static void* window_options_events[] = { window_options_emptysub, window_options_mouseup, window_options_emptysub, @@ -148,7 +154,7 @@ void window_options_open() if (w != NULL) return; - w = window_create_auto_pos(310, 372, window_options_events, WC_OPTIONS, 0); + w = window_create_auto_pos(310, 372, (uint32*)window_options_events, WC_OPTIONS, 0); w->widgets = window_options_widgets; w->enabled_widgets = (1 << WIDX_CLOSE) | @@ -190,7 +196,59 @@ void window_options_open() */ static void window_options_mouseup() { - RCT2_CALLPROC_EBPSAFE(0x006BAFCA); + short widgetIndex; + rct_window *w; + + __asm mov widgetIndex, dx + __asm mov w, esi + + switch (widgetIndex) { + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_HOTKEY_DROPDOWN: + RCT2_CALLPROC_EBPSAFE(0x006E3884); + break; + case WIDX_SCREEN_EDGE_SCROLLING: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) ^= 1; + config_save(); + window_invalidate(w); + break; + case WIDX_REAL_NAME_CHECKBOX: + RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) ^= PARK_FLAGS_SHOW_REAL_GUEST_NAMES; + + if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_SHOW_REAL_GUEST_NAMES) + __asm xor al, al + else + __asm mov al, 1 + + RCT2_CALLPROC_EBPSAFE(0x0069C52F); + break; + case WIDX_TILE_SMOOTHING_CHECKBOX: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) ^= CONFIG_FLAG_DISABLE_SMOOTH_LANDSCAPE; + config_save(); + gfx_invalidate_screen(); + break; + case WIDX_GRIDLINES_CHECKBOX: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) ^= CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES; + config_save(); + gfx_invalidate_screen(); + + if ((w = window_get_main()) != NULL) { + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) + w->viewport->flags |= VIEWPORT_FLAG_GRIDLINES; + else + w->viewport->flags &= ~VIEWPORT_FLAG_GRIDLINES; + } + break; + case WIDX_SOUND_SW_BUFFER_CHECKBOX: + pause_sounds(); + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint8) ^= 1; + config_save(); + unpause_sounds(); + window_invalidate(w); + break; + } } /** @@ -199,8 +257,7 @@ static void window_options_mouseup() */ static void window_options_mousedown() { - //RCT2_CALLPROC_EBPSAFE(0x006BB01B); - int numItems, i; + int num_items, i; sint64 device; short widgetIndex; rct_window *w; @@ -213,24 +270,16 @@ static void window_options_mousedown() switch (widgetIndex) { case WIDX_SOUND_DROPDOWN: - numItems = RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32); - if (numItems == 0) + num_items = RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32); + if (num_items == 0) break; - window_dropdown_show_text_custom_width( - w->x + widget->left, - w->y + widget->top, - widget->bottom - widget->top + 1, - w->colours[1], - 0x80, - numItems, - widget->right - widget->left - 3 - ); + window_options_draw_dropdown_box(w, widget, num_items); // populate the list with the sound devices device = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, sint32) + 0x10; - for (i = 0; i < numItems; i++) { + for (i = 0; i < num_items; i++) { gDropdownItemsFormat[i] = 1142; gDropdownItemsArgs[i] = 1170 | (device << 16); device += 0x210; @@ -239,28 +288,85 @@ static void window_options_mousedown() break; case WIDX_HEIGHT_LABELS_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB517); + window_options_draw_dropdown_box(w, widget, 2); + + gDropdownItemsFormat[0] = 1142; + gDropdownItemsFormat[1] = 1142; + gDropdownItemsArgs[0] = STR_UNITS; + gDropdownItemsArgs[1] = STR_REAL_VALUES; + + gDropdownItemsChecked = + (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & + CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS) ? 1 : 2; + break; case WIDX_MUSIC_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB5A8); + window_options_draw_dropdown_box(w, widget, 2); + + gDropdownItemsFormat[0] = 1142; + gDropdownItemsFormat[1] = 1142; + gDropdownItemsArgs[0] = STR_OFF; + gDropdownItemsArgs[1] = STR_ON; + + gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8); + break; case WIDX_SOUND_QUALITY_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB631); + num_items = 3; + window_options_draw_dropdown_box(w, widget, num_items); + + for (i = 0; i < num_items; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = STR_SOUND_LOW + i; // low, medium, high + } + gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, uint8); + break; case WIDX_CURRENCY_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB494); + num_items = 10; + window_options_draw_dropdown_box(w, widget, num_items); + + for (i = 0; i < num_items; i++) { + gDropdownItemsFormat[i] = 1142; + gDropdownItemsArgs[i] = STR_POUNDS + i; // all different currencies + } + gDropdownItemsChecked = 1 << (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, uint8) & 0x3F); + break; case WIDX_DISTANCE_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB3E6); + window_options_draw_dropdown_box(w, widget, 2); + + gDropdownItemsFormat[0] = 1142; + gDropdownItemsFormat[1] = 1142; + gDropdownItemsArgs[0] = STR_IMPERIAL; + gDropdownItemsArgs[1] = STR_METRIC; + + gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8); + break; case WIDX_RESOLUTION_DROPDOWN: RCT2_CALLPROC_EBPSAFE(0x006BB2AF); break; case WIDX_TEMPERATURE_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB21F); + window_options_draw_dropdown_box(w, widget, 2); + + gDropdownItemsFormat[0] = 1142; + gDropdownItemsFormat[1] = 1142; + gDropdownItemsArgs[0] = STR_CELSIUS; + gDropdownItemsArgs[1] = STR_FAHRENHEIT; + + gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8); + break; case WIDX_CONSTRUCTION_MARKER_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB18F); + window_options_draw_dropdown_box(w, widget, 2); + + gDropdownItemsFormat[0] = 1142; + gDropdownItemsFormat[1] = 1142; + gDropdownItemsArgs[0] = STR_WHITE; + gDropdownItemsArgs[1] = STR_TRANSLUCENT; + + gDropdownItemsChecked = 1 << RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8); break; } } @@ -271,18 +377,76 @@ static void window_options_mousedown() */ static void window_options_dropdown() { - RCT2_CALLPROC_EBPSAFE(0x006BB076); - /*short widgetIndex; + short dropdownIndex; + short widgetIndex; rct_window *w; + __asm mov dropdownIndex, ax __asm mov widgetIndex, dx __asm mov w, esi + if (dropdownIndex == -1) + return; + switch (widgetIndex) { case WIDX_SOUND_DROPDOWN: - RCT2_CALLPROC_EBPSAFE(0x006BB757); + __asm movzx ax, dropdownIndex // the switch replaces ax value + RCT2_CALLPROC_EBPSAFE(0x006BA9B5); // part of init audio + window_invalidate(w); break; - }*/ + case WIDX_HEIGHT_LABELS_DROPDOWN: + // reset flag and set it to 1 if height as units is selected + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) &= ~CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS; + + if (dropdownIndex == 0) + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS; + + window_options_update_height_markers(); + break; + case WIDX_MUSIC_DROPDOWN: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = (uint8)dropdownIndex; + config_save(); + RCT2_CALLPROC_EBPSAFE(0x006BCA9F); + window_invalidate(w); + break; + case WIDX_SOUND_QUALITY_DROPDOWN: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_QUALITY, uint8) = (uint8)dropdownIndex; + + // TODO: no clue what this does (and if it's correct) + RCT2_GLOBAL(0x009AAC75, uint8) = RCT2_GLOBAL(0x009AF601 + dropdownIndex, uint8); + RCT2_GLOBAL(0x009AAC76, uint8) = RCT2_GLOBAL(0x009AF604 + dropdownIndex, uint8); + + config_save(); + window_invalidate(w); + break; + case WIDX_CURRENCY_DROPDOWN: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CURRENCY, uint8) = dropdownIndex | 0xC0; + config_save(); + gfx_invalidate_screen(); + break; + case WIDX_DISTANCE_DROPDOWN: + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint8) = (uint8)dropdownIndex; + window_options_update_height_markers(); + break; + case WIDX_RESOLUTION_DROPDOWN: + __asm movzx ax, dropdownIndex // the switch replaces ax value + RCT2_CALLPROC_EBPSAFE(0x006BB37D); + break; + case WIDX_TEMPERATURE_DROPDOWN: + if (dropdownIndex != RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8)) { + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_TEMPERATURE, uint8) = (uint8)dropdownIndex; + config_save(); + gfx_invalidate_screen(); + } + break; + case WIDX_CONSTRUCTION_MARKER_DROPDOWN: + if (dropdownIndex != RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8)) { + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_CONSTRUCTION_MARKER, uint8) = (uint8)dropdownIndex; + config_save(); + gfx_invalidate_screen(); + } + break; + } } /** @@ -329,4 +493,31 @@ static void window_options_paint() w->y + window_options_widgets[WIDX_MUSIC].top + 1); gfx_draw_string_left(dpi, STR_SOUND_QUALITY, w, 0, w->x + 10, w->y + window_options_widgets[WIDX_SOUND_QUALITY].top + 1); +} + +// helper function, all dropdown boxes have similar properties +static void window_options_draw_dropdown_box(rct_window *w, rct_widget *widget, int num_items) +{ + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + 0x80, + num_items, + widget->right - widget->left - 3 + ); +} + +static void window_options_update_height_markers() +{ + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_SHOW_HEIGHT_AS_UNITS) { + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = 0; + } else { // use real values (metric or imperial) + RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_HEIGHT_MARKERS, uint16) = + (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_METRIC, uint16) + 1) * 256; + } + + config_save(); + gfx_invalidate_screen(); } \ No newline at end of file diff --git a/src/window_park.c b/src/window_park.c index 6e3911f424..d73576d8d0 100644 --- a/src/window_park.c +++ b/src/window_park.c @@ -264,7 +264,7 @@ static void window_park_awards_update(); static void window_park_awards_invalidate(); static void window_park_awards_paint(); -static uint32 window_park_entrance_events[] = { +static void* window_park_entrance_events[] = { window_park_entrance_close, window_park_entrance_mouseup, window_park_entrance_resize, @@ -295,7 +295,7 @@ static uint32 window_park_entrance_events[] = { window_park_emptysub }; -static uint32 window_park_rating_events[] = { +static void* window_park_rating_events[] = { window_park_emptysub, window_park_rating_mouseup, window_park_rating_resize, @@ -326,7 +326,7 @@ static uint32 window_park_rating_events[] = { window_park_emptysub }; -static uint32 window_park_guests_events[] = { +static void* window_park_guests_events[] = { window_park_emptysub, window_park_guests_mouseup, window_park_guests_resize, @@ -357,7 +357,7 @@ static uint32 window_park_guests_events[] = { window_park_emptysub }; -static uint32 window_park_price_events[] = { +static void* window_park_price_events[] = { window_park_emptysub, window_park_price_mouseup, window_park_price_resize, @@ -388,7 +388,7 @@ static uint32 window_park_price_events[] = { window_park_emptysub }; -static uint32 window_park_stats_events[] = { +static void* window_park_stats_events[] = { window_park_emptysub, window_park_stats_mouseup, window_park_stats_resize, @@ -419,7 +419,7 @@ static uint32 window_park_stats_events[] = { window_park_emptysub }; -static uint32 window_park_objective_events[] = { +static void* window_park_objective_events[] = { window_park_emptysub, window_park_objective_mouseup, window_park_objective_resize, @@ -450,7 +450,7 @@ static uint32 window_park_objective_events[] = { window_park_emptysub }; -static uint32 window_park_awards_events[] = { +static void* window_park_awards_events[] = { window_park_emptysub, window_park_awards_mouseup, window_park_awards_resize, @@ -481,7 +481,7 @@ static uint32 window_park_awards_events[] = { window_park_emptysub }; -static uint32 *window_park_page_events[] = { +static void* window_park_page_events[] = { window_park_entrance_events, window_park_rating_events, window_park_guests_events, @@ -589,7 +589,7 @@ rct_window *window_park_open() { rct_window* w; - w = window_create_auto_pos(230, 174, window_park_entrance_events, WC_PARK_INFORMATION, 0x0400); + w = window_create_auto_pos(230, 174, (uint32*)window_park_entrance_events, WC_PARK_INFORMATION, 0x0400); w->widgets = window_park_entrance_widgets; w->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_ENTRANCE]; w->number = 0; @@ -599,7 +599,7 @@ rct_window *window_park_open() w->var_490 = -1; w->var_48C = -1; w->var_492 = 0; - RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); w->colours[0] = 1; w->colours[1] = 19; w->colours[2] = 19; @@ -628,7 +628,7 @@ void window_park_entrance_open() window_invalidate(window); window->widgets = window_park_entrance_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_ENTRANCE]; - window->event_handlers = window_park_entrance_events; + window->event_handlers = (uint32*)window_park_entrance_events; window->pressed_widgets = 0; window_init_scroll_widgets(window); window_park_init_viewport(window); @@ -675,10 +675,10 @@ static void window_park_entrance_mouseup() window_park_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_BUY_LAND_RIGHTS: - RCT2_CALLPROC_X(0x006682F7, 0, 0, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006682F7, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case WIDX_BUY_CONSTRUCTION_RIGHTS: - RCT2_CALLPROC_X(0x00668393, 0, 0, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x00668393, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case WIDX_LOCATE: window_park_scroll_to_viewport(w); @@ -791,7 +791,7 @@ static void window_park_entrance_toolupdate() { int x, y; short widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, eax __asm mov y, ebx @@ -799,7 +799,7 @@ static void window_park_entrance_toolupdate() __asm mov w, esi if (widgetIndex == WIDX_BUY_LAND_RIGHTS) { - RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xFFFE; screen_pos_to_map_pos(&x, &y); if (x != SPRITE_LOCATION_NULL) { @@ -809,7 +809,7 @@ static void window_park_entrance_toolupdate() RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; - RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); } } } @@ -821,14 +821,14 @@ static void window_park_entrance_toolupdate() static void window_park_entrance_tooldown() { short x, y, widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, ax __asm mov y, bx __asm mov widgetIndex, dx __asm mov w, esi - RCT2_CALLPROC_X(0x006681E6, x, y, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006681E6, x, y, 0, widgetIndex, (int)w, 0, 0); } /** @@ -838,14 +838,14 @@ static void window_park_entrance_tooldown() static void window_park_entrance_tooldrag() { short x, y, widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov x, ax __asm mov y, bx __asm mov widgetIndex, dx __asm mov w, esi - RCT2_CALLPROC_X(0x006681FB, x, y, 0, widgetIndex, w, 0, 0); + RCT2_CALLPROC_X(0x006681FB, x, y, 0, widgetIndex, (int)w, 0, 0); } /** @@ -855,7 +855,7 @@ static void window_park_entrance_tooldrag() static void window_park_entrance_toolabort() { short widgetIndex; - rct_window *w, *mainWindow; + rct_window *w; __asm mov widgetIndex, dx __asm mov w, esi @@ -952,7 +952,6 @@ static void window_park_entrance_invalidate() */ static void window_park_entrance_paint() { - int i, x, y; rct_window *w; rct_drawpixelinfo *dpi; rct_widget *labelWidget; @@ -977,7 +976,7 @@ static void window_park_entrance_paint() gfx_draw_string_centred_clipped( dpi, 1191, - 0x013CE952, + (void*)0x013CE952, 0, w->x + (labelWidget->left + labelWidget->right) / 2, w->y + labelWidget->top, @@ -1025,7 +1024,7 @@ static void window_park_init_viewport(rct_window *w) } // Call invalidate event - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); w->var_482 = x; w->var_484 = y; @@ -1108,7 +1107,7 @@ void window_park_rating_open() window->widgets = window_park_rating_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_RATING]; window->var_020 = 0; - window->event_handlers = window_park_rating_events; + window->event_handlers = (uint32*)window_park_rating_events; window_init_scroll_widgets(window); } @@ -1163,9 +1162,8 @@ static void window_park_rating_update() */ static void window_park_rating_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1207,7 +1205,7 @@ static void window_park_rating_paint() widget = &window_park_rating_widgets[WIDX_PAGE_BACKGROUND]; // Current value - gfx_draw_string_left(dpi, STR_PARK_RATING_LABEL, RCT2_ADDRESS_CURRENT_PARK_RATING, 0, x + widget->left + 3, y + widget->top + 2); + gfx_draw_string_left(dpi, STR_PARK_RATING_LABEL, (void*)RCT2_ADDRESS_CURRENT_PARK_RATING, 0, x + widget->left + 3, y + widget->top + 2); // Graph border gfx_fill_rect_inset(dpi, x + widget->left + 4, y + widget->top + 15, x + widget->right - 4, y + widget->bottom - 4, w->colours[1], 0x30); @@ -1251,7 +1249,7 @@ void window_park_guests_open() window->widgets = window_park_guests_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_GUESTS]; window->var_020 = 0; - window->event_handlers = window_park_guests_events; + window->event_handlers = (uint32*)window_park_guests_events; window_init_scroll_widgets(window); } @@ -1307,9 +1305,8 @@ static void window_park_guests_update() */ static void window_park_guests_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1351,7 +1348,7 @@ static void window_park_guests_paint() widget = &window_park_guests_widgets[WIDX_PAGE_BACKGROUND]; // Current value - gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, RCT2_ADDRESS_GUESTS_IN_PARK, 0, x + widget->left + 3, y + widget->top + 2); + gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, (void*)RCT2_ADDRESS_GUESTS_IN_PARK, 0, x + widget->left + 3, y + widget->top + 2); // Graph border gfx_fill_rect_inset(dpi, x + widget->left + 4, y + widget->top + 15, x + widget->right - 4, y + widget->bottom - 4, w->colours[1], 0x30); @@ -1458,9 +1455,8 @@ static void window_park_price_update() */ static void window_park_price_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1511,9 +1507,9 @@ static void window_park_price_paint() x = w->x + window_park_price_widgets[WIDX_PAGE_BACKGROUND].left + 4; y = w->y + window_park_price_widgets[WIDX_PAGE_BACKGROUND].top + 30; - gfx_draw_string_left(dpi, STR_TOTAL_ADMISSIONS, RCT2_ADDRESS_TOTAL_ADMISSIONS, 0, x, y); + gfx_draw_string_left(dpi, STR_TOTAL_ADMISSIONS, (void*)RCT2_ADDRESS_TOTAL_ADMISSIONS, 0, x, y); y += 10; - gfx_draw_string_left(dpi, STR_INCOME_FROM_ADMISSIONS, RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, 0, x, y); + gfx_draw_string_left(dpi, STR_INCOME_FROM_ADMISSIONS, (void*)RCT2_ADDRESS_INCOME_FROM_ADMISSIONS, 0, x, y); } #pragma endregion @@ -1586,9 +1582,8 @@ static void window_park_stats_update() */ static void window_park_stats_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1616,7 +1611,6 @@ static void window_park_stats_paint() int x, y, parkSize, stringIndex; rct_window *w; rct_drawpixelinfo *dpi; - rct_award *award; __asm mov w, esi __asm mov dpi, edi @@ -1635,25 +1629,25 @@ static void window_park_stats_paint() parkSize = squaredmetres_to_squaredfeet(parkSize); } RCT2_GLOBAL(0x013CE952, uint32) = parkSize; - gfx_draw_string_left(dpi, stringIndex, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, stringIndex, (void*)0x013CE952, 0, x, y); y += 10; // Draw number of rides / attractions if (w->var_490 != -1) { RCT2_GLOBAL(0x013CE952, uint32) = w->var_490; - gfx_draw_string_left(dpi, STR_NUMBER_OF_RIDES_LABEL, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, STR_NUMBER_OF_RIDES_LABEL, (void*)0x013CE952, 0, x, y); } y += 10; // Draw number of staff if (w->var_48C != -1) { RCT2_GLOBAL(0x013CE952, uint32) = w->var_48C; - gfx_draw_string_left(dpi, STR_STAFF_LABEL, 0x013CE952, 0, x, y); + gfx_draw_string_left(dpi, STR_STAFF_LABEL, (void*)0x013CE952, 0, x, y); } y += 10; // Draw number of guests in park - gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, RCT2_ADDRESS_GUESTS_IN_PARK, 0, x, y); + gfx_draw_string_left(dpi, STR_GUESTS_IN_PARK_LABEL, (void*)RCT2_ADDRESS_GUESTS_IN_PARK, 0, x, y); } #pragma endregion @@ -1685,7 +1679,7 @@ void window_park_objective_open() window->widgets = window_park_objective_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_OBJECTIVE]; window->var_020 = 0; - window->event_handlers = window_park_objective_events; + window->event_handlers = (uint32*)window_park_objective_events; window_init_scroll_widgets(window); window->x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2 - 115; window->y = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2 - 87; @@ -1698,7 +1692,6 @@ void window_park_objective_open() */ static void window_park_objective_mouseup() { - int tabIndex; short widgetIndex; rct_window *w; @@ -1757,7 +1750,6 @@ static void window_park_objective_update() */ static void window_park_objective_invalidate() { - int i; rct_window *w; __asm mov w, esi @@ -1765,8 +1757,8 @@ static void window_park_objective_invalidate() window_park_set_pressed_tab(w); // Set window title arguments - *((short*)0x013CE952) = RCT2_GLOBAL(0x013573D4, uint16); - *((short*)0x013CE954) = RCT2_GLOBAL(0x013573D8, uint32); + *((uint16*)0x013CE952) = RCT2_GLOBAL(0x013573D4, uint16); + *((uint32*)0x013CE954) = RCT2_GLOBAL(0x013573D8, uint32); // if (RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & 0x02) @@ -1784,7 +1776,7 @@ static void window_park_objective_invalidate() */ static void window_park_objective_paint() { - int i, x, y; + int x, y; rct_window *w; rct_drawpixelinfo *dpi; @@ -1798,7 +1790,7 @@ static void window_park_objective_paint() x = w->x + window_park_objective_widgets[WIDX_PAGE_BACKGROUND].left + 4; y = w->y + window_park_objective_widgets[WIDX_PAGE_BACKGROUND].top + 7; strcpy((char*)0x009BC677, RCT2_ADDRESS(RCT2_ADDRESS_SCENARIO_DETAILS, char)); - *((short*)0x013CE952) = 3165; + RCT2_GLOBAL(0x013CE952, short) = 3165; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 222, 1191, 0); y += 5; @@ -1807,9 +1799,9 @@ static void window_park_objective_paint() y += 10; // Objective - *((short*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16); - *((short*)0x013CE954) = date_get_total_months(MONTH_OCTOBER, RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8)); - *((int*)0x013CE956) = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32); + RCT2_GLOBAL(0x013CE952, short) = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_NUM_GUESTS, uint16); + RCT2_GLOBAL(0x013CE954, short) = date_get_total_months(MONTH_OCTOBER, RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_YEAR, uint8)); + RCT2_GLOBAL(0x013CE956, int) = RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_CURRENCY, sint32); gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 221, 2385 + RCT2_GLOBAL(RCT2_ADDRESS_OBJECTIVE_TYPE, uint8), 0); y += 5; @@ -1821,7 +1813,7 @@ static void window_park_objective_paint() gfx_draw_string_left_wrapped(dpi, NULL, x, y, 222, 2789, 0); } else { // Objective completed - *((int*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); + RCT2_GLOBAL(0x013CE952, int) = RCT2_GLOBAL(RCT2_ADDRESS_COMPLETED_COMPANY_VALUE, uint32); gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 222, 2788, 0); } } @@ -1856,7 +1848,7 @@ void window_park_awards_open() window->widgets = window_park_awards_widgets; window->enabled_widgets = window_park_page_enabled_widgets[WINDOW_PARK_PAGE_AWARDS]; window->var_020 = 0; - window->event_handlers = window_park_awards_events; + window->event_handlers = (uint32*)window_park_awards_events; window_init_scroll_widgets(window); } @@ -1911,9 +1903,8 @@ static void window_park_awards_update() */ static void window_park_awards_invalidate() { - int i; rct_window *w; - rct_widget **widgets; + rct_widget *widgets; __asm mov w, esi @@ -1959,7 +1950,7 @@ static void window_park_awards_paint() continue; gfx_draw_sprite(dpi, SPR_AWARD_MOST_UNTIDY + award->type, x, y); - gfx_draw_string_left_wrapped(dpi, STR_AWARD_MOST_UNTIDY, x + 34, y + 6, 180, 0, 0); + gfx_draw_string_left_wrapped(dpi, (void*)STR_AWARD_MOST_UNTIDY, x + 34, y + 6, 180, 0, 0); y += 32; count++; @@ -2002,11 +1993,11 @@ 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, w, 0, 0); + RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, (int)w, 0, 0); window_invalidate(w); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); if (listen != 0 && w->viewport != NULL) w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON; } @@ -2029,7 +2020,7 @@ static void window_park_align_tabs(rct_window *w) 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 & (1 << (WIDX_TAB_1 + 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; @@ -2042,7 +2033,7 @@ static void window_park_set_pressed_tab(rct_window *w) int i; for (i = 0; i < 7; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); } static void window_park_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w) @@ -2125,7 +2116,7 @@ static void window_park_graph_draw_months(rct_drawpixelinfo *dpi, uint8 *history if (history[i] != 0 && history[i] != 255 && yearOver32 % 4 == 0) { // Draw month text RCT2_GLOBAL(0x013CE952, uint32) = ((yearOver32 / 4) + 8) % 8 + STR_MONTH_SHORT_MAR; - gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, 0x013CE952); + gfx_draw_string_centred(dpi, 2222, x, y - 10, 0, (void*)0x013CE952); // Draw month mark gfx_fill_rect(dpi, x, y, x, y + 3, 10); diff --git a/src/window_ride_list.c b/src/window_ride_list.c index 390261673b..f7e877ef3d 100644 --- a/src/window_ride_list.c +++ b/src/window_ride_list.c @@ -79,7 +79,7 @@ static void window_ride_list_invalidate(); static void window_ride_list_paint(); static void window_ride_list_scrollpaint(); -static uint32 window_ride_list_events[] = { +static void* window_ride_list_events[] = { window_ride_list_emptysub, window_ride_list_mouseup, window_ride_list_resize, @@ -140,7 +140,7 @@ void window_ride_list_open() // Check if window is already open window = window_bring_to_front_by_id(WC_RIDE_LIST, 0); if (window == NULL) { - window = window_create_auto_pos(340, 240, window_ride_list_events, WC_RIDE_LIST, 0x0400); + window = window_create_auto_pos(340, 240, (uint32*)window_ride_list_events, WC_RIDE_LIST, 0x0400); window->widgets = window_ride_list_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | @@ -175,7 +175,6 @@ void window_ride_list_open() */ static void window_ride_list_mouseup() { - int i; short widgetIndex; rct_window *w; @@ -273,10 +272,8 @@ static void window_ride_list_mousedown() */ static void window_ride_list_dropdown() { - int i; short dropdownIndex, widgetIndex; rct_window *w; - rct_ride *ride; __asm mov dropdownIndex, ax __asm mov widgetIndex, dx @@ -291,7 +288,7 @@ static void window_ride_list_dropdown() if (dropdownIndex == -1) return; - _window_ride_list_information_type = gDropdownItemsArgs[dropdownIndex] - STR_STATUS; + _window_ride_list_information_type = *((uint32*)&gDropdownItemsArgs[dropdownIndex]) - STR_STATUS; window_invalidate(w); } } @@ -398,7 +395,7 @@ static void window_ride_list_tooltip() */ static void window_ride_list_invalidate() { - int i, x, y; + int i; rct_window *w; __asm mov w, esi @@ -408,7 +405,7 @@ static void window_ride_list_invalidate() // Set correct active tab for (i = 0; i < 3; i++) w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); - w->pressed_widgets |= 1 << (WIDX_TAB_1 + w->page); + w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); window_ride_list_widgets[WIDX_TITLE].image = STR_RIDES + w->page; @@ -554,7 +551,7 @@ static void window_ride_list_scrollpaint() format = 1192; RCT2_GLOBAL(0x013CE952, uint16) = formatSecondary; - gfx_draw_string_left_clipped(dpi, format, 0x013CE952, 0, 160, y - 1, 157); + gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 160, y - 1, 157); y += 10; } } @@ -593,7 +590,7 @@ static void window_ride_list_draw_tab_images(rct_drawpixelinfo *dpi, rct_window static void window_ride_list_refresh_list(rct_window *w) { int i, j, k, countA, countB; - sint16 swapper; + uint8 swapper; rct_ride *ride, *otherRide; countA = countB = 0; @@ -636,7 +633,7 @@ static void window_ride_list_refresh_list(rct_window *w) otherRide = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[w->var_076[k]]); RCT2_GLOBAL(0x013CE952, uint32) = otherRide->var_04C; RCT2_CALLPROC_X(0x006C2538, otherRide->var_04A, 0, 0x013CE952, 0, 0, 0x0141EF68, 0); - if (strcmp(0x0141ED68, 0x0141EF68) >= 0) + if (strcmp((char*)0x0141ED68, (char*)0x0141EF68) >= 0) break; swapper = w->var_076[k]; diff --git a/src/window_save_prompt.c b/src/window_save_prompt.c index 3978cc1154..a0a06597fd 100644 --- a/src/window_save_prompt.c +++ b/src/window_save_prompt.c @@ -54,7 +54,7 @@ static void window_save_prompt_close(); static void window_save_prompt_mouseup(); static void window_save_prompt_paint(); -static uint32 window_save_prompt_events[] = { +static void* window_save_prompt_events[] = { window_save_prompt_close, window_save_prompt_mouseup, window_save_prompt_emptysub, @@ -102,7 +102,7 @@ void window_save_prompt_open() max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 25), 260, 50, - window_save_prompt_events, + (uint32*)window_save_prompt_events, WC_SAVE_PROMPT, 0 ); diff --git a/src/window_title_exit.c b/src/window_title_exit.c index 1eaa52b6a8..780e4cf3b4 100644 --- a/src/window_title_exit.c +++ b/src/window_title_exit.c @@ -34,7 +34,7 @@ static void window_title_exit_emptysub() {} static void window_title_exit_paint(); static void window_title_exit_mouseup(); -static uint32 window_title_exit_events[] = { +static void* window_title_exit_events[] = { window_title_exit_emptysub, window_title_exit_mouseup, window_title_exit_emptysub, @@ -76,7 +76,7 @@ void window_title_exit_open() window = window_create( RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 40, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 64, 40, 64, - window_title_exit_events, + (uint32*)window_title_exit_events, WC_TITLE_EXIT, WF_STICK_TO_FRONT ); diff --git a/src/window_title_logo.c b/src/window_title_logo.c index a81ec804b1..f30a66cea4 100644 --- a/src/window_title_logo.c +++ b/src/window_title_logo.c @@ -32,7 +32,7 @@ static rct_widget window_title_logo_widgets[] = { static void window_title_logo_emptysub() {} static void window_title_logo_paint(); -static uint32 window_title_logo_events[] = { +static void* window_title_logo_events[] = { window_title_logo_emptysub, window_title_logo_emptysub, window_title_logo_emptysub, @@ -79,8 +79,8 @@ void window_title_logo_open() packs++; // Create the window - window = window_create(0, 0, 200, 106 + (10 * packs), window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_FRONT); - window->widgets = 0x009A9658; // mouse move bug in original game, keep this address and no crash happens + window = window_create(0, 0, 200, 106 + (10 * packs), (uint32*)window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_FRONT); + window->widgets = (rct_widget*)0x009A9658; // mouse move bug in original game, keep this address and no crash happens window_init_scroll_widgets(window); window->flags |= 16; window->colours[0] = 129; diff --git a/src/window_title_menu.c b/src/window_title_menu.c index f34c875127..e139ce8397 100644 --- a/src/window_title_menu.c +++ b/src/window_title_menu.c @@ -50,7 +50,7 @@ static void window_title_menu_dropdown(); static void window_title_menu_unknown17(); static void window_title_menu_paint(); -static uint32 window_title_menu_events[] = { +static void* window_title_menu_events[] = { window_title_menu_emptysub, window_title_menu_mouseup, window_title_menu_emptysub, @@ -92,7 +92,7 @@ void window_title_menu_open() window = window_create( (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 328) / 2, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 142, 328, 82, - window_title_menu_events, + (uint32*)window_title_menu_events, WC_TITLE_MENU, WF_STICK_TO_FRONT ); diff --git a/src/window_title_scenarioselect.c b/src/window_title_scenarioselect.c index 00556c1ee2..5d0be5bba5 100644 --- a/src/window_title_scenarioselect.c +++ b/src/window_title_scenarioselect.c @@ -66,7 +66,7 @@ static void window_scenarioselect_invalidate(); static void window_scenarioselect_paint(); static void window_scenarioselect_scrollpaint(); -static uint32 window_scenarioselect_events[] = { +static void* window_scenarioselect_events[] = { window_scenarioselect_emptysub, window_scenarioselect_mouseup, window_scenarioselect_emptysub, @@ -116,7 +116,7 @@ void window_scenarioselect_open() max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 167), 610, 334, - window_scenarioselect_events, + (uint32*)window_scenarioselect_events, WC_SCENARIO_SELECT, WF_STICK_TO_FRONT | WF_10 ); @@ -128,7 +128,7 @@ void window_scenarioselect_open() window->colours[1] = 26; window->colours[2] = 26; window->var_480 = -1; - window->var_494 = NULL; + window->var_494 = 0; window_scenarioselect_init_tabs(); @@ -189,10 +189,10 @@ static void window_scenarioselect_mousedown() if (widgetIndex >= WIDX_TAB1 && widgetIndex <= WIDX_TAB5) { w->var_4AC = widgetIndex - 4; - w->var_494 = NULL; + w->var_494 = 0; window_invalidate(w); - RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0); - RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0); + RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); window_init_scroll_widgets(w); window_invalidate(w); } @@ -273,8 +273,8 @@ static void window_scenarioselect_scrollmouseover() selected = scenario; break; } - if (w->var_494 != selected) { - w->var_494 = selected; + if (w->var_494 != (uint32)selected) { + w->var_494 = (uint32)selected; window_invalidate(w); } } @@ -286,7 +286,7 @@ static void window_scenarioselect_invalidate() __asm mov w, esi w->pressed_widgets &= ~(0x10 | 0x20 | 0x40 | 0x80 | 0x100); - w->pressed_widgets |= 1 << (w->var_4AC + 4); + w->pressed_widgets |= 1LL << (w->var_4AC + 4); } static void window_scenarioselect_paint() @@ -310,7 +310,7 @@ static void window_scenarioselect_paint() x = (widget->left + widget->right) / 2 + w->x; y = (widget->top + widget->bottom) / 2 + w->y - 3; - *((short*)(0x0013CE952 + 0)) = STR_BEGINNER_PARKS + i; + RCT2_GLOBAL(0x013CE952 + 0, short) = STR_BEGINNER_PARKS + i; gfx_draw_string_centred_wrapped(dpi, (void*)0x013CE952, x, y, 87, 1193, 10); } @@ -326,28 +326,28 @@ static void window_scenarioselect_paint() // Scenario name x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4; y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5; - strcpy(0x009BC677, scenario->name); - *((short*)(0x0013CE952 + 0)) = 3165; + strcpy((char*)0x009BC677, scenario->name); + RCT2_GLOBAL(0x013CE952 + 0, short) = 3165; gfx_draw_string_centred_clipped(dpi, 1193, (void*)0x013CE952, 0, x + 85, y, 170); y += 15; // Scenario details - strcpy(0x009BC677, scenario->details); - *((short*)(0x0013CE952 + 0)) = 3165; + strcpy((char*)0x009BC677, scenario->details); + RCT2_GLOBAL(0x013CE952 + 0, short) = 3165; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 170, 1191, 0) + 5; // Scenario objective - *((short*)(0x0013CE952 + 0)) = scenario->objective_type + STR_OBJECTIVE_NONE; - *((short*)(0x0013CE952 + 2)) = scenario->objective_arg_3; - *((short*)(0x0013CE952 + 4)) = date_get_total_months(MONTH_OCTOBER, scenario->objective_arg_1); - *((int*)(0x0013CE952 + 6)) = scenario->objective_arg_2; + RCT2_GLOBAL(0x013CE952 + 0, short) = scenario->objective_type + STR_OBJECTIVE_NONE; + RCT2_GLOBAL(0x013CE952 + 2, short) = scenario->objective_arg_3; + RCT2_GLOBAL(0x013CE952 + 4, short) = date_get_total_months(MONTH_OCTOBER, scenario->objective_arg_1); + RCT2_GLOBAL(0x013CE952 + 6, int) = scenario->objective_arg_2; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 170, STR_OBJECTIVE, 0) + 5; // Scenario score if (scenario->flags & SCENARIO_FLAGS_COMPLETED) { - strcpy(0x009BC677, scenario->completed_by); - *((short*)(0x0013CE952 + 0)) = 3165; - *((int*)(0x0013CE952 + 2)) = scenario->company_value; + strcpy((char*)0x009BC677, scenario->completed_by); + RCT2_GLOBAL(0x013CE952 + 0, short) = 3165; + RCT2_GLOBAL(0x013CE952 + 2, int) = scenario->company_value; y += gfx_draw_string_left_wrapped(dpi, (void*)0x013CE952, x, y, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, 0); } } @@ -385,7 +385,7 @@ static void window_scenarioselect_scrollpaint() // Draw scenario name strcpy((char*)0x009BC677, scenario->name); - *((short*)0x013CE952) = 3165; + RCT2_GLOBAL(0x013CE952, short) = 3165; gfx_draw_string_centred(dpi, highlighted ? 1193 : 1191, 210, y + 1, 0, (void*)0x013CE952); // Check if scenario is completed @@ -395,8 +395,8 @@ static void window_scenarioselect_scrollpaint() // Draw completion score strcpy((char*)0x009BC677, scenario->completed_by); - *((short*)0x013CE952) = 2793; - *((short*)0x013CE954) = 3165; + RCT2_GLOBAL(0x013CE952, short) = 2793; + RCT2_GLOBAL(0x013CE954, short) = 3165; gfx_draw_string_centred(dpi, highlighted ? 1193 : 1191, 210, y + 11, 0, (void*)0x013CE952); } diff --git a/src/window_tooltip.c b/src/window_tooltip.c index bc13d6fbd1..95312aea2f 100644 --- a/src/window_tooltip.c +++ b/src/window_tooltip.c @@ -38,7 +38,7 @@ static void window_tooltip_onclose(); static void window_tooltip_update(); static void window_tooltip_paint(); -static uint32 window_tooltip_events[] = { +static void* window_tooltip_events[] = { window_tooltip_onclose, window_tooltip_emptysub, window_tooltip_emptysub, @@ -93,7 +93,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y return; widget = &widgetWindow->widgets[widgetIndex]; - RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, widgetWindow, 0, 0); + RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)widgetWindow, 0, 0); if (widget->tooltip == 0xFFFF) return; @@ -103,7 +103,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y int eax, ebx, ecx, edx, esi, edi, ebp; eax = widgetIndex; - esi = widgetWindow; + esi = (int)widgetWindow; RCT2_CALLFUNC_X(widgetWindow->event_handlers[WE_TOOLTIP], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if ((eax & 0xFFFF) == 0xFFFF) return; @@ -114,7 +114,7 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y RCT2_GLOBAL(0x0142006C, sint32) = -1; - format_string(0x0141ED68, widget->tooltip, 0x013CE952); + format_string((char*)0x0141ED68, widget->tooltip, (void*)0x013CE952); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; esi = 0x0141ED68; @@ -136,12 +136,12 @@ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; - memcpy(0x0141FE44, 0x0141ED68, 512); + memcpy((void*)0x0141FE44, (void*)0x0141ED68, 512); x = clamp(0, x - (width / 2), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) - width); y = clamp(22, y + 26, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - height - 40); - w = window_create(x, y, width, height, window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); + w = window_create(x, y, width, height, (uint32*)window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT); w->widgets = window_tooltip_widgets; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) = 0; @@ -213,5 +213,5 @@ static void window_tooltip_paint() gfx_draw_pixel(dpi, right - 1, bottom - 1, 0x0200002F); // Text - RCT2_CALLPROC_X(0x006C1DB7, 0, 0, w->x + ((w->width + 1) / 2) - 1, w->y + 1, 0x0141FE44, dpi, RCT2_GLOBAL(0x01420044, uint16)); + RCT2_CALLPROC_X(0x006C1DB7, 0, 0, w->x + ((w->width + 1) / 2) - 1, w->y + 1, 0x0141FE44, (int)dpi, RCT2_GLOBAL(0x01420044, uint16)); } \ No newline at end of file diff --git a/src/window_water.c b/src/window_water.c index 1e91cbf5b5..0c22ddabae 100644 --- a/src/window_water.c +++ b/src/window_water.c @@ -53,7 +53,7 @@ static void window_water_update(); static void window_water_invalidate(); static void window_water_paint(); -static uint32 window_water_events[] = { +static void* window_water_events[] = { window_water_close, window_water_mouseup, window_water_emptysub, @@ -96,7 +96,7 @@ void window_water_open() if (window_find_by_id(WC_WATER, 0) != NULL) return; - window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, window_water_events, WC_WATER, 0); + window = window_create(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 76, 29, 76, 77, (uint32*)window_water_events, WC_WATER, 0); window->widgets = window_water_widgets; window->enabled_widgets = 0x04 | 0x10 | 0x20; window_init_scroll_widgets(window);