clean up many CALL_PROCs and implement a few functions

This commit is contained in:
IntelOrca 2015-03-31 02:21:30 +01:00
parent 7f42400f36
commit 851b0819b9
18 changed files with 134 additions and 88 deletions

View File

@ -291,17 +291,17 @@ static void set_all_land_owned()
}
/**
*
* rct2: 0x006BD3A4
*/
void sub_6BD3A4() {
for (short i = 0; i < 200; i++) {
*
* rct2: 0x006BD3A4
*/
void sub_6BD3A4()
{
for (int i = 0; i < 200; i++)
RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_NONE;
}
for (short i = 200; i < 204; i++) {
for (int i = 200; i < 204; i++)
RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_WALK;
}
//RCT2_CALLPROC_EBPSAFE(0x006C0C3F);
sub_6C0C3F();
}

View File

@ -473,6 +473,15 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
return 0x80000000;
}
void pause_toggle()
{
RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) ^= 1;
window_invalidate_by_class(WC_TOP_TOOLBAR);
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1)
pause_sounds();
else
unpause_sounds();
}
/**
*
@ -480,14 +489,9 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
*/
void game_pause_toggle(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp)
{
if (*ebx & GAME_COMMAND_FLAG_APPLY) {
RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) ^= 1;
window_invalidate_by_class(WC_TOP_TOOLBAR);
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint32) & 1)
pause_sounds();
else
unpause_sounds();
}
if (*ebx & GAME_COMMAND_FLAG_APPLY)
pause_toggle();
*ebx = 0;
}

View File

@ -109,6 +109,7 @@ void game_reduce_game_speed();
void game_load_or_quit_no_save_prompt();
int game_load_save(const char *path);
void game_pause_toggle(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
void pause_toggle();
char save_game();
void rct2_exit();
void rct2_exit_reason(rct_string_id title, rct_string_id body);

View File

@ -25,6 +25,7 @@
#include "keyboard_shortcut.h"
#include "viewport.h"
#include "window.h"
#include "widget.h"
typedef void (*shortcut_action)();
@ -171,7 +172,38 @@ static void shortcut_rotate_view()
static void shortcut_rotate_construction_object()
{
RCT2_CALLPROC_EBPSAFE(0x006E4182);
rct_window *w;
// Rotate scenery
w = window_find_by_class(WC_SCENERY);
if (w != NULL && !widget_is_disabled(w, 25) && w->widgets[25].type != WWT_EMPTY) {
window_event_mouse_up_call(w, 25);
return;
}
// Rotate construction track piece
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
if (w != NULL && !widget_is_disabled(w, 32) && w->widgets[32].type != WWT_EMPTY) {
// Check if building a maze...
if (w->widgets[32].tooltip != 1761) {
window_event_mouse_up_call(w, 32);
return;
}
}
// Rotate track design preview
w = window_find_by_class(WC_TRACK_DESIGN_LIST);
if (w != NULL && !widget_is_disabled(w, 5) && w->widgets[5].type != WWT_EMPTY) {
window_event_mouse_up_call(w, 5);
return;
}
// Rotate track design placement
w = window_find_by_class(WC_TRACK_DESIGN_PLACE);
if (w != NULL && !widget_is_disabled(w, 3) && w->widgets[3].type != WWT_EMPTY) {
window_event_mouse_up_call(w, 3);
return;
}
}
static void shortcut_underground_view_toggle()
@ -308,14 +340,11 @@ static void shortcut_show_financial_information()
static void shortcut_show_research_information()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
// Open new ride window
RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
window = window_find_by_class(WC_CONSTRUCT_RIDE);
if (window != NULL)
window_event_mouse_up_call(window, 10);
if (gConfigInterface.toolbar_show_research)
window_research_open();
else
window_new_ride_open_research();
}
}
@ -386,7 +415,7 @@ static void shortcut_show_map()
static void shortcut_screenshot()
{
RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2
RCT2_GLOBAL(RCT2_ADDRESS_SCREENSHOT_COUNTDOWN, uint8) = 2;
}
static void shortcut_reduce_game_speed()

View File

@ -642,7 +642,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, (int)w, 0, 0);
window_event_invalidate_call(w);
// Find the widget at point x, y
widget_index = -1;
@ -1140,14 +1140,24 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z)
}
}
/**
*
* rct2: 0x00688956
*/
void sub_688956()
{
rct_window *w;
for (w = RCT2_NEW_WINDOW - 1; w >= g_window_list; w--)
RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_14], 0, 0, 0, 0, (int)w, 0, 0);
}
/**
*
* rct2: 0x0068881A
*/
void window_rotate_camera(rct_window *w)
{
//RCT2_CALLPROC_X(0x0068881A, 0, 0, 0, 0, (int)w, 0, 0);
rct_viewport *viewport = w->viewport;
if (viewport == NULL)
return;
@ -1186,8 +1196,7 @@ void window_rotate_camera(rct_window *w)
window_invalidate(w);
RCT2_CALLPROC_EBPSAFE(0x00688956);
sub_688956();
sub_69E9A7();
}
@ -1345,7 +1354,7 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom)
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_4, uint8) = v->colours[3] & 0x7F;
// Invalidate the window
RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)v, 0, 0);
window_event_invalidate_call(v);
// Paint the window
RCT2_CALLPROC_X(v->event_handlers[WE_PAINT], 0, 0, 0, 0, (int)v, (int)dpi, 0);
@ -1484,8 +1493,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, (int)w, 0, 0);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_resize_call(w);
window_event_invalidate_call(w);
// Update scroll widgets
for (i = 0; i < 3; i++) {
@ -1906,7 +1915,7 @@ void sub_6EA73F()
for (w = RCT2_LAST_WINDOW; w >= g_window_list; w--) {
window_update_scroll_widgets(w);
window_invalidate_pressed_image_buttons(w);
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_resize_call(w);
}
}

View File

@ -540,7 +540,8 @@ void window_ride_construct(rct_window *w);
void window_ride_list_open();
rct_window * window_construction_open();
void window_track_place_open();
void window_new_ride_open();
rct_window *window_new_ride_open();
rct_window *window_new_ride_open_research();
void window_banner_open(rct_windownumber number);
void window_sign_open(rct_windownumber number);
void window_sign_small_open(rct_windownumber number);

View File

@ -530,9 +530,8 @@ void peep_update_sprite_type(rct_peep* peep){
void peep_window_state_update(rct_peep* peep){
rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index);
if (w){
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
}
if (w != NULL)
window_event_invalidate_call(w);
if (peep->type == PEEP_TYPE_GUEST){
// Update action label

View File

@ -1134,7 +1134,7 @@ int scenario_save(char *path, int flags)
fclose(file);
if (!(flags & 0x80000000))
reset_loaded_objects();//RCT2_CALLPROC_EBPSAFE(0x006A9FC0);
reset_loaded_objects();
gfx_invalidate_screen();
RCT2_GLOBAL(0x009DEA66, uint16) = 0;

View File

@ -94,7 +94,7 @@ void title_load()
log_verbose("loading title");
if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) & 1)
RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0);//Game pause toggle
pause_toggle();
RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO;
@ -103,7 +103,7 @@ void title_load()
reset_sprite_list();
ride_init_all();
window_guest_list_init_vars_a();
sub_6BD3A4(); // RCT2_CALLPROC_EBPSAFE(0x006BD3A4);
sub_6BD3A4();
map_init(150);
park_init();
date_reset();
@ -112,8 +112,8 @@ void title_load()
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);
map_update_tile_pointers();
reset_0x69EBE4();
viewport_init_all();
news_item_init_queue();
title_create_windows();
@ -131,14 +131,12 @@ void title_load()
*/
static void title_create_windows()
{
// RCT2_CALLPROC_EBPSAFE(0x0066B3E8);
window_main_open();
window_title_menu_open();
window_title_exit_open();
window_title_options_open();
window_title_logo_open();
RCT2_CALLPROC_EBPSAFE(0x0066B905);
window_resize_gui(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16));
}
/**

View File

@ -1513,8 +1513,8 @@ static void window_finances_set_page(rct_window *w, int page)
w->width = 530;
w->height = 257;
}
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);

View File

@ -568,7 +568,7 @@ void window_guest_overview_resize(){
window_get_register(w);
window_guest_disable_widgets(w);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_MARQUEE);
@ -676,10 +676,8 @@ void window_guest_set_page(rct_window* w, int page){
w->widgets = window_guest_page_widgets[page];
window_guest_disable_widgets(w);
window_invalidate(w);
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);
@ -768,7 +766,7 @@ void window_guest_viewport_init(rct_window* w){
viewport_flags |= VIEWPORT_FLAG_GRIDLINES;
}
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
w->viewport_focus_coordinates.x = focus.coordinate.x;
w->viewport_focus_coordinates.y = focus.coordinate.y;

View File

@ -382,13 +382,13 @@ static void window_new_ride_scroll_to_focused_ride(rct_window *w)
*
* rct2: 0x006B3CFF
*/
void window_new_ride_open()
rct_window *window_new_ride_open()
{
rct_window *w;
w = window_bring_to_front_by_class(WC_CONSTRUCT_RIDE);
if (w != NULL)
return;
return w;
// Not sure what these windows are
window_close_by_class(WC_TRACK_DESIGN_LIST);
@ -427,6 +427,17 @@ void window_new_ride_open()
w->width = 1;
window_new_ride_refresh_widget_sizing(w);
window_new_ride_scroll_to_focused_ride(w);
return w;
}
rct_window *window_new_ride_open_research()
{
rct_window *w;
w = window_new_ride_open();
window_new_ride_set_page(w, WINDOW_NEW_RIDE_PAGE_RESEARCH);
return w;
}
/**

View File

@ -888,10 +888,8 @@ static void window_options_set_page(rct_window *w, int page)
w->frame_no = 0;
window_invalidate(w);
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);
}

View File

@ -1018,7 +1018,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, (int)w, 0, 0);
window_event_invalidate_call(w);
w->viewport_focus_coordinates.x = x;
w->viewport_focus_coordinates.y = y;

View File

@ -620,8 +620,8 @@ static void window_research_set_page(rct_window *w, int page)
w->width = 320;
w->height = 207;
}
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);

View File

@ -1421,9 +1421,8 @@ static void window_ride_set_page(rct_window *w, int page)
window_ride_disable_tabs(w);
window_invalidate(w);
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);
@ -1535,7 +1534,7 @@ static void window_ride_init_viewport(rct_window *w)
viewport_flags |= VIEWPORT_FLAG_GRIDLINES;
}
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
w->viewport_focus_coordinates.x = focus.coordinate.x;
w->viewport_focus_coordinates.y = focus.coordinate.y;
@ -1896,7 +1895,7 @@ static void window_ride_main_update(rct_window *w)
// Update tab animation
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_1);
// Update status
@ -2402,7 +2401,7 @@ static void window_ride_vehicle_dropdown()
static void window_ride_vehicle_update(rct_window *w)
{
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_2);
}
@ -2946,7 +2945,7 @@ static void window_ride_operating_update(rct_window *w)
rct_ride *ride;
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_3);
ride = GET_RIDE(w->number);
@ -3356,7 +3355,7 @@ static void window_ride_maintenance_update(rct_window *w)
rct_ride *ride;
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_4);
ride = GET_RIDE(w->number);
@ -3844,7 +3843,7 @@ static void window_ride_colour_dropdown()
static void window_ride_colour_update(rct_window *w)
{
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_5);
widget_invalidate(w, WIDX_VEHICLE_PREVIEW);
}
@ -4369,7 +4368,7 @@ static void window_ride_music_dropdown()
static void window_ride_music_update(rct_window *w)
{
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_6);
}
@ -4639,7 +4638,7 @@ static void window_ride_measurements_dropdown()
static void window_ride_measurements_update(rct_window *w)
{
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_7);
}
@ -5011,9 +5010,9 @@ static void window_ride_graphs_update(rct_window *w)
int x;
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_8);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_GRAPH);
widget = &window_ride_graphs_widgets[WIDX_GRAPH];
@ -5041,7 +5040,7 @@ static void window_ride_graphs_scrollgetheight()
window_get_register(w);
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
// Set minimum size
width = window_ride_graphs_widgets[WIDX_GRAPH].right - window_ride_graphs_widgets[WIDX_GRAPH].left - 2;
@ -5447,7 +5446,7 @@ static void window_ride_income_update(rct_window *w)
rct_ride *ride;
w->frame_no++;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_9);
ride = GET_RIDE(w->number);
@ -5731,7 +5730,7 @@ static void window_ride_customer_update(rct_window *w)
if (w->var_492 >= 24)
w->var_492 = 0;
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
widget_invalidate(w, WIDX_TAB_10);
ride = GET_RIDE(w->number);

View File

@ -332,9 +332,8 @@ void window_staff_open(rct_peep* peep)
window_staff_disable_widgets(w);
window_init_scroll_widgets(w);
window_staff_viewport_init(w);
if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED) {
RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_UP], 0, 0, 0, 10, (int)w, 0, 0);
}
if (g_sprite_list[w->number].peep.state == PEEP_STATE_PICKED)
window_event_mouse_up_call(w, WIDX_CHECKBOX_3);
}
/**
@ -421,8 +420,8 @@ void window_staff_set_page(rct_window* w, int page)
window_staff_disable_widgets(w);
window_invalidate(w);
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);
@ -1279,7 +1278,7 @@ void window_staff_viewport_init(rct_window* w){
viewport_flags |= VIEWPORT_FLAG_GRIDLINES;
}
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0);
window_event_invalidate_call(w);
w->viewport_focus_sprite.sprite_id = focus.sprite_id;
w->viewport_focus_sprite.type = focus.type;

View File

@ -182,8 +182,8 @@ static void window_scenarioselect_mousedown(int widgetIndex, rct_window*w, rct_w
w->selected_tab = widgetIndex - 4;
w->var_494 = 0;
window_invalidate(w);
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_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
window_invalidate(w);
}