From 6fc09f8ade323d561125ec4586792aff13699721 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 8 May 2016 14:25:20 +0200 Subject: [PATCH] Update sub_98199C to match 7c --- src/paint/paint.c | 135 ++++++++++++++++++++-------------------------- src/paint/paint.h | 2 +- 2 files changed, 58 insertions(+), 79 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index f6f55f7d6d..4462849990 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -551,7 +551,7 @@ bool sub_98199C( sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, - sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { assert((uint16) bound_box_length_x == (sint16) bound_box_length_x); @@ -570,10 +570,9 @@ bool sub_98199C( } //Not a paint struct but something similar - paint_struct *ps = RCT2_GLOBAL(0xEE7888, paint_struct*); - if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { - return false; - } + paint_struct* ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + + if ((uint32)ps >= RCT2_GLOBAL(0xEE7880, uint32))return false; ps->image_id = image_id; @@ -581,28 +580,25 @@ bool sub_98199C( rct_g1_element *g1Element = gfx_get_g1_element(image_element); rct_xyz16 coord_3d = { - .x = x_offset, // ax - .y = y_offset, // cx + .x = x_offset, + .y = y_offset, .z = z_offset }; switch (rotation) { - case 1: - coord_3d.x = -y_offset; - coord_3d.y = x_offset; - break; - - case 2: - coord_3d.x = -x_offset; - coord_3d.y = -y_offset; - break; - - case 3: - coord_3d.x = y_offset; - coord_3d.y = -x_offset; - break; + case 0: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 0); + break; + case 1: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 3); + break; + case 2: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 2); + break; + case 3: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, 1); + break; } - coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); @@ -620,18 +616,12 @@ bool sub_98199C( RCT2_GLOBAL(0xF1AD1C, uint16) = left; RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; - rct_drawpixelinfo *dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); + rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); - if (right <= dpi->x) return false; - if (top <= dpi->y) return false; - if (left >= (dpi->x + dpi->width)) return false; - if (bottom >= (dpi->y + dpi->height)) return false; - - rct_xyz16 boundBoxOffset = { - .x = bound_box_offset_x, - .y = bound_box_offset_y, - .z = bound_box_offset_z, - }; + if (right <= dpi->x)return false; + if (top <= dpi->y)return false; + if (left >= dpi->x + dpi->width)return false; + if (bottom >= dpi->y + dpi->height)return false; rct_xyz16 boundBox = { .x = bound_box_length_x, @@ -639,67 +629,56 @@ bool sub_98199C( .z = bound_box_length_z }; - sint16 temp; + rct_xyz16 boundBoxOffset = { + .x = bound_box_offset_x, + .y = bound_box_offset_y, + .z = bound_box_offset_z + }; + + // Unsure why rots 1 and 3 need to swap switch (rotation) { - case 0: - boundBox.x--; - boundBox.y--; - break; - - case 1: - boundBoxOffset.x = bound_box_offset_y; - boundBoxOffset.y = -bound_box_offset_x; - - boundBox.x--; - temp = boundBox.x; - boundBox.x = boundBox.y; - boundBox.y = temp; - boundBox.x = -boundBox.x; - break; - - case 2: - boundBoxOffset.x = -boundBoxOffset.x; - boundBoxOffset.y = -boundBoxOffset.y; - - boundBox.x = -boundBox.x; - boundBox.y = -boundBox.y; - break; - - case 3: - boundBoxOffset.x = bound_box_offset_y; - boundBoxOffset.y = -bound_box_offset_x; - - boundBox.y--; - temp = boundBox.x; - boundBox.x = boundBox.y; - boundBox.y = temp; - boundBox.y = -boundBox.y; - break; + case 0: + boundBox.x--; + boundBox.y--; + rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 0); + rotate_map_coordinates(&boundBox.x, &boundBox.y, 0); + break; + case 1: + boundBox.x--; + rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 3); + rotate_map_coordinates(&boundBox.x, &boundBox.y, 3); + break; + case 2: + rotate_map_coordinates(&boundBox.x, &boundBox.y, 2); + rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 2); + break; + case 3: + boundBox.y--; + rotate_map_coordinates(&boundBox.x, &boundBox.y, 1); + rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 1); + break; } - ps->bound_box_x_end = boundBox.x + boundBoxOffset.x + RCT2_GLOBAL(0x009DE568, sint16); - ps->bound_box_y_end = boundBox.y + boundBoxOffset.y + RCT2_GLOBAL(0x009DE56C, sint16); - - // TODO: check whether this is right. edx is ((bound_box_length_z + bound_box_offset_z) << 16 | bound_box_offset_z) + ps->bound_box_x_end = boundBox.x + boundBoxOffset.x + RCT2_GLOBAL(0x9DE568, sint16); ps->bound_box_z = boundBoxOffset.z; ps->bound_box_z_end = boundBoxOffset.z + boundBox.z; - + ps->bound_box_y_end = boundBox.y + boundBoxOffset.y + RCT2_GLOBAL(0x009DE56C, sint16); ps->flags = 0; - ps->bound_box_x = boundBoxOffset.x + RCT2_GLOBAL(0x009DE568, sint16); + ps->bound_box_x = boundBoxOffset.x + RCT2_GLOBAL(0x9DE568, sint16); ps->bound_box_y = boundBoxOffset.y + RCT2_GLOBAL(0x009DE56C, sint16); ps->attached_ps = NULL; ps->var_20 = NULL; ps->sprite_type = RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8); + ps->var_29 = RCT2_GLOBAL(0x9DE571, uint8); ps->map_x = RCT2_GLOBAL(0x9DE574, uint16); ps->map_y = RCT2_GLOBAL(0x9DE576, uint16); ps->mapElement = RCT2_GLOBAL(0x9DE578, rct_map_element*); - paint_struct *edi = RCT2_GLOBAL(0xF1AD28, paint_struct*); - edi->var_20 = ps; + paint_struct *old_ps = RCT2_GLOBAL(0xF1AD28, paint_struct*); + old_ps->var_20 = ps; - RCT2_GLOBAL(0xEE7888, paint_struct*) += 0x34; RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; - + RCT2_GLOBAL(0xEE7888, paint_struct*)++; return true; } diff --git a/src/paint/paint.h b/src/paint/paint.h index 3466dfd5bf..da3454021a 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -90,7 +90,7 @@ void painter_setup(); bool sub_98196C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, uint32 rotation); bool sub_98197C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); bool sub_98198C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); -bool sub_98199C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); +bool sub_98199C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, uint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y); bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y);