/* rct2: 0x6ba50c */ static void window_banner_textinput() { short widgetIndex; rct_window *w; uint8 result; uint8* text; window_text_input_get_registers(w, widgetIndex, result, text); if (widgetIndex == WIDX_BANNER_TEXT && result) { rct_banner* banner = &gBanners[w->number]; uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8); text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START; strncpy(text_buffer + 1, text, 32); int string_id = 0, ebx = 0, ecx = 128, edx = 0, ebp = 0, esi = 0; RCT2_CALLFUNC_X(0x6C421D, &string_id, &ebx, &ecx, &edx, &esi, (int*)&text_buffer, &ebp); if (string_id){ rct_string_id prev_string_id = banner->string_idx; banner->string_idx = string_id; // De-allocate previous string id? RCT2_CALLPROC_X(0x6C42AC, prev_string_id, 0, 0, 0, 0, 0, 0); window_invalidate(w); } else{ window_error_open(2984, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id)); } } }
/** * * rct2: 0x006677F2 * * @param cost (ebp) */ static int game_check_affordability(int cost) { int eax, ebx, ecx, edx, esi, edi, ebp; ebp = cost; RCT2_CALLFUNC_X(0x0069C62C, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return ebp; }
/** * * rct2: 0x006C2321 * buffer (esi) */ int gfx_get_string_width(char *buffer) { int eax, ebx, ecx, edx, esi, edi, ebp; esi = (int)buffer; RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return ecx & 0xFFFF; }
/** * * rct2: 0x0066C9EA */ static void window_game_top_toolbar_dropdown() { short widgetIndex, dropdownIndex; __asm mov widgetIndex, dx __asm mov dropdownIndex, ax if (widgetIndex == WIDX_FILE_MENU) { switch (dropdownIndex) { case 0: // load game game_do_command(0, 1, 0, 0, 5, 0, 0); break; case 1: // save game tool_cancel(); { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x006750E9, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if (eax == 0) { gfx_invalidate_screen(); break; } char *src = (char*)0x0141EF67; do { src++; } while (*src != '.' && *src != '\0'); strcpy(src, ".SV6"); strcpy(RCT2_ADDRESS_SAVED_GAMES_PATH_2, 0x0141EF68); eax = 0; if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 8) eax |= 1; RCT2_CALLPROC_X(0x006754F5, eax, 0, 0, 0, 0, 0, 0); // check success? game_do_command(0, 1047, 0, -1, 0, 0, 0); gfx_invalidate_screen(); } break; case 3: // about window_about_open(); break; case 4: // options window_options_open(); //RCT2_CALLPROC_EBPSAFE(0x006BAC5B); break; case 5: // screenshot RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, sint8) = 10; break; case 7: // quit game game_do_command(0, 1, 0, 0, 5, 1, 0); break; } } else if (widgetIndex == WIDX_VIEW_MENU) { RCT2_CALLPROC_X(0x0066CF8A, dropdownIndex, 0, 0, 0, 0, 0, 0); } }
int viewport_interaction_left_over(int x, int y) { int eax = x, ebx = y, ecx = 0, edx = 0, esi = 0, edi = 0, ebp = 0; RCT2_CALLFUNC_X(0x006ED9D0, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if ((ebx & 0xFF) == 2 || (ebx & 0xFF) == 8 || (ebx & 0xFF) == 3) return 1; return 0; }
/** * * rct2: 0x0068958D */ void screen_pos_to_map_pos(int *x, int *y) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = *x; ebx = *y; RCT2_CALLFUNC_X(0x0068958D, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); *x = eax & 0xFFFF; *y = ebx & 0xFFFF; }
/** * Opens a new window, supposedly automatically positioned * rct2: 0x006EA9B1 * * @param width (bx) * @param height (ebx >> 16) * @param events (edx) * @param flags (ch) * @param class (cl) */ rct_window *window_create_auto_pos(int width, int height, uint32 *event_handlers, rct_windowclass cls, uint16 flags) { int eax, ebx, ecx, edx, esi, edi, ebp; ebx = (height << 16) | width; ecx = (flags << 8) | cls; edx = (int)event_handlers; RCT2_CALLFUNC_X(0x006EA9B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return (rct_window*)esi; }
/* rct2: 0x6ba517 */ static void window_banner_dropdown() { short widgetIndex, dropdownIndex; rct_window* w; window_dropdown_get_registers(w, widgetIndex, dropdownIndex); rct_banner* banner = &gBanners[w->number]; switch(widgetIndex){ case WIDX_MAIN_COLOR: if ( dropdownIndex == 0xFFFF) return; banner->colour = (uint8)dropdownIndex; window_invalidate(w); break; case WIDX_TEXT_COLOR_DROPDOWN_BUTTON: if ( dropdownIndex == 0xFFFF) return; banner->text_colour = dropdownIndex + 1; //Can be replaced with a buffer 34 chars wide ( 32 character + 1 colour_format + 1 '\0') uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8); format_string(text_buffer, banner->string_idx, 0); if (text_buffer[0] < FORMAT_COLOUR_CODE_START || text_buffer[0] > FORMAT_COLOUR_CODE_END){ int end_point = strlen(text_buffer) + 1; strncpy(text_buffer + 1, text_buffer, 32); text_buffer[end_point] = '\0'; } text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START; int string_id = 0, ebx = 0, ecx = 128, edx = 0, ebp = 0, esi = 0; // Allocate text_buffer to a new string_id? RCT2_CALLFUNC_X(0x6C421D, &string_id, &ebx, &ecx, &edx, &esi, (int*)&text_buffer, &ebp); if (string_id){ rct_string_id prev_string_id = banner->string_idx; banner->string_idx = string_id; // De-allocate previous string id? RCT2_CALLPROC_X(0x6C42AC, prev_string_id, 0, 0, 0, 0, 0, 0); window_invalidate(w); } else{ window_error_open(2984, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id)); } break; } }
/** * * rct2: 0x006C2105 * dpi (edi) * format (esi) * x (cx) * y (dx) * width (bp) * colour (bx) * unknown (al) */ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *format, int x, int y, int width, int colour, int unknown) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = unknown; ebx = colour; ecx = x; edx = y; esi = (int)format; edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return (sint16)(edx & 0xFFFF) - y; }
/** * * rct2: 0x006C1E53 * dpi (edi) * args (esi) * x (cx) * y (dx) * width (bp) * colour (al) * format (ebx) */ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = colour; ebx = format; ecx = x; edx = y; esi = (int)args; edi = (int)dpi; ebp = width; RCT2_CALLFUNC_X(0x006C1E53, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return (sint16)(edx & 0xFFFF) - y; }
/** * * rct2: 0x00682702 * dpi (edi) * format (esi) * colour (al) * x (cx) * y (dx) */ void gfx_draw_string(rct_drawpixelinfo *dpi, char *format, int colour, int x, int y) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = colour; ebx = 0; ecx = x; edx = y; esi = (int)format; edi = (int)dpi; ebp = 0; RCT2_CALLFUNC_X(0x00682702, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); gLastDrawStringX = ecx; gLastDrawStringY = edx; }
/** * * rct2: 0x006E83C7 */ static void game_get_next_input(int *x, int *y, int *state) { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if (eax == 0) { *x = gCursorState.x; *y = gCursorState.y; *state = 0; return; } *x = RCT2_GLOBAL(eax + 0, sint32); *y = RCT2_GLOBAL(eax + 4, sint32); *state = RCT2_GLOBAL(eax + 8, sint32); //int eax, ebx, ecx, edx, esi, edi, ebp; //RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); //*x = eax & 0xFFFF; //*y = ebx & 0xFFFF; //*state = ecx & 0xFF; //return; //int on_tutorial = RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8); //if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) { // if (on_tutorial == 1) { // } else { // RCT2_CALLPROC_EBPSAFE(0x00407074); // } // if (on_tutorial == 2) { // } //} else { //} }
int viewport_interaction_left_click(int x, int y) { rct_sprite* spr; int eax = x, ebx = y, ecx = 0, esi = 0, edi = 0, ebp = 0; RCT2_CALLFUNC_X(0x006ED9D0, &eax, &ebx, &ecx, (int*)&spr, &esi, &edi, &ebp); if ((ebx & 0xFF) == 2){ if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_VEHICLE){ //Open ride window RCT2_CALLPROC_X(0x6ACAC2, eax, ebx, ecx, (int)spr, esi, edi, ebp); } else if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_PEEP){ window_guest_open(&spr->peep); } else if (spr->unknown.sprite_identifier == SPRITE_IDENTIFIER_FLOATING_TEXT){ //Unknown for now RCT2_CALLPROC_X(0x6E88D7, eax, ebx, ecx, (int)spr, esi, edi, ebp); } return 1; } else if ((ebx & 0xFF) == 3){ rct_map_element* map_element = (rct_map_element*)spr; if (!((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_ENTRANCE)){ eax = RCT2_ADDRESS(0x0099BA64, uint8)[16 * map_element->properties.track.type]; if (!(eax & 0x10)){//If not station track //Open ride window in overview mode. window_ride_main_open(map_element->properties.track.ride_index); return; } } //Open ride window in station view RCT2_CALLPROC_X(0x6ACCCE, map_element->properties.track.ride_index, (map_element->properties.track.sequence & 0x70) >> 4, ecx, (int)map_element, esi, edi, ebp); return 1; }
/** * * rct2: 0x006E95F9 */ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex) { // RCT2_CALLPROC_X(0x006E95F9, x, y, state, widgetIndex, w, widget, 0); rct_windowclass windowClass = 255; rct_windownumber windowNumber = 0; rct_widget *widget; if (w != NULL) { windowClass = w->classification; windowNumber = w->number; widget = &w->widgets[widgetIndex]; } window_close_by_id(WC_ERROR, 0); window_close_by_id(WC_TOOLTIP, 0); w = window_find_by_id(windowClass, windowNumber); if (w == NULL) return; window_bring_to_front(w); if (widgetIndex == -1) return; switch (widget->type) { case WWT_FRAME: case WWT_RESIZE: if (!(w->flags & WF_RESIZABLE)) break; if (w->min_width == w->max_width && w->min_height == w->max_height) break; if (x < w->x + w->width - 19 || y < w->y + w->height - 19) break; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESIZING; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; break; case WWT_VIEWPORT: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_LEFT; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))) break; w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)); 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_GLOBAL(0x009DE518, uint32) |= (1 << 4); break; case WWT_CAPTION: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_DRAGGING; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber; break; case WWT_SCROLL: RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_SCROLL_LEFT; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y; int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; esi = w; edi = widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; ecx &= 0xFFFF; edx &= 0xFFFF; 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); 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); break; case SCROLL_PART_HSCROLLBAR_LEFT: // 0x006E9A60 RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT: // 0x006E9ABF RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH: // 0x006E9B47 RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH: // 0x006E9BB7 RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP: // 0x006E9C37 RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM: // 0x006E9C96 RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_TOP_TROUGH: // 0x006E9D1E RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH: // 0x006E9D8E RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0); break; } break; default: if (!widget_is_enabled(w, widgetIndex)) break; if (widget_is_disabled(w, widgetIndex)) break; sound_play_panned(4, w->x + (widget->left + widget->right) / 2); // 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(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); break; } }
/** * * rct2: 0x006E9253 */ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex) { // RCT2_CALLPROC_X(0x006E9253, x, y, state, widgetIndex, w, widget, 0); rct_windowclass windowClass = 255; rct_windownumber windowNumber = 0; rct_widget *widget; if (w != NULL) { windowClass = w->classification; windowNumber = w->number; widget = &w->widgets[widgetIndex]; } input_mouseover_widget_check(windowClass, windowNumber, widgetIndex); if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) { int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ebx = y; esi = w; edi = widget; RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part eax &= 0xFFFF; ebx &= 0xFFFF; ecx &= 0xFFFF; edx &= 0xFFFF; if (ecx < 0) goto showTooltip; if (ecx == 0) { RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEOVER], edx, 0, eax, ebx, w, 0, 0); goto showTooltip; } else { } } else { showTooltip: if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) == 255) { if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) < 500 || (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, sint16) == x && RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, sint16) == y) ) { RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = RCT2_GLOBAL(0x009DE588, uint16); int bp = 2000; if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) <= 1000) bp = 0; if (bp > RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16)) return; window_tooltip_open(w, widgetIndex, x, y); // RCT2_CALLPROC_X(0x006EA10D, x, y, 0, widgetIndex, w, widget, 0); // window_tooltip_open(); } } else { if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) != w->classification || RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) != w->number || RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) != widgetIndex ) { window_tooltip_close(); } RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) += RCT2_GLOBAL(0x009DE588, uint16); if (RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) < 8000) return; window_close_by_id(WC_TOOLTIP, 0); } } RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, sint16) = y; }
/** * * rct2: 0x006E8655 */ static void game_handle_input_mouse(int x, int y, int state) { rct_window *w, *w2; 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); widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y); widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex]; switch (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8)) { case INPUT_STATE_RESET: window_tooltip_reset(x, y); // fall-through case INPUT_STATE_NORMAL: switch (state) { case 0: input_mouseover(x, y, w, widgetIndex); break; case 1: input_leftmousedown(x, y, w, widgetIndex); break; case 3: // Close tooltip window_close_by_id(5, 0); if (w != NULL) window_bring_to_front(w); if (widgetIndex == -1) break; if (widget->type == WWT_VIEWPORT) { if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9) break; w->flags &= ~(1 << 3); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_DRAG; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; RCT2_GLOBAL(0x009DE530, rct_windowclass) = w->classification; RCT2_GLOBAL(0x009DE52E, rct_windownumber) = w->number; RCT2_GLOBAL(0x009DE540, sint16) = 0; // hide cursor // RCT2_CALLPROC_X(0x00407045, 0, 0, 0, 0, 0, 0, 0); // RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 5); GetCursorPos(&_dragPosition); ShowCursor(FALSE); } else if (widget->type == WWT_SCROLL) { } break; } break; case INPUT_STATE_WIDGET_PRESSED: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_DRAGGING: // RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0); w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber)); if (w == NULL) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; break; } if (state == 0) { y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34); window_move_position( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; } 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_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); window_move_position( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); 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); } break; case INPUT_STATE_VIEWPORT_DRAG: { int dx, dy; dx = x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16); dy = y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16); w = window_find_by_id(RCT2_GLOBAL(0x009DE530, rct_windowclass), RCT2_GLOBAL(0x009DE52E, rct_windownumber)); if (state == 0) { rct_viewport *viewport = w->viewport; RCT2_GLOBAL(0x009DE540, sint16) += RCT2_GLOBAL(0x009DE588, sint16); if (viewport == NULL) { ShowCursor(TRUE); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; } else if (dx != 0 || dy != 0) { if (!(w->flags & (1 << 2))) { RCT2_GLOBAL(0x009DE540, sint16) = 1000; dx <<= viewport->zoom + 1; dy <<= viewport->zoom + 1; w->var_4B2 += dx; w->var_4B4 += dy; } } } else if (state == 4) { ShowCursor(TRUE); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; if (RCT2_GLOBAL(0x009DE540, sint16) < 500) { // Right click { int eax, ebx, ecx, edx, esi, edi, ebp; eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16); ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16); RCT2_CALLFUNC_X(0x006EDE88, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); switch (ebx & 0xFF) { case 2: if (*((uint8*)edx) == 0) RCT2_CALLPROC_X(0x006B4857, eax, 0, ecx, 0, 0, 0, 0); break; case 3: RCT2_CALLPROC_X(0x006CC056, eax, 0, ecx, edx, 0, 0, 0); break; case 5: RCT2_CALLPROC_X(0x006E08D2, eax, 0, ecx, edx, 0, 0, 0); break; case 6: RCT2_CALLPROC_X(0x006A614A, eax, 0, ecx, edx, 0, 0, 0); break; case 7: RCT2_CALLPROC_X(0x006A61AB, eax, 0, ecx, edx, 0, 0, 0); break; case 8: RCT2_CALLPROC_X(0x00666C0E, eax, 0, ecx, edx, 0, 0, 0); break; case 9: RCT2_CALLPROC_X(0x006E57A9, eax, 0, ecx, edx, 0, 0, 0); break; case 10: RCT2_CALLPROC_X(0x006B88DC, eax, 0, ecx, edx, 0, 0, 0); break; case 12: RCT2_CALLPROC_X(0x006BA233, eax, 0, ecx, edx, 0, 0, 0); break; default: break; } } } } // // SetCursorPos(_dragPosition.x, _dragPosition.y); // RCT2_CALLPROC_X(0x006E89C6, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16), state, widgetIndex, w, widget, 0); break; } case INPUT_STATE_DROPDOWN_ACTIVE: RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_VIEWPORT_LEFT: RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_SCROLL_LEFT: RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0); break; case INPUT_STATE_RESIZING: // RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0); w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber)); if (w == NULL) { RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET; break; } if (state != 0 && state != 2) break; 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_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); } if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) { window_resize( w, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) ); } RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y; break; case 9: RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0); break; } }
/** * * rct2: 0x00678761 */ static void title_update_showcase() { rct_window* w; uint8 script_opcode, script_operand; short x, y; int i, _edx; if (_scriptWaitCounter <= 0) { do { script_opcode = *_currentScript++; switch (script_opcode) { case TITLE_SCRIPT_WAIT: _scriptWaitCounter = (*_currentScript++) * 32; break; case TITLE_SCRIPT_LOAD: scenario_load(get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN)); w = window_get_main(); w->var_4B0 = -1; w->var_4B2 = RCT2_GLOBAL(0x0138869A, sint16); w->var_4B4 = RCT2_GLOBAL(0x0138869C, sint16); { char _cl = (RCT2_GLOBAL(0x0138869E, sint16) & 0xFF) - w->viewport->zoom; w->viewport->zoom = RCT2_GLOBAL(0x0138869E, sint16) & 0xFF; *((char*)(&RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, sint32))) = RCT2_GLOBAL(0x0138869E, sint16) >> 8; if (_cl != 0) { if (_cl < 0) { _cl = -_cl; w->viewport->view_width >>= _cl; w->viewport->view_height >>= _cl; } else { w->viewport->view_width <<= _cl; w->viewport->view_height <<= _cl; } } w->var_4B2 -= w->viewport->view_width >> 1; w->var_4B4 -= w->viewport->view_height >> 1; } window_invalidate(w); RCT2_CALLPROC_EBPSAFE(0x0069E9A7); RCT2_CALLPROC_EBPSAFE(0x006ACA58); RCT2_CALLPROC_EBPSAFE(0x00684AC3); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); news_item_init_queue(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; RCT2_GLOBAL(0x009DEA5C, sint16) = 0x0D6D8; break; case TITLE_SCRIPT_LOCATION: x = (*_currentScript++) * 32 + 16; y = (*_currentScript++) * 32 + 16; // Set location int eax, ebx, ecx, edx, esi, edi, ebp; eax = x; ecx = y; RCT2_CALLFUNC_X(0x00662783, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); _edx = edx; // Update viewport w = window_get_main(); if (w != NULL) { window_scroll_to_location(w, x, y, _edx); w->flags &= ~0x08; viewport_update_position(w); } break; case TITLE_SCRIPT_ROTATE: script_operand = (*_currentScript++); w = window_get_main(); if (w != NULL) for (i = 0; i < script_operand; i++) window_rotate_camera(w); break; case TITLE_SCRIPT_RESTART: _currentScript = _magicMountainScript; if (gRandomShowcase) { if (_currentScript != NULL) free(_currentScript); _currentScript = generate_random_script(); } break; } } while (_scriptWaitCounter == 0);
/** * * rct2: 0x006AA2B7 */ int object_load_packed() { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x006AA2B7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return eax; }
/** * * rct2: 0x006EA10D */ void window_tooltip_open(rct_window *widgetWindow, int widgetIndex, int x, int y) { rct_window *w; rct_widget *widget; int width, height; if (widgetWindow == NULL || widgetIndex == -1) return; widget = &widgetWindow->widgets[widgetIndex]; RCT2_CALLPROC_X(widgetWindow->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, widgetWindow, 0, 0); if (widget->tooltip == 0xFFFF) return; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = widgetWindow->classification; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = widgetWindow->number; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = widgetIndex; int eax, ebx, ecx, edx, esi, edi, ebp; eax = widgetIndex; esi = widgetWindow; RCT2_CALLFUNC_X(widgetWindow->event_handlers[WE_TOOLTIP], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); if ((eax & 0xFFFF) == 0xFFFF) return; w = window_find_by_id(WC_ERROR, 0); if (w != NULL) return; RCT2_GLOBAL(0x0142006C, sint32) = -1; format_string(0x0141ED68, widget->tooltip, 0x013CE952); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; esi = 0x0141ED68; RCT2_CALLFUNC_X(0x006C23B1, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ecx &= 0xFFFF; if (ecx > 196) ecx = 196; esi = 0x0141ED68; edi = ecx + 1; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224; RCT2_CALLFUNC_X(0x006C21E2, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); ecx &= 0xFFFF; edi &= 0xFFFF; RCT2_GLOBAL(0x01420044, sint16) = edi; width = ecx + 3; height = ((edi + 1) * 10) + 4; window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; memcpy(0x0141FE44, 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->widgets = window_tooltip_widgets; RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, uint16) = 0; }
/** * * rct2: 0x006E3B43 */ void game_handle_keyboard_input() { rct_window *w; int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) != 0) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 1) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3)) game_handle_edge_scroll(); // Handle modifier keys and key scrolling RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0; if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) { if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 1; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 2; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) game_handle_key_scroll(); } // Handle key input while ((key = get_next_key()) != 0) { if (key == 255) continue; key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8; w = window_find_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); if (w != NULL) set_shortcut(key); else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) tutorial_stop(); else handle_shortcut(key); } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) return; // Tutorial and the modifier key if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x0066EEB4, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); eax &= 0xFF; RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = eax; 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, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } } else { 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, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } // Write tutorial input RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); } }
/** * * rct2: 0x00669EAA */ int calculate_park_rating() { { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x00669EAA, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); return eax & 0xFFFF; } int result; result = 1150; if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_FLAGS, uint32) & 0x4000) result = 1050; // Guests { rct_peep* peep; uint16 sprite_idx; int num_happy_peeps; short _bp; // -150 to +3 based on a range of guests from 0 to 2000 result -= 150 - (min(2000, RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16)) / 13); // Guests, happiness, ? num_happy_peeps = 0; _bp = 0; for (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->type != PEEP_TYPE_GUEST) continue; if (peep->var_2A != 0) continue; if (peep->happiness > 128) num_happy_peeps++; if (!(peep->var_C8 & 0x01)) continue; if (peep->var_C6 <= 89) _bp++; } // Peep happiness -500 to +0 result -= 500; if (num_happy_peeps > 0) result += 2 * min(250, (RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16) * 300) / num_happy_peeps); // ? _bp -= 25; if (_bp >= 0) result -= _bp * 7; } // Rides { int i; short _ax, _bx; int num_rides; rct_ride* ride; // _ax = 0; num_rides = 0; for (i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; _ax += 100 - ride->var_199; num_rides++; } result -= 200; if (num_rides > 0) result += (_ax / num_rides) * 2; // _ax = 0; _bx = 0; for (i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; if (ride->var_140 == -1) continue; _ax += ride->var_140 / 8; _bx += ride->var_142 / 8; } _ax = min(1000, _ax); _bx = min(1000, _bx); result -= 200 - ((_ax + _bx) / 10); } // Litter { rct_litter* litter; uint16 sprite_idx; short num_litter; num_litter = 0; for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_LITTER, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = litter->next) { litter = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].litter); // Guessing this eliminates recently dropped litter if (litter->var_24 - RCT2_GLOBAL(0x00F663AC, sint32) >= 7680) num_litter++; } result -= 600 - (4 * (150 - min(150, num_litter))); } // Rides { int i, num_rides; short _ax, _bx; rct_ride* ride; num_rides = 0; _ax = 0; _bx = 0; for (i = 0; i < 255; i++) { ride = &(RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[i]); if (ride->type == RIDE_TYPE_NULL) continue; if (ride->var_140 == -1) continue; _ax += ride->var_140 / 8; _bx += ride->var_142 / 8; num_rides++; } result -= 100; if (num_rides > 0) { _bx = _ax / num_rides; _ax = _bx / num_rides; _bx -= 46; if (_bx >= 0) _bx = -_bx; _ax -= 65; if (_ax >= 0) _ax = -_ax; _bx /= 2; _ax /= 2; _bx = min(50, _bx); _ax = min(50, _ax); result += 100 - _ax - _bx; } } result -= RCT2_GLOBAL(0x0135882E, sint16); result = clamp(0, result, 999); return result; }
/** * * rct2: 0x006677F2 * * @param flags (ebx) * @param command (esi) */ int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp) { int cost, flags, insufficientFunds; int original_ebx, original_edx, original_esi, original_edi, original_ebp; original_ebx = ebx; original_edx = edx; original_esi = esi; original_edi = edi; original_ebp = ebp; flags = ebx; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0xFFFF; // Increment nest count RCT2_GLOBAL(0x009A8C28, uint8)++; ebx &= ~1; // Primary command RCT2_CALLFUNC_X(game_do_command_table[esi], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); cost = ebx; if (cost != 0x80000000) { // Check funds insufficientFunds = 0; if (RCT2_GLOBAL(0x009A8C28, uint8) == 1 && !(flags & 4) && !(flags & 0x20) && cost != 0) insufficientFunds = game_check_affordability(cost); if (insufficientFunds != 0x80000000) { ebx = original_ebx; edx = original_edx; esi = original_esi; edi = original_edi; ebp = original_ebp; if (!(flags & 1)) { // Decrement nest count RCT2_GLOBAL(0x009A8C28, uint8)--; return cost; } // Secondary command RCT2_CALLFUNC_X(game_do_command_table[esi], &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); edx = ebx; if (edx != 0x80000000 && edx < cost) cost = edx; // Decrement nest count RCT2_GLOBAL(0x009A8C28, uint8)--; if (RCT2_GLOBAL(0x009A8C28, uint8) != 0) return cost; // if (!(flags & 0x20)) { // Update money balance finance_payment(cost, RCT2_GLOBAL(0x0141F56C, uint8)); RCT2_CALLPROC_X(0x0069C674, 0, cost, 0, 0, 0, 0, 0); if (RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8)) { // Create a +/- money text effect if (cost != 0) RCT2_CALLPROC_X(0x0069C5D0, 0, cost, 0, 0, 0, 0, 0); } } return cost; } } // Error occured // Decrement nest count RCT2_GLOBAL(0x009A8C28, uint8)--; // Show error window if (RCT2_GLOBAL(0x009A8C28, uint8) == 0 && (flags & 1) && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8) && !(flags & 8)) window_error_open(RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TITLE, uint16), RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16)); return 0x80000000; }