/** * * 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 = 0x0141EF67; do { src++; } while (*src != '.' && *src != '\0'); strcpy(src, ".SV6"); strcpy(0x009ABB37, 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 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); } }
/** * * rct2: 0x0068F0A9 */ void peep_update_all() { int i; uint16 spriteIndex; rct_peep* peep; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E) return; spriteIndex = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); i = 0; while (spriteIndex != SPRITE_INDEX_NULL) { peep = &(g_sprite_list[spriteIndex].peep); spriteIndex = peep->next; if ((i & 0x7F) != (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x7F)) { peep_update(peep); } else { RCT2_CALLPROC_X(0x0068F41A, 0, 0, 0, i, (int)peep, 0, 0); if (peep->var_08 == 4) peep_update(peep); } i++; } }
/** * * rct2: 0x0068E8DA */ void title_load() { if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1) RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0);//Game pause toggle RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; reset_park_entrances(); user_string_clear_all(); reset_sprite_list(); ride_init_all(); window_guest_list_init_vars_a(); sub_6BD3A4(); // RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); date_reset(); climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); map_update_tile_pointers(); //RCT2_CALLPROC_EBPSAFE(0x0068AFFD); reset_0x69EBE4();// RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); news_item_init_queue(); title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; }
/** * * rct2: 0x006EA41D */ static void window_tooltip_paint() { rct_window *w; rct_drawpixelinfo *dpi; __asm mov w, esi __asm mov dpi, edi int left = w->x; int top = w->y; int right = w->x + w->width - 1; int bottom = w->y + w->height - 1; // Background gfx_fill_rect(dpi, left + 1, top + 1, right - 1, bottom - 1, 0x0200002D); gfx_fill_rect(dpi, left + 1, top + 1, right - 1, bottom - 1, 0x02000084); // Sides gfx_fill_rect(dpi, left + 0, top + 2, left + 0, bottom - 2, 0x0200002F); gfx_fill_rect(dpi, right + 0, top + 2, right + 0, bottom - 2, 0x0200002F); gfx_fill_rect(dpi, left + 2, bottom + 0, right - 2, bottom + 0, 0x0200002F); gfx_fill_rect(dpi, left + 2, top + 0, right - 2, top + 0, 0x0200002F); // Corners gfx_draw_pixel(dpi, left + 1, top + 1, 0x0200002F); gfx_draw_pixel(dpi, right - 1, top + 1, 0x0200002F); gfx_draw_pixel(dpi, left + 1, bottom - 1, 0x0200002F); 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: 0x006E7499 * left (ax) * top (bx) * right (dx) * bottom (bp) */ void gfx_redraw_screen_rect(short left, short top, short right, short bottom) { rct_window* w; rct_drawpixelinfo *screenDPI = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo); rct_drawpixelinfo *windowDPI = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_DPI, rct_drawpixelinfo); // Unsure what this does RCT2_CALLPROC_X(0x00683326, left, top, right - 1, bottom - 1, 0, 0, 0); windowDPI->bits = screenDPI->bits + left + ((screenDPI->width + screenDPI->pitch) * top); windowDPI->x = left; windowDPI->y = top; windowDPI->width = right - left; windowDPI->height = bottom - top; windowDPI->pitch = screenDPI->width + screenDPI->pitch + left - right; for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { if (w->flags & WF_TRANSPARENT) continue; if (right <= w->x || bottom <= w->y) continue; if (left >= w->x + w->width || top >= w->y + w->height) continue; window_draw(w, left, top, right, bottom); } }
/* 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)); } } }
/** * Closes the specified window. * rct2: 0x006ECD4C * * @param window The window to close (esi). */ void window_close(rct_window* window) { int num_windows; if (window == NULL) return; // Call close event of window 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); // Remove viewport if (window->viewport != NULL) { window->viewport->width = 0; window->viewport = NULL; } // Invalidate the window (area) window_invalidate(window); // Remove window from list and reshift all windows RCT2_NEW_WINDOW--; num_windows = (RCT2_NEW_WINDOW - window); if (num_windows > 0) memmove(window, window + 1, num_windows * sizeof(rct_window)); viewport_update_pointers(); }
/* rct2: 0x006C9BA5 */ void window_construction_mouseup_demolish(rct_window* w){ RCT2_CALLPROC_X(0x6C9BA5, 0, 0, 0, 0, (int)w, 0, 0); return; RCT2_GLOBAL(0xF44070, uint32) = 0x80000000; sub_6C9627(); RCT2_GLOBAL(0xF440B8, uint8) = 3; if (RCT2_GLOBAL(0xF440A6, uint8) == 1){ //6C9C4F } if (RCT2_GLOBAL(0xF440A6, uint8) != 2){ //6c9cc4 int eax = RCT2_GLOBAL(0xF440A8, uint16), ebx = RCT2_GLOBAL(0xF440AF, uint8) || (RCT2_GLOBAL(0xF440AE, uint8) << 8), ecx = RCT2_GLOBAL(0xF440AA, uint16), edx = RCT2_GLOBAL(0xF440AC, uint16); sub_6C683D(&eax, &ecx, edx, RCT2_GLOBAL(0xF440AE, uint8), RCT2_GLOBAL(0xF440AF, uint8) & 0x3FF, 0, 0, 0); } int ride_id = RCT2_GLOBAL(0xF440A7, uint8); RCT2_GLOBAL(0xF441D2, uint8) = ride_id; //6c9BFE }
/*** * * rct2: 0x00688596 * Part of 0x688485 */ void paint_attached_ps(paint_struct* ps, paint_struct* attached_ps, rct_drawpixelinfo* dpi){ for (; attached_ps; attached_ps = attached_ps->next_attached_ps){ sint16 x = attached_ps->attached_x + ps->x; sint16 y = attached_ps->attached_y + ps->y; int image_id = attached_ps->image_id; if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & VIEWPORT_FLAG_SEETHROUGH_RIDES){ if (ps->sprite_type == 3){ if (image_id & 0x40000000){ image_id &= 0x7FFFF; image_id |= 0x41880000; } } } if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & VIEWPORT_FLAG_SEETHROUGH_SCENERY){ if (ps->sprite_type == 5){ if (image_id & 0x40000000){ image_id &= 0x7FFFF; image_id |= 0x41880000; } } } if (!(attached_ps->var_0C & 1)){ gfx_draw_sprite(dpi, image_id, x, y, ps->var_04); } else{ RCT2_CALLPROC_X(0x00681DE2, 0, image_id, x, y, 0, (int)dpi, attached_ps->var_04); } } }
/** * * rct2: 0x006EA627 */ void game_handle_input() { rct_window *w; if (RCT2_GLOBAL(0x009DEA64, uint16) & 2) { RCT2_GLOBAL(0x009DEA64, uint16) &= ~2; RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, 0, 5, 2, 0); } 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, (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; for (;;) { game_get_next_input(&eax, &ebx, &ecx); if (ecx == 0) break; game_handle_input_mouse(eax, ebx, ecx & 0xFF); // RCT2_CALLPROC_X(0x006E8655, eax, ebx, ecx, 0, 0, 0, 0); // window_process_mouse_input } if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) { game_handle_input_mouse(eax, ebx, ecx); // RCT2_CALLPROC_X(0x006E8655, eax, ebx, 0, 0, 0, 0, 0); // window_process_mouse_input } else if (eax != 0x80000000) { eax = clamp(0, eax, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 1); ebx = clamp(0, ebx, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 1); game_handle_input_mouse(eax, ebx, ecx); // RCT2_CALLPROC_X(0x006E8655, eax, ebx, 0, 0, 0, 0, 0); // window_process_mouse_input RCT2_CALLPROC_X(0x006ED833, eax, ebx, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006ED801); } } } 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, (int)w, 0, 0); }
/** * rct2: 0x006989E9 * */ void window_peep_open(rct_peep* peep){ if (peep->type == PEEP_TYPE_STAFF){ RCT2_CALLPROC_X(0x006989E9, 0, 0, 0, (int)peep, 0, 0, 0); } rct_window* window; window = window_bring_to_front_by_id(WC_PEEP, peep->sprite_index); if (window == NULL){ window = window_create_auto_pos(192, 157, (uint32*)window_peep_overview_events, WC_PEEP, 0); window->widgets = window_peep_overview_widgets; window->enabled_widgets = window_peep_page_enabled_widgets[0]; window->number = peep->sprite_index; window->page = 0; window->var_482 = 0; window->frame_no = 0; window->list_information_type = 0; window->var_492 = 0; window->var_494 = 0; RCT2_CALLPROC_X(0x006987A6, 0, 0, 0, 0, (int)window, 0, 0); window->min_width = 192; window->min_height = 157; window->max_width = 500; window->max_height = 450; window->flags = 8; window->no_list_items = 0; window->selected_list_item = -1; window->colours[0] = 1; window->colours[1] = 15; window->colours[2] = 15; window->var_482 = -1; } window->page = 0; RCT2_CALLPROC_X(0x006EB13A, 0, 0, 0, 0, (int)window, 0, 0); window->widgets = RCT2_GLOBAL(0x981D0C, rct_widget*); window->enabled_widgets = RCT2_GLOBAL(0x981D3C,uint32); window->var_020 = RCT2_GLOBAL(0x981D54,uint32); window->event_handlers = RCT2_GLOBAL(0x981D24,uint32*); window->pressed_widgets = 0; RCT2_CALLPROC_X(0x006987A6, 0, 0, 0, 0, (int)window, 0, 0); window_init_scroll_widgets(window); RCT2_CALLPROC_X(0x0069883C, 0, 0, 0, 0, (int)window, 0, 0); }
/** * * rct2: 0x006A7EC5 */ static void window_footpath_mousedown(int widgetIndex, rct_window*w, rct_widget* widget) { switch (widgetIndex) { case WIDX_FOOTPATH_TYPE: window_footpath_show_footpath_types_dialog(w, widget, 0); break; case WIDX_QUEUELINE_TYPE: window_footpath_show_footpath_types_dialog(w, widget, 1); break; case WIDX_DIRECTION_NW: 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, (int)w, 0, 0); break; case WIDX_DIRECTION_SW: 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, (int)w, 0, 0); break; case WIDX_SLOPEDOWN: RCT2_CALLPROC_X(0x006A81AA, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_LEVEL: RCT2_CALLPROC_X(0x006A81C5, 0, 0, 0, 0, (int)w, 0, 0); break; case WIDX_SLOPEUP: RCT2_CALLPROC_X(0x006A81E0, 0, 0, 0, 0, (int)w, 0, 0); break; } }
/* rct2: 0x006C6E14 */ void window_construction_mouseup(){ short widgetIndex; rct_window *w; window_widget_get_registers(w, widgetIndex); RCT2_CALLPROC_X(0x6C6A77, 0, 0, 0, 0, 0, 0, 0); switch (widgetIndex){ case WIDX_CLOSE: window_close(w); break; case 27: RCT2_CALLPROC_X(0x6C9296, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case 26: RCT2_CALLPROC_X(0x6C93B8, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case 23: RCT2_CALLPROC_X(0x6C9F72, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case WIDX_DEMOLISH: window_construction_mouseup_demolish(w); break; case 32: RCT2_CALLPROC_X(0x6C78AA, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case 29: RCT2_CALLPROC_X(0x6C7802, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; case 30: RCT2_CALLPROC_X(0x6C7866, 0, 0, 0, widgetIndex, (int)w, 0, 0); break; } }
static void input_mouseover_widget_flatbutton_invalidate() { rct_window *w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_OVER_WINDOWNUMBER, rct_windownumber)); if (w == NULL) return; RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, 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)); }
/** * * rct2: 0x006ED7B0 */ void window_dispatch_update_all() { rct_window *w; 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_EBPSAFE(0x006EE411); // handle_text_input }
/** * * rct2: 0x006A8066 */ static void window_footpath_toolup() { short x, y; short widgetIndex; rct_window *w; window_tool_get_registers(w, widgetIndex, x, y); if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { RCT2_CALLPROC_X(0x006A8380, x, y, 0, 0, (int)w, 0, 0); } }
/** * Draws i formatted text string left aligned at i specified position but clips * the text with an elipsis if the text width exceeds the specified width. * rct2: 0x006C1B83 * dpi (edi) * format (bx) * args (esi) * colour (al) * x (cx) * y (dx) * width (bp) */ 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, (int)args, (int)dpi, width); //char* buffer; //buffer = (char*)0x0141ED68; //format_string(buffer, format, args); //rctmem->current_font_sprite_base = 224; //clip_text(buffer, width); //gfx_draw_string(dpi, buffer, colour, x, y); }
/** * * rct2: 0x006CFB82 */ static void window_track_list_select(rct_window *w, int index) { uint8 *trackDesignItem, *trackDesignList = (uint8*)0x00F441EC; rct_track_design *trackDesign; w->track_list.var_480 = index; sound_play_panned(SOUND_CLICK_1, w->x + (w->width / 2), 0, 0, 0); if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8) && index == 0) { window_close(w); ride_construct_new(_window_track_list_item); return; } if (RCT2_GLOBAL(0x00F44153, uint8) != 0) RCT2_GLOBAL(0x00F44152, uint8) = 1; if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8)) index--; trackDesignItem = trackDesignList + (index * 128);; RCT2_GLOBAL(0x00F4403C, uint8*) = trackDesignItem; window_track_list_format_name( (char*)0x009BC313, trackDesignItem, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8 ? 0 : FORMAT_WHITE ); subsitute_path((char*)0x0141EF68, (char*)RCT2_ADDRESS_TRACKS_PATH, trackDesignItem); if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8) { window_track_manage_open(); return; } if (!RCT2_CALLPROC_X(0x0067726A, 0, 0, 0, 0, 0, 0, 0)) { w->track_list.var_480 = 0xFFFF; window_invalidate(w); return; } trackDesign = track_get_info(index, NULL); if (trackDesign->var_06 & 4) window_error_open(STR_THIS_DESIGN_WILL_BE_BUILT_WITH_AN_ALTERNATIVE_VEHICLE_TYPE, -1); window_close(w); window_track_place_open(); }
/** * * rct2: 0x006A8047 */ static void window_footpath_tooldown() { short x, y; short widgetIndex; rct_window *w; window_tool_get_registers(w, widgetIndex, x, y); 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, (int)w, 0, 0); } }
/* 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; } }
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; }
/** * Draws i formatted text string centred at i specified position but clips the * text with an elipsis if the text width exceeds the specified width. * rct2: 0x006C1BBA * dpi (edi) * format (bx) * args (esi) * colour (al) * x (cx) * y (dx) * width (bp) */ 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, (int)args, (int)dpi, width); //char* buffer; //short text_width; //buffer = (char*)0x0141ED68; //format_string(buffer, format, args); //rctmem->current_font_sprite_base = 224; //text_width = clip_text(buffer, width); //// Draw the text centred //x -= (text_width - 1) / 2; //gfx_draw_string(dpi, buffer, colour, x, y); }
/** * * rct2: 0x0066FADA */ static void window_editor_top_toolbar_resize() { rct_window *mainWindow = window_get_main(); rct_window *w; window_get_register(w); int eax = 0; if ((w->disabled_widgets & 0xFF) == 0) eax |= (1 << 3); if ((w->disabled_widgets & 0xFF) == 3) eax |= (1 << 2); RCT2_CALLPROC_X(0x006ECE14, 0, 0, 0, 0, (int)w, 0, 0); }
/** * * rct2: 0x006AEAB4 */ rct_window *window_ride_open(int rideIndex) { rct_window *w; w = window_create_auto_pos(316, 180, window_ride_page_events[0], WC_RIDE, 0x400); w->widgets = window_ride_page_widgets[0]; w->enabled_widgets = 0x007DBFF4; w->number = rideIndex; w->page = 0; w->var_48C = 0; w->frame_no = 0; w->list_information_type = 0; w->var_492 = 0; w->var_494 = 0; RCT2_CALLPROC_X(0x006AEB9F, 0, 0, 0, 0, (int)w, 0, 0); w->min_width = 316; w->min_height = 180; w->max_width = 500; w->max_height = 450; w->flags |= WF_RESIZABLE; w->colours[0] = 1; w->colours[1] = 26; w->colours[2] = 11; rct_ride *ride = &g_ride_list[rideIndex]; uint8 *edx = (uint8*)0x009E32F8; if (ride->type != RIDE_TYPE_NULL) { int rideType = ride->type; do { edx++; if (*(edx - 1) != 0xFF) continue; } while (rideType-- != 0); } int eax, ebx = 0, ecx; while (*edx != 0xFF) { eax = *edx++; ecx = eax >> 5; eax &= 0x1F; if (!(RCT2_ADDRESS(0x001357424, uint32)[ecx] & (1 << eax))) continue; ebx++; } RCT2_GLOBAL((int)w + 496, uint16) = ebx; }
void game_logic_update() { short _bx, _dx; RCT2_GLOBAL(0x013628F4, sint32)++; RCT2_GLOBAL(0x00F663AC, sint32)++; RCT2_GLOBAL(0x009DEA66, sint16)++; if (RCT2_GLOBAL(0x009DEA66, sint16) == 0) RCT2_GLOBAL(0x009DEA66, sint16)--; RCT2_CALLPROC_EBPSAFE(0x0068B089); RCT2_CALLPROC_EBPSAFE(0x006C44B1); // update_objective RCT2_CALLPROC_EBPSAFE(0x006C46B1); // update_climate RCT2_CALLPROC_EBPSAFE(0x006646E1); RCT2_CALLPROC_EBPSAFE(0x006A876D); peep_update_all(); RCT2_CALLPROC_EBPSAFE(0x006D4204); // update vehicles RCT2_CALLPROC_EBPSAFE(0x00672AA4); // update text effects RCT2_CALLPROC_EBPSAFE(0x006ABE4C); // update rides RCT2_CALLPROC_EBPSAFE(0x006674F7); // update park RCT2_CALLPROC_EBPSAFE(0x00684C7A); RCT2_CALLPROC_EBPSAFE(0x006B5A2A); RCT2_CALLPROC_EBPSAFE(0x006B6456); // update ride measurements RCT2_CALLPROC_EBPSAFE(0x0068AFAD); RCT2_CALLPROC_EBPSAFE(0x006BBC6B); RCT2_CALLPROC_EBPSAFE(0x006BD18A); RCT2_CALLPROC_EBPSAFE(0x006BCB91); news_item_update_current(); RCT2_CALLPROC_EBPSAFE(0x0067009A); // Update windows window_dispatch_update_all(); if (RCT2_GLOBAL(0x009AC31B, uint8) != 0) { _bx = 3010; _dx = RCT2_GLOBAL(0x009AC31C, uint16); if (RCT2_GLOBAL(0x009AC31B, uint8) != 254) { _bx = RCT2_GLOBAL(0x009AC31C, uint16); _dx = 0xFFFF; } RCT2_GLOBAL(0x009AC31B, uint8) = 0; RCT2_CALLPROC_X(0x0066792F, 0, _bx, 0, _dx, 0, 0, 0); } }
/** * * rct2: 0x006E77A1 */ void window_update_all() { rct_window* w; RCT2_GLOBAL(0x009E3CD8, sint32)++; // if (RCT2_GLOBAL(0x009E3CD8, sint32) == 224 && RCT2_GLOBAL(0x009ABDF2, sint8) != 0) // RCT2_CALLPROC(0x004067E3); // ddwindow_move_to_top_corner if (RCT2_GLOBAL(0x009ABDF2, sint8) == 0) return; gfx_draw_all_dirty_blocks(); for (w = g_window_list; w < RCT2_NEW_WINDOW; w++) if (w->viewport != NULL) viewport_update_position(w); // 1000 tick update RCT2_GLOBAL(0x009DEB7C, sint16) += RCT2_GLOBAL(0x009DE588, sint16); if (RCT2_GLOBAL(0x009DEB7C, sint16) >= 1000) { RCT2_GLOBAL(0x009DEB7C, sint16) = 0; for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_07], 0, 0, 0, 0, (int) w, 0, 0); } // Border flash invalidation for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) { if (w->flags & WF_WHITE_BORDER_MASK) { w->flags -= WF_WHITE_BORDER_ONE; if (!(w->flags & WF_WHITE_BORDER_MASK)) window_invalidate(w); } } // RCT2_CALLPROC_X(0x006E7868, 0, 0, 0, 0, 0, RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo), 0); // process_mouse_wheel_input(); window_all_wheel_input(); }
/** * * rct2: 0x006EA594 * x (ax) * y (bx) * returns widget_index (edx) * EDI NEEDS TO BE SET TO w->widgets[widget_index] AFTER */ int window_find_widget_from_point(rct_window *w, int x, int y) { rct_widget *widget; int i, widget_index; // Invalidate the window 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; RCT2_GLOBAL(0x01420074, uint8) = -1; for (i = 0;; i++) { widget = &w->widgets[i]; if (widget->type == WWT_LAST) { break; } else if (widget->type != WWT_EMPTY) { if (widget->type == WWT_SCROLL) RCT2_GLOBAL(0x01420074, uint8)++; if (x >= w->x + widget->left && x <= w->x + widget->right && y >= w->y + widget->top && y <= w->y + widget->bottom ) { widget_index = i; RCT2_GLOBAL(0x01420075, uint8) = RCT2_GLOBAL(0x01420074, uint8); } } } // Return next widget if a dropdown if (widget_index != -1) if (w->widgets[widget_index].type == WWT_DROPDOWN) widget_index++; // Return the widget index return widget_index; }
/** * * rct2: 0x0068FC1E */ static void peep_update(rct_peep *peep) { // RCT2_CALLPROC_X(0x0068FC1E, 0, 0, 0, 0, (int)peep, 0, 0); return; int i, j; if (peep->type == PEEP_TYPE_GUEST) { if (peep->var_AD != 255) if (++peep->var_AE < 720) peep->var_AD = 255; // Update thoughts i = 0; int ebp = 0; int edi = -1; for (i = 0; i < PEEP_MAX_THOUGHTS; i++) { if (peep->thoughts[i].type == PEEP_THOUGHT_TYPE_NONE) break; if (peep->thoughts[i].var_2 == 1) { ebp++; if (++peep->thoughts[i].var_3 >= 220) { peep->thoughts[i].var_3 = 0; peep->thoughts[i].var_2++; ebp--; } } else if (peep->thoughts[i].var_2 > 1) { if (++peep->thoughts[i].var_3 > 255) { if (++peep->thoughts[i].var_3 >= 28) { peep->var_45 |= 1; // Clear top thought, push others up for (j = i; j < PEEP_MAX_THOUGHTS - 1; j++) peep->thoughts[j].type = peep->thoughts[j + 1].type; peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE; } } } else { edi = i; } } if (ebp == 0 && edi != -1) { peep->thoughts[edi].var_2 = 1; peep->var_45 |= 1; } } // Walking speed logic unsigned int stepsToTake = peep->energy; if (stepsToTake < 95 && peep->state == PEEP_STATE_QUEUING) stepsToTake = 95; if ((peep->flags & PEEP_FLAGS_SLOW_WALK) && peep->state != PEEP_STATE_QUEUING) stepsToTake /= 2; if (peep->var_71 == 255 && (RCT2_GLOBAL((int)peep + 0x29, uint8) & 4)) { stepsToTake /= 2; if (peep->state == PEEP_STATE_QUEUING) stepsToTake += stepsToTake / 2; } unsigned int carryCheck = peep->var_73 + stepsToTake; peep->var_73 = carryCheck; if (carryCheck <= 255) { // loc_68FD3A RCT2_CALLPROC_X(0x0068FD3A, 0, 0, 0, 0, (int)peep, 0, 0); } else { // loc_68FD2F RCT2_CALLPROC_X(0x0068FD2F, 0, 0, 0, 0, (int)peep, 0, 0); switch (peep->state) { } } }
/** * * rct2: 0x006CED50 */ void track_load_list(int edx) { RCT2_CALLPROC_X(0x006CED50, 0, 0, 0, edx, 0, 0, 0); }
/** * * rct2: 0x006E7A3A */ void viewport_update_position(rct_window *window) { //RCT2_CALLPROC_X(0x006E7A3A, 0, 0, 0, 0, (int)window, 0, 0); RCT2_CALLPROC_X(window->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)window, 0, 0); rct_viewport* viewport = window->viewport; if (!viewport)return; if (window->viewport_target_sprite != -1){ rct_sprite* sprite = &g_sprite_list[window->viewport_target_sprite]; int height = map_element_height(sprite->unknown.x, sprite->unknown.y) - 16; int underground = sprite->unknown.z < height; RCT2_CALLPROC_X(0x6E7A15, sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, underground, (int)window, (int)viewport, 0); int center_x, center_y; center_2d_coordinates(sprite->unknown.x, sprite->unknown.y, sprite->unknown.z, ¢er_x, ¢er_y, window->viewport); RCT2_CALLPROC_X(0x6E7DE1, center_x, center_y, 0, 0, (int)window, (int)viewport, 0); window_invalidate(window);//Added to force a redraw. return; } sint16 x = viewport->view_width / 2 + window->saved_view_x; sint16 y = viewport->view_height / 2 + window->saved_view_y; int curr_rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); sub_689174(&x, &y, curr_rotation); RCT2_CALLPROC_X(0x006E7A15, x, y, 0, 0, (int)window, (int)viewport, 0); //Clamp to the map minimum value int at_map_edge = 0; if (x < MAP_MINIMUM_X_Y){ x = MAP_MINIMUM_X_Y; at_map_edge = 1; } if (y < MAP_MINIMUM_X_Y){ y = MAP_MINIMUM_X_Y; at_map_edge = 1; } //Clamp to the map maximum value (scenario specific) if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16); at_map_edge = 1; } if (y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ y = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16); at_map_edge = 1; } if (at_map_edge) { // The &0xFFFF is to prevent the sign extension messing the // function up. int z = map_element_height(x & 0xFFFF, y & 0xFFFF); int _2d_x, _2d_y; center_2d_coordinates(x, y, z, &_2d_x, &_2d_y, viewport); if (window->saved_view_x > 0){ _2d_x = min(_2d_x, window->saved_view_x); } else{ _2d_x = max(_2d_x, window->saved_view_x); } if (window->saved_view_y > 0){ _2d_y = min(_2d_y, window->saved_view_y); } else{ _2d_y = max(_2d_y, window->saved_view_y); } window->saved_view_x = _2d_x; window->saved_view_y = _2d_y; } x = window->saved_view_x; y = window->saved_view_y; if (window->flags & WF_SCROLLING_TO_LOCATION){ // Moves the viewport if focusing in on an item uint8 flags = 0; x -= viewport->view_x; if (x < 0){ x = -x; flags |= 1; } y -= viewport->view_y; if (y < 0){ y = -y; flags |= 2; } x = (x + 7)/8; y = (y + 7)/8; //If we are at the final zoom position if (!x && !y){ window->flags &= ~WF_SCROLLING_TO_LOCATION; } if (flags & 1){ x = -x; } if (flags & 2){ y = -y; } x += viewport->view_x; y += viewport->view_y; } RCT2_CALLPROC_X(0x6E7DE1, x, y, 0, 0, (int)window, (int)viewport, 0); }