From 144470e5aac190f9ea6c596fb1e53355177036f0 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 11 Jul 2014 18:32:32 +0100 Subject: [PATCH 1/2] 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); } /** From 87fe239ac054a50973d5292cff03144ad64df465 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 11 Jul 2014 19:00:26 +0100 Subject: [PATCH 2/2] Switched to g_viewport_list --- src/viewport.c | 8 ++++++-- src/viewport.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/viewport.c b/src/viewport.c index d9abef260a..1b23c7c97f 100644 --- a/src/viewport.c +++ b/src/viewport.c @@ -29,6 +29,8 @@ #define RCT2_LAST_VIEWPORT (RCT2_GLOBAL(RCT2_ADDRESS_NEW_VIEWPORT_PTR, rct_viewport*) - 1) #define RCT2_NEW_VIEWPORT (RCT2_GLOBAL(RCT2_ADDRESS_NEW_VIEWPORT_PTR, rct_viewport*)) +rct_viewport* g_viewport_list = RCT2_ADDRESS(RCT2_ADDRESS_VIEWPORT_LIST, rct_viewport); + /** * * rct2: 0x006E6EAC @@ -54,7 +56,7 @@ void viewport_init_all() // Setting up viewports for (i = 0; i < 9; i++) - RCT2_FIRST_VIEWPORT[i].width = 0; + g_viewport_list[i].width = 0; RCT2_NEW_VIEWPORT = NULL; // ? @@ -90,7 +92,7 @@ void viewport_update_pointers() rct_viewport *viewport; rct_viewport **vp = &RCT2_NEW_VIEWPORT; - for (viewport = RCT2_FIRST_VIEWPORT; viewport <= RCT2_NEW_VIEWPORT; viewport++) + for (viewport = g_viewport_list; viewport <= RCT2_NEW_VIEWPORT; viewport++) if (viewport->width != 0) *vp++ = viewport; @@ -169,9 +171,11 @@ void viewport_render(rct_drawpixelinfo *dpi, rct_viewport *viewport, int left, i //cx int height = y_start - y_end; if (height > 384){ + //Paint RCT2_CALLPROC_X(0x00685CBF, x_end, y_end, height, x_start, (int)viewport, (int)dpi, y_end + 384); y_end += 384; } + //Paint RCT2_CALLPROC_X(0x00685CBF, x_end, y_end, height, x_start, (int)viewport, (int)dpi, y_start); } diff --git a/src/viewport.h b/src/viewport.h index 283b8d8f0d..3aa6e67b35 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -42,6 +42,9 @@ enum { VIEWPORT_FLAG_15 = (1 << 15) }; +// rct2: 0x014234BC +extern rct_viewport* g_viewport_list; + void viewport_init_all(); void viewport_create(rct_window *w, int x, int y, int width, int height, int ecx, int edx); void viewport_update_pointers();