From 144470e5aac190f9ea6c596fb1e53355177036f0 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 11 Jul 2014 18:32:32 +0100 Subject: [PATCH] Finished viewport_render decompile. --- src/viewport.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/viewport.c b/src/viewport.c index 35622551b5..d9abef260a 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -109,10 +109,70 @@ void viewport_update_position(rct_window *window) /** * * rct2: 0x00685C02 + * ax: left + * bx: top + * dx: right + * esi: viewport + * edi: dpi + * ebp: bottom */ void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, int top, int right, int bottom) { - RCT2_CALLPROC_X(0x00685C02, left , top, 0, right, (int)viewport, (int)dpi, bottom); + if (right <= viewport->x) return; + if (bottom <= viewport->y) return; + if (left >= viewport->x + viewport->width )return; + if (top >= viewport->y + viewport->height )return; + + //ax + int x_end = left; + + if (left < viewport->x){ + x_end = viewport->x; + } + + //dx + int x_start = right; + + if (right > viewport->x + viewport->width){ + x_start = viewport->x + viewport->width; + } + + //bx + int y_end = top; + + if (top < viewport->y){ + y_end = viewport->y; + } + + //bp + int y_start = bottom; + + if (bottom > viewport->y + viewport->height){ + y_start = viewport->y + viewport->height; + } + + x_end -= viewport->x; + x_start -= viewport->x; + y_end -= viewport->y; + y_start -= viewport->y; + + x_end <<= viewport->zoom; + x_start <<= viewport->zoom; + y_end <<= viewport->zoom; + y_start <<= viewport->zoom; + + x_end += viewport->view_x; + x_start += viewport->view_x; + y_end += viewport->view_y; + y_start += viewport->view_y; + + //cx + int height = y_start - y_end; + if (height > 384){ + RCT2_CALLPROC_X(0x00685CBF, x_end, y_end, height, x_start, (int)viewport, (int)dpi, y_end + 384); + y_end += 384; + } + RCT2_CALLPROC_X(0x00685CBF, x_end, y_end, height, x_start, (int)viewport, (int)dpi, y_start); } /**