mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #209 from duncanspumpkin/viewport_render
Viewport render
This commit is contained in:
commit
830f881f3c
|
@ -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;
|
||||
|
||||
|
@ -109,10 +111,72 @@ 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){
|
||||
//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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue