From ffaeca1a1cf844a60a4da3c278b116d487a95e59 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 12 Aug 2014 07:45:55 +0100 Subject: [PATCH] Zoomed land working. --- src/gfx.c | 57 ++++++++++++++++++++++++++-------------------------- src/gfx.h | 2 +- src/window.c | 3 ++- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index 00c2a86f34..297f6e2c61 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1022,44 +1022,45 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in rct_g1_element* g1_source = &(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[image_element]); //Zooming code has been integrated into main code but is not working. - if (dpi->zoom_level >= 1){ //These have not been tested - //something to do with zooming - if (dpi->zoom_level == 1){ - RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, 0); - return; - } - if (dpi->zoom_level == 2){ - RCT2_CALLPROC_X(0x0067DADA, 0, (int)g1_source, x, y, 0, (int)dpi, 0); - return; - } - RCT2_CALLPROC_X(0x0067FAAE, 0, (int)g1_source, x, y, 0, (int)dpi, 0); - return; - } - //if ( dpi->zoom_level && (g1_source->flags & (1<<4)) ){ - // rct_drawpixelinfo zoomed_dpi = { - // .bits = dpi->bits, - // .x = dpi->x >> 1, - // .y = dpi->y >> 1, - // .height = dpi->height>>1, - // .width = dpi->width>>1, - // .pitch = dpi->pitch,//In the actual code this is dpi->pitch but that doesn't seem correct. - // .zoom_level = dpi->zoom_level - 1 - // }; - // gfx_draw_sprite_palette_set(&zoomed_dpi, (image_type << 28) | (image_element - g1_source->zoomed_offset), x >> 1, y >> 1, palette_pointer, unknown_pointer); + //if (dpi->zoom_level >= 1){ //These have not been tested + // //something to do with zooming + // if (dpi->zoom_level == 1){ + // RCT2_CALLPROC_X(0x0067A28E, 0, image_id, x, y, 0, (int)dpi, 0); + // return; + // } + // if (dpi->zoom_level == 2){ + // RCT2_CALLPROC_X(0x0067DADA, 0, (int)g1_source, x, y, 0, (int)dpi, 0); + // return; + // } + // RCT2_CALLPROC_X(0x0067FAAE, 0, (int)g1_source, x, y, 0, (int)dpi, 0); // return; //} - + if ( dpi->zoom_level && (g1_source->flags & (1<<4)) ){ + rct_drawpixelinfo zoomed_dpi = { + .bits = dpi->bits, + .x = ((uint16)dpi->x) >> 1, + .y = ((uint16)dpi->y) >> 1, + .height = dpi->height>>1, + .width = dpi->width>>1, + .pitch = dpi->pitch, + .zoom_level = dpi->zoom_level - 1 + }; + gfx_draw_sprite_palette_set(&zoomed_dpi, (image_type << 28) | (image_element - g1_source->zoomed_offset), x >> 1, y >> 1, palette_pointer, unknown_pointer); + return; + } + if ( dpi->zoom_level && (g1_source->flags & (1<<5)) ){ return; } - + //Disable all buggy code + if (dpi->zoom_level)return; //Its used super often so we will define it to a seperate variable. int zoom_level = dpi->zoom_level; //This will be the height of the drawn image int height = g1_source->height >> zoom_level; //This is the start y coordinate on the destination - sint16 dest_start_y = y - dpi->y + g1_source->y_offset; + sint16 dest_start_y = y - ((uint16)dpi->y) + g1_source->y_offset; //This is the start y coordinate on the source int source_start_y = 0; @@ -1094,7 +1095,7 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in //This is the source start x coordinate int source_start_x = 0; //This is the destination start x coordinate - sint16 dest_start_x = x - dpi->x + g1_source->x_offset; + sint16 dest_start_x = x - ((uint16)dpi->x) + g1_source->x_offset; if (dest_start_x < 0){ //If the destination is negative reduce the width diff --git a/src/gfx.h b/src/gfx.h index 009a7bfa65..476f7420ac 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -43,7 +43,7 @@ typedef struct { sint16 x_offset; // 0x08 sint16 y_offset; // 0x0A uint16 flags; // 0x0C - sint16 zoomed_offset; // 0x0E + uint16 zoomed_offset; // 0x0E } rct_g1_element; enum{ diff --git a/src/window.c b/src/window.c index 569463783c..fe9363d2d4 100644 --- a/src/window.c +++ b/src/window.c @@ -1343,7 +1343,8 @@ void window_bubble_list_item(rct_window* w, int item_position){ void window_resize_gui(int width, int height) { if (RCT2_GLOBAL(0x9DEA68, uint8) & 0xE){ - return window_resize_gui_scenario_editor(width, height); + window_resize_gui_scenario_editor(width, height); + return; } rct_window* mainWind = window_get_main(); if (mainWind){