From 3ffffc699cac9494a554d1a5e4cf857fa30c5236 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sun, 12 Jul 2015 01:46:52 +0100 Subject: [PATCH] clean up and remove various callprocs --- src/game.c | 4 ++-- src/game.h | 2 +- src/interface/viewport.c | 8 ++------ src/ride/ride.c | 14 -------------- src/windows/ride.c | 25 ++++--------------------- src/world/footpath.h | 1 + src/world/map.c | 38 ++++++++++++++++++++------------------ src/world/map.h | 1 + src/world/sprite.c | 15 +++++++-------- 9 files changed, 38 insertions(+), 70 deletions(-) diff --git a/src/game.c b/src/game.c index e26db4bedd..021efd0df4 100644 --- a/src/game.c +++ b/src/game.c @@ -907,7 +907,7 @@ void game_load_or_quit_no_save_prompt() static uint32 game_do_command_table[58] = { 0, - 0x0066397F, + 0, 0, 0, 0, @@ -970,7 +970,7 @@ void game_command_emptysub(int* eax, int* ebx, int* ecx, int* edx, int* esi, int static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_set_ride_appearance, - game_command_emptysub, + game_command_set_land_height, game_pause_toggle, game_command_place_track, game_command_remove_track, diff --git a/src/game.h b/src/game.h index 5a2911113b..5247ccd70e 100644 --- a/src/game.h +++ b/src/game.h @@ -26,7 +26,7 @@ enum GAME_COMMAND { GAME_COMMAND_SET_RIDE_APPEARANCE, - GAME_COMMAND_1, + GAME_COMMAND_SET_LAND_HEIGHT, GAME_COMMAND_TOGGLE_PAUSE, GAME_COMMAND_PLACE_TRACK, GAME_COMMAND_REMOVE_TRACK, diff --git a/src/interface/viewport.c b/src/interface/viewport.c index ec8ad17070..0a4878b9a4 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -2587,9 +2587,7 @@ void screen_get_map_xy_with_z(sint16 screenX, sint16 screenY, sint16 z, sint16 * */ void screen_get_map_xy_quadrant(sint16 screenX, sint16 screenY, sint16 *mapX, sint16 *mapY, uint8 *quadrant) { - rct_viewport *viewport; - - screen_get_map_xy(screenX, screenY, mapX, mapY, &viewport); + screen_get_map_xy(screenX, screenY, mapX, mapY, NULL); if (*mapX == (sint16)0x8000) return; @@ -2619,9 +2617,7 @@ void screen_get_map_xy_quadrant_with_z(sint16 screenX, sint16 screenY, sint16 z, */ void screen_get_map_xy_side(sint16 screenX, sint16 screenY, sint16 *mapX, sint16 *mapY, uint8 *side) { - rct_viewport *viewport; - - screen_get_map_xy(screenX, screenY, mapX, mapY, &viewport); + screen_get_map_xy(screenX, screenY, mapX, mapY, NULL); if (*mapX == (sint16)0x8000) return; diff --git a/src/ride/ride.c b/src/ride/ride.c index eb5cb63a66..f5a78109d5 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3000,20 +3000,6 @@ void ride_set_map_tooltip(rct_map_element *mapElement) */ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId) { - /*{ - int a_eax, a_ebx, a_ecx, a_edx, a_esi, a_edi, a_ebp; - - a_eax = x; - a_ebx = (*tuneId << 8) | rideIndex; - a_ecx = y; - a_edx = z; - a_edi = sampleRate; - a_ebp = position; - RCT2_CALLFUNC_X(0x006BC3AC, &a_eax, &a_ebx, &a_ecx, &a_edx, &a_esi, &a_edi, &a_ebp); - - *tuneId = (a_ebx >> 8) & 0xFF; - return a_ebp; - }*/ if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) { RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate; sint16 v11; diff --git a/src/windows/ride.c b/src/windows/ride.c index 9eb5b926a4..3981ffa009 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -3674,24 +3674,14 @@ static void window_ride_set_track_colour_scheme(rct_window *w, int x, int y) { rct_map_element *mapElement; uint8 newColourScheme; + int interactionType, z, direction; newColourScheme = (uint8)(*((uint16*)&w->var_494)); - int interactionType; - rct_xy16 mapCoord = { 0 }; get_map_coordinates_from_pos(x, y, VIEWPORT_INTERACTION_MASK_RIDE, &mapCoord.x, &mapCoord.y, &interactionType, &mapElement, NULL); x = mapCoord.x; y = mapCoord.y; - // Get map coordinates from point - /*int eax, ebx, ecx, edx, esi, edi, ebp; - eax = x; - ebx = y; - edx = -5; - RCT2_CALLFUNC_X(0x00685ADC, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - x = eax & 0xFFFF; - y = ecx & 0xFFFF; - mapElement = (rct_map_element*)edx;*/ if (interactionType != VIEWPORT_INTERACTION_ITEM_RIDE) return; @@ -3700,16 +3690,9 @@ static void window_ride_set_track_colour_scheme(rct_window *w, int x, int y) if ((mapElement->properties.track.colour & 3) == newColourScheme) return; - RCT2_CALLPROC_X( - 0x006C683D, - x, - ((mapElement->type & 3) << 8) | mapElement->properties.track.type, - y, - mapElement->base_height << 3, - newColourScheme, - 0, - 4 - ); + z = mapElement->base_height * 8; + direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; + sub_6C683D(&x, &y, &z, direction, mapElement->properties.track.type, newColourScheme, NULL, 4); } /** diff --git a/src/world/footpath.h b/src/world/footpath.h index 28f89cdb1f..4cf703b54d 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -48,6 +48,7 @@ enum { extern const rct_xy16 word_981D6C[4]; +money32 footpath_remove_real(int x, int y, int z, int flags); void game_command_place_footpath(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); void game_command_remove_footpath(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); money32 footpath_place(int type, int x, int y, int z, int slope, int flags); diff --git a/src/world/map.c b/src/world/map.c index e005eec11c..26d059aea6 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -20,6 +20,9 @@ #include "../addresses.h" #include "../audio/audio.h" +#include "../cheats.h" +#include "../config.h" +#include "../cursors.h" #include "../game.h" #include "../interface/window.h" #include "../localisation/date.h" @@ -33,9 +36,7 @@ #include "map_animation.h" #include "park.h" #include "scenery.h" -#include "../cheats.h" -#include "../config.h" -#include "../cursors.h" + const rct_xy16 TileDirectionDelta[] = { { -32, 0 }, @@ -1166,17 +1167,6 @@ void game_command_set_banner_colour(int* eax, int* ebx, int* ecx, int* edx, int* *ebx = 0; } -money32 sub_6A67C0(int x, int y, int z, int flags) -{ - int eax, ebx, ecx, edx, esi, edi, ebp; - eax = x * 32; - ecx = y * 32; - ebx = flags & 0xFF; - edx = z & 0xFF; - RCT2_CALLFUNC_X(0x006A67C0, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - return ebx; -} - // This will cause clear scenery to remove paths // This should be a flag for the game command which can be set via a checkbox on the clear scenery window. // #define CLEAR_SCENERY_REMOVES_PATHS @@ -1200,7 +1190,7 @@ restart_from_beginning: switch (type) { case MAP_ELEMENT_TYPE_PATH: if (gClearFootpath) { - cost = sub_6A67C0(x, y, mapElement->base_height, flags); + cost = footpath_remove_real(x * 32, y * 32, mapElement->base_height, flags); if (cost == MONEY32_UNDEFINED) return MONEY32_UNDEFINED; @@ -1457,7 +1447,7 @@ const uint8 map_element_lower_styles[5][32] = { { 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0D, 0x0E, 0x00 }, }; -static money32 sub_66397F(int flags, int x, int y, int height, int style, int selectionType) +static money32 map_set_land_height(int flags, int x, int y, int height, int style, int selectionType) { if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) != 0 && !gConfigCheat.build_in_pause_mode) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; @@ -1505,6 +1495,18 @@ static money32 sub_66397F(int flags, int x, int y, int height, int style, int se return ebx; } +void game_command_set_land_height(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) +{ + *ebx = map_set_land_height( + *ebx & 0xFF, + *eax & 0xFFFF, + *ecx & 0xFFFF, + *edx & 0xFF, + (*edx >> 8) & 0xFF, + *edi >> 5 + ); +} + money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int by, int selectionType) { money32 cost = 0; @@ -1541,7 +1543,7 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b height += 2; newStyle &= ~0x20; } - money32 tileCost = sub_66397F(flags, xi, yi, height, newStyle, selectionType); + money32 tileCost = map_set_land_height(flags, xi, yi, height, newStyle, selectionType); if (tileCost == MONEY32_UNDEFINED) return MONEY32_UNDEFINED; @@ -1605,7 +1607,7 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b height -= 2; newStyle &= ~0x20; } - money32 tileCost = sub_66397F(flags, xi, yi, height, newStyle, selectionType); + money32 tileCost = map_set_land_height(flags, xi, yi, height, newStyle, selectionType); if (tileCost == MONEY32_UNDEFINED) return MONEY32_UNDEFINED; diff --git a/src/world/map.h b/src/world/map.h index 78aec14373..eaed60b305 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -295,6 +295,7 @@ money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags); money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags); money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags); +void game_command_set_land_height(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); void game_command_remove_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); void game_command_remove_banner(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); diff --git a/src/world/sprite.c b/src/world/sprite.c index 1aec4516a4..501020d1ff 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -476,14 +476,13 @@ void money_effect_create(money32 value) return; mainViewport = mainWindow->viewport; - mapPosition.x = mainViewport->x + (mainViewport->width / 2); - mapPosition.y = mainViewport->y + (mainViewport->height / 2); - - int eax = mapPosition.x, ebx = mapPosition.y, ecx, edx, esi, edi, ebp; - RCT2_CALLFUNC_X(0x00688972, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - mapPosition.x = eax; - mapPosition.y = ebx; - + screen_get_map_xy( + mainViewport->x + (mainViewport->width / 2), + mainViewport->y + (mainViewport->height / 2), + &mapPosition.x, + &mapPosition.y, + NULL + ); if (mapPosition.x == (sint16)0x8000) return;