1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01:00

Trying to find cause of subtle bug

This commit is contained in:
Duncan Frost
2014-08-24 14:52:38 +01:00
parent d095dce810
commit 3b2fa2ddce
3 changed files with 26 additions and 17 deletions

View File

@@ -168,7 +168,7 @@ int map_element_height(int x, int y)
// Remove the extra height bit
slope &= 0xF;
uint8 quad, quad_extra; // which quadrant the element is in?
sint8 quad, quad_extra; // which quadrant the element is in?
// quad_extra is for extra height tiles
uint8 xl, yl; // coordinates across this tile
@@ -198,7 +198,7 @@ int map_element_height(int x, int y)
quad = TILE_SIZE - yl - xl;
break;
case 8: // NW corner up
quad = xl - yl;
quad = yl - xl;
break;
}
// If the element is in the quadrant with the slope, raise its height
@@ -241,7 +241,7 @@ int map_element_height(int x, int y)
break;
case 14: // NE corner down
quad_extra = (TILE_SIZE - xl) + (TILE_SIZE - yl);
quad = TILE_SIZE - yl - xl;
quad = TILE_SIZE - yl - xl - 1;
break;
}
@@ -255,7 +255,6 @@ int map_element_height(int x, int y)
// so we move *down* the slope
if (quad < 0) {
height += quad / 2;
height += 0xFF00;
}
}

View File

@@ -24,8 +24,8 @@
#include "rct2.h"
typedef struct {
uint8 slope;
uint8 terrain;
uint8 slope; //4
uint8 terrain; //5
uint8 grass_length;
uint8 ownership;
} rct_map_element_surface_properties;
@@ -92,10 +92,10 @@ typedef union {
* size: 0x08
*/
typedef struct {
uint8 type;
uint8 flags;
uint8 base_height;
uint8 clearance_height;
uint8 type; //0
uint8 flags; //1
uint8 base_height; //2
uint8 clearance_height; //3
rct_map_element_properties properties;
} rct_map_element;

View File

@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <assert.h>
#include "addresses.h"
#include "config.h"
#include "gfx.h"
@@ -221,25 +222,32 @@ void viewport_update_pointers()
}
void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){
//RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, &ecx, &curr_rotation, (int*)&window, (int*)&viewport, &ebp);
int start_x = *x;
int start_y = *y;
int eax, ebx, ecx = 0;
int eax = start_x, ebx, ecx = 0;
switch (curr_rotation){
case 0:
for (int i = 0; i < 6; ++i){
int edx = start_x / 2;
eax = -start_x;
eax = -start_x / 2;
eax += start_y;
ebx = start_y + edx;
eax += ecx;
ebx += ecx;
int __eax = eax, __ebx = 0, __ecx = ebx, __edx = 0, __edi= 0, __esi = 0, __ebp = 0;
RCT2_CALLFUNC_X(0x00662783, &__eax, &__ebx, &__ecx, &__edx, &__esi, &__edi, &__ebp);
ecx = map_element_height((0xFFFF) & eax, (0xFFFF) & ebx);
ecx = map_element_height((0xFFFF) & eax, (0xFFFF) & ebx);
assert(ecx == __edx);
}
break;
case 1:
for (int i = 0; i < 6; ++i){
int edx = start_x / 2;
eax = -start_x;
eax = -start_x / 2;
eax -= start_y;
ebx = start_y - edx;
eax -= ecx;
@@ -250,7 +258,7 @@ void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){
case 2:
for (int i = 0; i < 6; ++i){
int edx = start_x / 2;
eax -= start_y;
eax = start_x / 2 - start_y;
ebx = -start_y;
ebx -= edx;
eax -= ecx;
@@ -261,7 +269,7 @@ void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){
case 3:
for (int i = 0; i < 6; ++i){
int edx = start_x / 2;
eax += start_y;
eax = start_x / 2 + start_y;
ebx = -start_y;
ebx += edx;
eax += ecx;
@@ -272,6 +280,10 @@ void sub_689174(sint16* x, sint16* y, uint8 curr_rotation){
}
*x = eax;
*y = ebx;
int _eax = start_x, _ebx = start_y, _ecx, _edx = curr_rotation, _esi, _edi, _ebp;
RCT2_CALLFUNC_X(0x00689174, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp);
assert(*x == (sint16)_eax);
assert(*y == (sint16)_ebx);
}
/**
@@ -307,9 +319,7 @@ void viewport_update_position(rct_window *window)
sint16 y = viewport->view_height / 2 + window->saved_view_y;
int curr_rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32);
int ecx = 0, ebp;
sub_689174(&x, &y, curr_rotation);
//RCT2_CALLFUNC_X(0x00689174, (int*)&x, (int*)&y, &ecx, &curr_rotation, (int*)&window, (int*)&viewport, &ebp);
RCT2_CALLPROC_X(0x006E7A15, x, y, 0, 0, (int)window, (int)viewport, 0);