From e28d5e7d6bf7ee46faf58e8c6b00a89ac5ac2e6d Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 18 Apr 2016 18:31:27 +0200 Subject: [PATCH 1/7] decompile rot 0 --- src/paint/paint.c | 458 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 423 insertions(+), 35 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index 72ac7807a5..69774a6773 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -59,17 +59,151 @@ bool sub_98196C( uint16 z_offset, uint32 rotation ) { - int flags = RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098196C, uint32)[rotation], - x_offset | (bound_box_length_z << 8), - image_id, - y_offset, - z_offset, - bound_box_length_y, - bound_box_length_x, - rotation - ); + assert((uint16) bound_box_length_x == (sint16) bound_box_length_x); + assert((uint16) bound_box_length_y == (sint16) bound_box_length_y); + assert((uint16) z_offset == (sint16) z_offset); - return !(flags & (1 << 8)); + RCT2_GLOBAL(0xF1AD28, paint_struct*) = 0; + RCT2_GLOBAL(0xF1AD2C, uint32) = 0; + + //Not a paint struct but something similar + paint_struct *ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + + if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { + return false; + } + + ps->image_id = image_id; + + uint32 image_element = image_id & 0x7FFFF; + rct_g1_element *g1Element = gfx_get_g1_element(image_element); + + rct_xyz16 coord_3d = { + .x = x_offset, // ax + .y = y_offset, // cx + .z = z_offset + }; + + rct_xyz16 boundBox = { + .x = bound_box_length_x, // di + .y = bound_box_length_y, // si + .z = bound_box_length_z, + }; + + switch (rotation) { + case 0: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, MAP_ELEMENT_DIRECTION_WEST); + + boundBox.x--; + boundBox.y--; + rotate_map_coordinates(&boundBox.x, &boundBox.y, MAP_ELEMENT_DIRECTION_WEST); + break; + + case 1: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, MAP_ELEMENT_DIRECTION_SOUTH); + + boundBox.x--; + rotate_map_coordinates(&boundBox.x, &boundBox.y, MAP_ELEMENT_DIRECTION_SOUTH); + break; + + case 2: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, MAP_ELEMENT_DIRECTION_EAST); + rotate_map_coordinates(&boundBox.x, &boundBox.y, MAP_ELEMENT_DIRECTION_EAST); + break; + + case 3: + rotate_map_coordinates(&coord_3d.x, &coord_3d.y, MAP_ELEMENT_DIRECTION_NORTH); + + boundBox.y--; + rotate_map_coordinates(&boundBox.x, &boundBox.y, MAP_ELEMENT_DIRECTION_NORTH); + break; + } + + coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); + coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); + + ps->bound_box_x_end = coord_3d.x + boundBox.x; + ps->bound_box_y_end = coord_3d.y + boundBox.y; + + // TODO: check whether this is right. edx is ((bound_box_length_z + z_offset) << 16 | z_offset) + ps->bound_box_z = coord_3d.z; + ps->bound_box_z_end = (boundBox.z + coord_3d.z); + + rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); + + ps->x = map.x; + ps->y = map.y; + + sint16 left = map.x + g1Element->x_offset; + sint16 bottom = map.y + g1Element->y_offset; + + sint16 right = left + g1Element->width; + sint16 top = bottom + g1Element->height; + + RCT2_GLOBAL(0xF1AD1C, sint16) = left; + RCT2_GLOBAL(0xF1AD1E, sint16) = bottom; + + 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; + + ps->flags = 0; + ps->bound_box_x = coord_3d.x; + ps->bound_box_y = coord_3d.y; + 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*); + + sint32 edi; + switch (rotation) { + case 0: + edi = coord_3d.y + coord_3d.x; + break; + + case 1: + edi = coord_3d.y - coord_3d.x + 0x2000; + break; + + case 2: + edi = -(coord_3d.y + coord_3d.x) + 0x4000; + break; + + case 3: + edi = coord_3d.x - coord_3d.y + 0x2000; + break; + } + + if (edi < 0) { + edi = 0; + } + + edi /= 32; + edi = min(edi, 0x1FF); // 511 + + ps->var_18 = edi; + + paint_struct *old_ps = RCT2_ADDRESS(0x00F1A50C, paint_struct*)[edi]; + RCT2_ADDRESS(0x00F1A50C, paint_struct*)[edi] = ps; + ps->next_quadrant_ps = old_ps; + + if ((uint16)edi < RCT2_GLOBAL(0x00F1AD0C, uint32)) { + RCT2_GLOBAL(0x00F1AD0C, uint32) = edi; + } + + if ((uint16)edi > RCT2_GLOBAL(0x00F1AD10, uint32)) { + RCT2_GLOBAL(0x00F1AD10, uint32) = edi; + } + + RCT2_GLOBAL(0xEE7888, uint32) += 0x34; + + return true; } /** @@ -275,21 +409,142 @@ bool sub_98198C( sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X, uint16) = bound_box_offset_x; - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y, uint16) = bound_box_offset_y; - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z, uint16) = bound_box_offset_z; + assert((uint16) bound_box_length_x == (sint16) bound_box_length_x); + assert((uint16) bound_box_length_y == (sint16) bound_box_length_y); + assert((uint16) z_offset == (sint16) z_offset); - int flags = RCT2_CALLPROC_X(RCT2_ADDRESS(0x0098198C, uint32)[rotation], - x_offset | (bound_box_length_z << 8), - image_id, - y_offset, - z_offset, - bound_box_length_y, - bound_box_length_x, - rotation - ); + RCT2_GLOBAL(0xF1AD28, uint32) = 0; + RCT2_GLOBAL(0xF1AD2C, uint32) = 0; - return !(flags & (1 << 8)); + //Not a paint struct but something similar + paint_struct *ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { + return false; + } + + ps->image_id = image_id; + + uint32 image_element = image_id & 0x7FFFF; + rct_g1_element *g1Element = gfx_get_g1_element(image_element); + + rct_xyz16 coord_3d = { + .x = x_offset, // ax + .y = y_offset, // cx + .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; + } + + coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); + coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); + + rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); + + ps->x = map.x; + ps->y = map.y; + + int left = map.x + g1Element->x_offset; + int bottom = map.y + g1Element->y_offset; + + int right = left + g1Element->width; + int top = bottom + g1Element->height; + + RCT2_GLOBAL(0xF1AD1C, uint16) = left; + RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; + + 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, + }; + + rct_xyz16 boundBox = { + .x = bound_box_length_x, + .y = bound_box_length_y, + .z = bound_box_length_z + }; + + sint16 temp; + 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; + } + + 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_z = boundBoxOffset.z; + ps->bound_box_z_end = boundBoxOffset.z + boundBox.z; + + ps->flags = 0; + ps->bound_box_x = boundBoxOffset.x + RCT2_GLOBAL(0x009DE568, 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->map_x = RCT2_GLOBAL(0x9DE574, uint16); + ps->map_y = RCT2_GLOBAL(0x9DE576, uint16); + ps->mapElement = RCT2_GLOBAL(0x9DE578, rct_map_element*); + + RCT2_GLOBAL(0xEE7888, paint_struct*) += 0x34; + RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; + + return true; } /** @@ -317,20 +572,153 @@ bool sub_98199C( sint16 bound_box_offset_x, uint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation ) { - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_X, uint16) = bound_box_offset_x; - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Y, uint16) = bound_box_offset_y; - RCT2_GLOBAL(RCT2_ADDRESS_PAINT_BOUNDBOX_OFFSET_Z, uint16) = bound_box_offset_z; + assert((uint16) bound_box_length_x == (sint16) bound_box_length_x); + assert((uint16) bound_box_length_y == (sint16) bound_box_length_y); + assert((uint16) z_offset == (sint16) z_offset); - int flags = RCT2_CALLPROC_X(RCT2_ADDRESS(0x98199C, uint32_t)[rotation], - x_offset | (bound_box_length_z << 8), - image_id, - y_offset, - z_offset, - bound_box_length_y, - bound_box_length_x, - rotation); + if (RCT2_GLOBAL(0xF1AD28, uint32) == 0) { + return sub_98197C( + image_id, + x_offset, y_offset, + bound_box_length_x, bound_box_length_y, bound_box_length_z, + z_offset, + bound_box_offset_x, bound_box_offset_y, bound_box_offset_z, + rotation + ) == 1; + } - return !(flags & (1 << 8)); + //Not a paint struct but something similar + paint_struct *ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { + return false; + } + + ps->image_id = image_id; + + uint32 image_element = image_id & 0x7FFFF; + rct_g1_element *g1Element = gfx_get_g1_element(image_element); + + rct_xyz16 coord_3d = { + .x = x_offset, // ax + .y = y_offset, // cx + .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; + } + + coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); + coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); + + rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); + + ps->x = map.x; + ps->y = map.y; + + int left = map.x + g1Element->x_offset; + int bottom = map.y + g1Element->y_offset; + + int right = left + g1Element->width; + int top = bottom + g1Element->height; + + RCT2_GLOBAL(0xF1AD1C, uint16) = left; + RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; + + 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, + }; + + rct_xyz16 boundBox = { + .x = bound_box_length_x, + .y = bound_box_length_y, + .z = bound_box_length_z + }; + + sint16 temp; + 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; + } + + 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_z = boundBoxOffset.z; + ps->bound_box_z_end = boundBoxOffset.z + boundBox.z; + + ps->flags = 0; + ps->bound_box_x = boundBoxOffset.x + RCT2_GLOBAL(0x009DE568, 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->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; + + RCT2_GLOBAL(0xEE7888, paint_struct*) += 0x34; + RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; + + return true; } /** From a595b1fa96927f3df4772ec88fb5bdd4fd767c12 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Fri, 22 Apr 2016 20:08:29 +0200 Subject: [PATCH 2/7] Make 8c match 7c --- src/paint/paint.c | 156 ++++++++++++++++++++-------------------------- src/paint/paint.h | 2 +- 2 files changed, 70 insertions(+), 88 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index 69774a6773..f6f55f7d6d 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -161,6 +161,8 @@ bool sub_98196C( ps->map_y = RCT2_GLOBAL(0x9DE576, uint16); ps->mapElement = RCT2_GLOBAL(0x9DE578, rct_map_element*); + RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; + sint32 edi; switch (rotation) { case 0: @@ -285,17 +287,19 @@ bool sub_98197C( 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; + if (left >= dpi->x + dpi->width)return false; + if (bottom >= dpi->y + dpi->height)return false; - rct_xy16 boundBox = { + rct_xyz16 boundBox = { .x = bound_box_length_x, - .y = bound_box_length_y + .y = bound_box_length_y, + .z = bound_box_length_z }; - rct_xy16 boundBoxOffset = { + rct_xyz16 boundBoxOffset = { .x = bound_box_offset_x, - .y = bound_box_offset_y + .y = bound_box_offset_y, + .z = bound_box_offset_z }; // Unsure why rots 1 and 3 need to swap @@ -323,9 +327,8 @@ bool sub_98197C( } ps->bound_box_x_end = boundBox.x + boundBoxOffset.x + RCT2_GLOBAL(0x9DE568, sint16); - ps->bound_box_z = bound_box_offset_z; - int boundBoxZEnd = bound_box_length_z + bound_box_offset_z; - ps->bound_box_z_end = boundBoxZEnd; + 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(0x9DE568, sint16); @@ -398,7 +401,7 @@ bool sub_98197C( * @param bound_box_offset_x (0x009DEA52) * @param bound_box_offset_y (0x009DEA54) * @param bound_box_offset_z (0x009DEA56) - * @param rotation + * @param rotation (ebp) * @return (!CF) success */ bool sub_98198C( @@ -406,21 +409,20 @@ bool sub_98198C( 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); assert((uint16) bound_box_length_y == (sint16) bound_box_length_y); assert((uint16) z_offset == (sint16) z_offset); - RCT2_GLOBAL(0xF1AD28, uint32) = 0; + RCT2_GLOBAL(0xF1AD28, paint_struct*) = 0; RCT2_GLOBAL(0xF1AD2C, uint32) = 0; //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; @@ -428,28 +430,25 @@ bool sub_98198C( 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); @@ -467,18 +466,12 @@ bool sub_98198C( 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, @@ -486,64 +479,53 @@ bool sub_98198C( .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*); - 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 fff2e0c34c..3466dfd5bf 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -89,7 +89,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, uint16 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 paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y); 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 3/7] 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); From 66d5c74a6615fb2561b56fd27cee273a7b9e81c4 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 8 May 2016 18:29:07 +0200 Subject: [PATCH 4/7] Add markers for indicating to-be-extracted function --- src/paint/paint.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/paint/paint.c b/src/paint/paint.c index 4462849990..a4ac1f2641 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -236,6 +236,8 @@ bool sub_98197C( RCT2_GLOBAL(0xF1AD28, paint_struct*) = 0; RCT2_GLOBAL(0xF1AD2C, uint32) = 0; + // START FUNCTION EXTRACTION + //Not a paint struct but something similar paint_struct* ps = RCT2_GLOBAL(0xEE7888, paint_struct*); @@ -341,6 +343,8 @@ bool sub_98197C( ps->map_y = RCT2_GLOBAL(0x9DE576, uint16); ps->mapElement = RCT2_GLOBAL(0x9DE578, rct_map_element*); + // END FUNCTION EXTRACTION + RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; rct_xy16 attach = { From bbbe0c1ffb87012a80abd397a5bdd442b902bfa2 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 8 May 2016 22:00:39 +0200 Subject: [PATCH 5/7] Extract paint struct creation --- src/paint/paint.c | 422 ++++++++++++---------------------------------- 1 file changed, 112 insertions(+), 310 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index a4ac1f2641..43c247f1a6 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -39,6 +39,100 @@ void painter_setup() { RCT2_GLOBAL(0xF1AD24, uint32) = 0; } +paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBox, rct_xyz16 boundBoxOffset, uint8 rotation) +{ + + //Not a paint struct but something similar + paint_struct * ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + + if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32))return NULL; + + ps->image_id = image_id; + + uint32 image_element = image_id & 0x7FFFF; + rct_g1_element * g1Element = gfx_get_g1_element(image_element); + + switch (rotation) { + case 0: + rotate_map_coordinates(&offset.x, &offset.y, 0); + break; + case 1: + rotate_map_coordinates(&offset.x, &offset.y, 3); + break; + case 2: + rotate_map_coordinates(&offset.x, &offset.y, 2); + break; + case 3: + rotate_map_coordinates(&offset.x, &offset.y, 1); + break; + } + offset.x += RCT2_GLOBAL(0x9DE568, sint16); + offset.y += RCT2_GLOBAL(0x9DE56C, sint16); + + rct_xy16 map = coordinate_3d_to_2d(&offset, rotation); + + ps->x = map.x; + ps->y = map.y; + + int left = map.x + g1Element->x_offset; + int bottom = map.y + g1Element->y_offset; + + int right = left + g1Element->width; + int top = bottom + g1Element->height; + + RCT2_GLOBAL(0xF1AD1C, uint16) = left; + RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; + + rct_drawpixelinfo * dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); + + if (right <= dpi->x)return NULL; + if (top <= dpi->y)return NULL; + if (left >= dpi->x + dpi->width)return NULL; + if (bottom >= dpi->y + dpi->height)return NULL; + + + // Unsure why rots 1 and 3 need to swap + switch (rotation) { + 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(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(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*); + + return ps; +} + /** * rct2: 0x006861AC, 0x00686337, 0x006864D0, 0x0068666B, 0x0098196C * @@ -236,114 +330,14 @@ bool sub_98197C( RCT2_GLOBAL(0xF1AD28, paint_struct*) = 0; RCT2_GLOBAL(0xF1AD2C, uint32) = 0; - // START FUNCTION EXTRACTION + rct_xyz16 offset = {.x = x_offset, .y = y_offset, .z = z_offset}; + rct_xyz16 boundBox = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; + rct_xyz16 boundBoxOffset = {.x = bound_box_offset_x, .y = bound_box_offset_y, .z = bound_box_offset_z}; + paint_struct * ps = sub_9819_c(image_id, offset, boundBox, boundBoxOffset, rotation); - //Not a paint struct but something similar - paint_struct* ps = RCT2_GLOBAL(0xEE7888, paint_struct*); - - if ((uint32)ps >= RCT2_GLOBAL(0xEE7880, uint32))return false; - - ps->image_id = image_id; - - uint32 image_element = image_id & 0x7FFFF; - rct_g1_element *g1Element = gfx_get_g1_element(image_element); - - rct_xyz16 coord_3d = { - .x = x_offset, - .y = y_offset, - .z = z_offset - }; - - switch (rotation) { - 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; + if (ps == NULL) { + return NULL; } - coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); - coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); - - rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); - - ps->x = map.x; - ps->y = map.y; - - int left = map.x + g1Element->x_offset; - int bottom = map.y + g1Element->y_offset; - - int right = left + g1Element->width; - int top = bottom + g1Element->height; - - RCT2_GLOBAL(0xF1AD1C, uint16) = left; - RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; - - 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 boundBox = { - .x = bound_box_length_x, - .y = bound_box_length_y, - .z = bound_box_length_z - }; - - 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--; - 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(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(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*); - - // END FUNCTION EXTRACTION RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; @@ -423,110 +417,14 @@ bool sub_98198C( RCT2_GLOBAL(0xF1AD28, paint_struct*) = 0; RCT2_GLOBAL(0xF1AD2C, uint32) = 0; - //Not a paint struct but something similar - paint_struct* ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + rct_xyz16 offset = {.x = x_offset, .y = y_offset, .z = z_offset}; + rct_xyz16 boundBox = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; + rct_xyz16 boundBoxOffset = {.x = bound_box_offset_x, .y = bound_box_offset_y, .z = bound_box_offset_z}; + paint_struct * ps = sub_9819_c(image_id, offset, boundBox, boundBoxOffset, rotation); - if ((uint32)ps >= RCT2_GLOBAL(0xEE7880, uint32))return false; - - ps->image_id = image_id; - - uint32 image_element = image_id & 0x7FFFF; - rct_g1_element *g1Element = gfx_get_g1_element(image_element); - - rct_xyz16 coord_3d = { - .x = x_offset, - .y = y_offset, - .z = z_offset - }; - - switch (rotation) { - 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; + if (ps == NULL) { + return NULL; } - coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); - coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); - - rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); - - ps->x = map.x; - ps->y = map.y; - - int left = map.x + g1Element->x_offset; - int bottom = map.y + g1Element->y_offset; - - int right = left + g1Element->width; - int top = bottom + g1Element->height; - - RCT2_GLOBAL(0xF1AD1C, uint16) = left; - RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; - - 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 boundBox = { - .x = bound_box_length_x, - .y = bound_box_length_y, - .z = bound_box_length_z - }; - - 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--; - 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(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(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*); RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; RCT2_GLOBAL(0xEE7888, paint_struct*)++; @@ -573,110 +471,14 @@ bool sub_98199C( ) == 1; } - //Not a paint struct but something similar - paint_struct* ps = RCT2_GLOBAL(0xEE7888, paint_struct*); + rct_xyz16 offset = {.x = x_offset, .y = y_offset, .z = z_offset}; + rct_xyz16 boundBox = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; + rct_xyz16 boundBoxOffset = {.x = bound_box_offset_x, .y = bound_box_offset_y, .z = bound_box_offset_z}; + paint_struct * ps = sub_9819_c(image_id, offset, boundBox, boundBoxOffset, rotation); - if ((uint32)ps >= RCT2_GLOBAL(0xEE7880, uint32))return false; - - ps->image_id = image_id; - - uint32 image_element = image_id & 0x7FFFF; - rct_g1_element *g1Element = gfx_get_g1_element(image_element); - - rct_xyz16 coord_3d = { - .x = x_offset, - .y = y_offset, - .z = z_offset - }; - - switch (rotation) { - 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; + if (ps == NULL) { + return NULL; } - coord_3d.x += RCT2_GLOBAL(0x9DE568, sint16); - coord_3d.y += RCT2_GLOBAL(0x9DE56C, sint16); - - rct_xy16 map = coordinate_3d_to_2d(&coord_3d, rotation); - - ps->x = map.x; - ps->y = map.y; - - int left = map.x + g1Element->x_offset; - int bottom = map.y + g1Element->y_offset; - - int right = left + g1Element->width; - int top = bottom + g1Element->height; - - RCT2_GLOBAL(0xF1AD1C, uint16) = left; - RCT2_GLOBAL(0xF1AD1E, uint16) = bottom; - - 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 boundBox = { - .x = bound_box_length_x, - .y = bound_box_length_y, - .z = bound_box_length_z - }; - - 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--; - 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(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(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 *old_ps = RCT2_GLOBAL(0xF1AD28, paint_struct*); old_ps->var_20 = ps; From b112178c6122cc8993f24d10f9b4fc95efe852a9 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sun, 8 May 2016 23:34:58 +0200 Subject: [PATCH 6/7] Replace outdated call to sub_98196C --- src/paint/map_element/map_element.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/paint/map_element/map_element.c b/src/paint/map_element/map_element.c index 48f993e7dc..0d854fbbf8 100644 --- a/src/paint/map_element/map_element.c +++ b/src/paint/map_element/map_element.c @@ -137,16 +137,7 @@ static void blank_tiles_paint(int x, int y) RCT2_GLOBAL(0x9DE568, sint16) = x; RCT2_GLOBAL(0x9DE56C, sint16) = y; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8_t) = VIEWPORT_INTERACTION_ITEM_NONE; - RCT2_CALLPROC_X( - (int)RCT2_ADDRESS(0x98196C, uint32_t*)[get_current_rotation()], - 0xFF00, - 3123, - y & 0xFF00, - 16, - 32, - 32, - get_current_rotation() - ); + sub_98196C(3123, 0, 0, 32, 32, -1, 16, get_current_rotation()); } /** From 019155a4961635559c427a446cb1e1b3b54d2cce Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 11 May 2016 18:40:13 +0100 Subject: [PATCH 7/7] Apply suggestions from PR --- src/paint/paint.c | 73 ++++++++++++++++++++++++----------------------- src/paint/paint.h | 8 +++--- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index 43c247f1a6..e054232a4e 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -39,10 +39,11 @@ void painter_setup() { RCT2_GLOBAL(0xF1AD24, uint32) = 0; } -paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBox, rct_xyz16 boundBoxOffset, uint8 rotation) +/** + * Extracted from 0x0098196c, 0x0098197c, 0x0098198c, 0x0098199c + */ +paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBoxSize, rct_xyz16 boundBoxOffset, uint8 rotation) { - - //Not a paint struct but something similar paint_struct * ps = RCT2_GLOBAL(0xEE7888, paint_struct*); if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32))return NULL; @@ -91,34 +92,34 @@ paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBox, if (bottom >= dpi->y + dpi->height)return NULL; - // Unsure why rots 1 and 3 need to swap + // This probably rotates the variables so they're relative to rotation 0. switch (rotation) { case 0: - boundBox.x--; - boundBox.y--; + boundBoxSize.x--; + boundBoxSize.y--; rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 0); - rotate_map_coordinates(&boundBox.x, &boundBox.y, 0); + rotate_map_coordinates(&boundBoxSize.x, &boundBoxSize.y, 0); break; case 1: - boundBox.x--; + boundBoxSize.x--; rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 3); - rotate_map_coordinates(&boundBox.x, &boundBox.y, 3); + rotate_map_coordinates(&boundBoxSize.x, &boundBoxSize.y, 3); break; case 2: - rotate_map_coordinates(&boundBox.x, &boundBox.y, 2); + rotate_map_coordinates(&boundBoxSize.x, &boundBoxSize.y, 2); rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 2); break; case 3: - boundBox.y--; - rotate_map_coordinates(&boundBox.x, &boundBox.y, 1); + boundBoxSize.y--; + rotate_map_coordinates(&boundBoxSize.x, &boundBoxSize.y, 1); rotate_map_coordinates(&boundBoxOffset.x, &boundBoxOffset.y, 1); break; } - ps->bound_box_x_end = boundBox.x + boundBoxOffset.x + RCT2_GLOBAL(0x9DE568, sint16); + ps->bound_box_x_end = boundBoxSize.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->bound_box_z_end = boundBoxOffset.z + boundBoxSize.z; + ps->bound_box_y_end = boundBoxSize.y + boundBoxOffset.y + RCT2_GLOBAL(0x009DE56C, sint16); ps->flags = 0; ps->bound_box_x = boundBoxOffset.x + RCT2_GLOBAL(0x9DE568, sint16); ps->bound_box_y = boundBoxOffset.y + RCT2_GLOBAL(0x009DE56C, sint16); @@ -144,9 +145,9 @@ paint_struct * sub_9819_c(uint32 image_id, rct_xyz16 offset, rct_xyz16 boundBox, * @param bound_box_length_z (ah) * @param z_offset (dx) * @param rotation (ebp) - * @return (!CF) success + * @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1) */ -bool sub_98196C( +paint_struct * 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, @@ -164,7 +165,7 @@ bool sub_98196C( paint_struct *ps = RCT2_GLOBAL(0xEE7888, paint_struct*); if ((uint32) ps >= RCT2_GLOBAL(0xEE7880, uint32)) { - return false; + return NULL; } ps->image_id = image_id; @@ -239,10 +240,10 @@ bool sub_98196C( 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; + if (right <= dpi->x) return NULL; + if (top <= dpi->y) return NULL; + if (left >= (dpi->x + dpi->width)) return NULL; + if (bottom >= (dpi->y + dpi->height)) return NULL; ps->flags = 0; ps->bound_box_x = coord_3d.x; @@ -299,7 +300,7 @@ bool sub_98196C( RCT2_GLOBAL(0xEE7888, uint32) += 0x34; - return true; + return ps; } /** @@ -316,9 +317,9 @@ bool sub_98196C( * @param bound_box_offset_y (0x009DEA54) * @param bound_box_offset_z (0x009DEA56) * @param rotation (ebp) - * @return (!CF) success + * @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1) */ -bool sub_98197C( +paint_struct * 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, @@ -331,9 +332,9 @@ bool sub_98197C( RCT2_GLOBAL(0xF1AD2C, uint32) = 0; rct_xyz16 offset = {.x = x_offset, .y = y_offset, .z = z_offset}; - rct_xyz16 boundBox = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; + rct_xyz16 boundBoxSize = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; rct_xyz16 boundBoxOffset = {.x = bound_box_offset_x, .y = bound_box_offset_y, .z = bound_box_offset_z}; - paint_struct * ps = sub_9819_c(image_id, offset, boundBox, boundBoxOffset, rotation); + paint_struct * ps = sub_9819_c(image_id, offset, boundBoxSize, boundBoxOffset, rotation); if (ps == NULL) { return NULL; @@ -382,7 +383,7 @@ bool sub_98197C( } RCT2_GLOBAL(0xEE7888, paint_struct*)++; - return true; + return ps; } /** @@ -400,9 +401,9 @@ bool sub_98197C( * @param bound_box_offset_y (0x009DEA54) * @param bound_box_offset_z (0x009DEA56) * @param rotation (ebp) - * @return (!CF) success + * @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1) */ -bool sub_98198C( +paint_struct * 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, @@ -418,9 +419,9 @@ bool sub_98198C( RCT2_GLOBAL(0xF1AD2C, uint32) = 0; rct_xyz16 offset = {.x = x_offset, .y = y_offset, .z = z_offset}; - rct_xyz16 boundBox = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; + rct_xyz16 boundBoxSize = {.x = bound_box_length_x, .y = bound_box_length_y, .z = bound_box_length_z}; rct_xyz16 boundBoxOffset = {.x = bound_box_offset_x, .y = bound_box_offset_y, .z = bound_box_offset_z}; - paint_struct * ps = sub_9819_c(image_id, offset, boundBox, boundBoxOffset, rotation); + paint_struct * ps = sub_9819_c(image_id, offset, boundBoxSize, boundBoxOffset, rotation); if (ps == NULL) { return NULL; @@ -428,7 +429,7 @@ bool sub_98198C( RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; RCT2_GLOBAL(0xEE7888, paint_struct*)++; - return true; + return ps; } /** @@ -446,9 +447,9 @@ bool sub_98198C( * @param bound_box_offset_y (0x009DEA54) * @param bound_box_offset_z (0x009DEA56) * @param rotation (ebp) - * @return (!CF) success + * @return (ebp) paint_struct on success (CF == 0), NULL on failure (CF == 1) */ -bool sub_98199C( +paint_struct * 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, @@ -485,7 +486,7 @@ bool sub_98199C( RCT2_GLOBAL(0xF1AD28, paint_struct*) = ps; RCT2_GLOBAL(0xEE7888, paint_struct*)++; - return true; + return ps; } /** diff --git a/src/paint/paint.h b/src/paint/paint.h index da3454021a..0d9778d361 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -87,10 +87,10 @@ enum PAINT_STRUCT_FLAGS { 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, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); +paint_struct * 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); +paint_struct * 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); +paint_struct * 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); +paint_struct * 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);