diff --git a/src/gfx.c b/src/gfx.c index 7f35f83f55..3c568c6f6b 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -647,7 +647,7 @@ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short ri * image. */ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, uint8* source_pointer, uint8* dest_pointer, rct_g1_element* source_image, rct_drawpixelinfo *dest_dpi, int height, int width, int image_type){ - uint8 zoom_level = dest_dpi->zoom_level + 1; + uint8 zoom_level = dest_dpi->zoom_level; //Requires use of palette? if (image_type & IMAGE_TYPE_USE_PALETTE){ @@ -655,12 +655,12 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui if (unknown_pointer!= NULL){ //Not tested. I can't actually work out when this code runs. unknown_pointer += source_pointer - source_image->offset;// RCT2_GLOBAL(0x9E3CE0, uint32); - for (; height > 0; height -= zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; - uint8* next_unknown_pointer = unknown_pointer + source_image->width*zoom_level; + for (; height > 0; height -= (1<width << zoom_level; + uint8* next_unknown_pointer = unknown_pointer + source_image->width << zoom_level; uint8* next_dest_pointer = dest_pointer + dest_dpi->width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, source_pointer+=zoom_level, unknown_pointer+=zoom_level, dest_pointer++){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; height -= zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; + for (; height > 0; height -= (1<width<width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, source_pointer+= zoom_level, dest_pointer++){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; height -= zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; + for (; height > 0; height -= (1<width<width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, source_pointer += zoom_level, dest_pointer++){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1<flags & G1_FLAG_BMP)){//Not tested - for (; height > 0; height-=zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; + for (; height > 0; height-=(1<width<width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, dest_pointer++, source_pointer += zoom_level){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1<offset; - for (; height > 0; height -= zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; - uint8* next_unknown_pointer = unknown_pointer + source_image->width*zoom_level; + for (; height > 0; height -= (1<width<width<width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, dest_pointer++, source_pointer += zoom_level, unknown_pointer += zoom_level){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; height -= zoom_level){ - uint8* next_source_pointer = source_pointer + source_image->width*zoom_level; + for (; height > 0; height -= (1<width<width + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_level, dest_pointer++, source_pointer += zoom_level){ + for (int no_pixels = width; no_pixels > 0; no_pixels -= (1<zoom_level + 1; + int zoom_level = dpi->zoom_level; uint8* next_source_pointer; uint8* next_dest_pointer = dest_bits_pointer; //For every line in the image - for (int y = source_y_start; y < (height + source_y_start); y += zoom_level){ + for (int y = source_y_start; y < (height + source_y_start); y += (1< 0){ //Since the start is positive //We need to move the drawing surface to the correct position - dest_pointer += x_start / zoom_level; + dest_pointer += x_start >> zoom_level; } else{ //If the start is negative we require to remove part of the image. @@ -838,7 +838,7 @@ void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_point //Finally after all those checks, copy the image onto the drawing surface //If the image type is not a basic one we require to mix the pixels if (image_type & IMAGE_TYPE_USE_PALETTE){//In the .exe these are all unraveled loops - for (; no_pixels > 0; no_pixels -= zoom_level, source_pointer += zoom_level, dest_pointer++){ + for (; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_level, dest_pointer++){ + for (; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_level, source_pointer += zoom_level, dest_pointer++){ + for (; no_pixels > 0; no_pixels -= (1<zoom_level + 1; + //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; + int height = g1_source->height >> zoom_level; //This is the start y coordinate on the destination int dest_start_y = y - dpi->y + g1_source->y_offset; //This is the start y coordinate on the source @@ -1038,7 +1038,7 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in return; } //The source image will start a further up the image - source_start_y -= dest_start_y*zoom_level; + source_start_y -= dest_start_y<width / zoom_level; + int width = g1_source->width >> zoom_level; //This is the source start x coordinate int source_start_x = 0; //This is the destination start x coordinate @@ -1070,7 +1070,7 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in return; } //The source start will also need to cut off the side - source_start_x -= dest_start_x*zoom_level; + source_start_x -= dest_start_x<width + dpi->pitch)*dest_start_y + dest_start_x; - height *= zoom_level; - width *= zoom_level; + height <<= zoom_level; + width <<= zoom_level; if (g1_source->flags & G1_FLAG_RLE_COMPRESSION){ //We have to use a different method to move the source pointer for