diff --git a/src/interface/viewport.c b/src/interface/viewport.c index c9ee8da855..579d96882e 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -2665,22 +2665,25 @@ void sub_679074(rct_drawpixelinfo *dpi, int imageId, sint16 x, sint16 y) } RCT2_GLOBAL(0x9E3D08, uint32) = image.offset; - RCT2_GLOBAL(0x9E3D0C, uint32) = image.width; - RCT2_GLOBAL(0x9E3D10, uint32) = image.x_offset; - RCT2_GLOBAL(0x9E3D14, uint32) = image.flags; + RCT2_GLOBAL(0x9E3D0C, sint16) = image.width; + RCT2_GLOBAL(0x9E3D0C + 2, sint16) = image.height; + RCT2_GLOBAL(0x9E3D10, sint16) = image.x_offset; + RCT2_GLOBAL(0x9E3D10 + 2, sint16) = image.y_offset; + RCT2_GLOBAL(0x9E3D14, uint16) = image.flags; + RCT2_GLOBAL(0x9E3D14 + 2, uint16) = image.zoomed_offset; if (image.flags & 4) { // push edi y--; // ebp = edi; // esi = image.offset; - y += image.x_offset; + y += image.y_offset; - uint16 width = image.width; + uint16 height = image.height; RCT2_GLOBAL(RCT2_ADDRESS_Y_START_POINT_GLOBAL, uint32) = 0; - if (width % 2) { - width--; - if (width == 0) { + if (height % 2) { + height--; + if (height == 0) { return; } @@ -2690,7 +2693,7 @@ void sub_679074(rct_drawpixelinfo *dpi, int imageId, sint16 x, sint16 y) // TODO: (y = y/2?) y &= 0xFFFE; - RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) = width; + RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) = height; y -= dpi->y; if (y < 0) { @@ -2715,9 +2718,9 @@ void sub_679074(rct_drawpixelinfo *dpi, int imageId, sint16 x, sint16 y) } } - sint16 ax = image.width; + sint16 width = image.width; RCT2_GLOBAL(RCT2_ADDRESS_X_START_POINT_GLOBAL, sint16) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) = ax; + RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) = width; x += image.x_offset; x &= 0xFFFE; x -= dpi->x; @@ -2744,6 +2747,93 @@ void sub_679074(rct_drawpixelinfo *dpi, int imageId, sint16 x, sint16 y) RCT2_CALLPROC_X(0x00679788, 0, 0, 0, 0, image.offset, (int) dpi, (int) dpi); return; + } else { + // push edi + // ebp = edi; + //esi = image.offset; + uint32 esi = image.offset; + y += image.y_offset; + sint16 height = image.height; + if (height % 2) { + sint16 ebx = image.width; + height--; + + esi += ebx; + } + + if (height == 0) { + return; + } + + y &= 0xFFFE; + RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) = height; + y -= image.height; + if (y < 0) { + RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) += y; + if (RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) <= 0) { + return; + } + + y = -y; + esi += (y * image.width) & 0xFFFF; + y = 0; + } else { + // Do nothing? + } + + y += RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16); + y--; + + if (y > 0) { + RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) -= y; + if (RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) <= 0) { + return; + } + } + + sint16 ax = image.width; + RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) = ax; + RCT2_GLOBAL(0x009ABDAE, sint16) = 0; + x += image.x_offset; + x = floor2(x, 2); + x -= dpi->x; + + if (x < 0) { + RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) += x; + if (RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) <= 0) { + return; + } + + RCT2_GLOBAL(0x009ABDAE, sint16) -= x; + + esi -= x; + x = 0; + } + + + x += RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16); + x--; + if (x > 0) { + RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) -= x; + if (RCT2_GLOBAL(RCT2_ADDRESS_X_END_POINT_GLOBAL, sint16) <= 0) { + return; + } + + RCT2_GLOBAL(0x009ABDAE, sint16) += x; + } + + // Or is this the 'flags' part? + if (!(image.zoomed_offset & (1 << 1))) { + sint8 ah = (RCT2_GLOBAL(RCT2_ADDRESS_Y_END_POINT_GLOBAL, sint16) >> 8) & 0xFF; + int edx = RCT2_GLOBAL(0x009ABDAE, sint16); + int ebx = RCT2_GLOBAL(0x00EDF81C, uint32) = 0; + + // ah and edx don't seem to be used by this function... + RCT2_CALLPROC_X(0x00679662, 0, ebx, 0, 0, esi, 0, 0); + return; + } + + // loc_6795E4: } break;