From e418b926a5cbb43a7fca6db1b46e5fc8e74ea6cf Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 15 Aug 2014 13:45:12 +0100 Subject: [PATCH 1/4] Add new language files to vs project --- projects/openrct2.vcxproj | 8 ++++---- projects/openrct2.vcxproj.filters | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index ba98d0f23c..3273121a1d 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -135,10 +135,10 @@ - - - - + + + + {D24D94F6-2A74-480C-B512-629C306CE92F} diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index a62222a671..ae30a2f716 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -372,7 +372,16 @@ - + + Data\Language + + + Data\Language + + + Data\Language + + Data\Language From 5aebdf0566df111ff23648ad78a9687af5367ede Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 15 Aug 2014 14:27:56 +0100 Subject: [PATCH 2/4] Added missing inline sprites --- data/language/dutch.txt | 40 ++++++++++++++++++------------------ data/language/english_uk.txt | 36 ++++++++++++++++---------------- data/language/english_us.txt | 36 ++++++++++++++++---------------- data/language/french.txt | 36 ++++++++++++++++---------------- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/data/language/dutch.txt b/data/language/dutch.txt index 690086e28c..c049474539 100644 --- a/data/language/dutch.txt +++ b/data/language/dutch.txt @@ -1448,7 +1448,7 @@ STR_1446 :Kijkt naar decor STR_1447 :Verlaat het park STR_1448 :Kijkt naar bouw van nieuwe attractie STR_1449 :{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) -STR_1450 :{INLINE_SPRITE}{MEDIUMFONT}{20} +STR_1450 :{INLINE_SPRITE}{09}{20}{00}{00}{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) STR_1451 :{STRINGID}{NEWLINE}({STRINGID}) STR_1452 :Naam bezoeker STR_1453 :Voer een naam in voor deze bezoeker: @@ -1710,10 +1710,10 @@ STR_1708 :{SMALLFONT}{BLACK}Set patrol area for this staff member STR_1709 :Sack staff STR_1710 :Yes STR_1711 :{WINDOW_COLOUR_1}Are you sure you want to sack {STRINGID}? -STR_1712 :{INLINE_SPRITE}{247}{19} -STR_1713 :{INLINE_SPRITE}{248}{19} -STR_1714 :{INLINE_SPRITE}{249}{19} -STR_1715 :{INLINE_SPRITE}{250}{19} +STR_1712 :{INLINE_SPRITE}{247}{19}{00}{00}{WINDOW_COLOUR_2}Sweep footpaths +STR_1713 :{INLINE_SPRITE}{248}{19}{00}{00}{WINDOW_COLOUR_2}Water gardens +STR_1714 :{INLINE_SPRITE}{249}{19}{00}{00}{WINDOW_COLOUR_2}Empty litter bins +STR_1715 :{INLINE_SPRITE}{250}{19}{00}{00}{WINDOW_COLOUR_2}Mow grass STR_1716 :Invalid name for park STR_1717 :Can't rename park... STR_1718 :Park Name @@ -1777,17 +1777,17 @@ STR_1775 :Uit STR_1776 :Aan STR_1777 :{WINDOW_COLOUR_2}Music: STR_1778 :{STRINGID} - - -STR_1779 :{INLINE_SPRITE}{254}{19} -STR_1780 :{INLINE_SPRITE}{255}{19} -STR_1781 :{INLINE_SPRITE} -STR_1782 :{INLINE_SPRITE}{MOVE_X}{20} -STR_1783 :{INLINE_SPRITE}{2}{20} -STR_1784 :{INLINE_SPRITE}{3}{20} -STR_1785 :{INLINE_SPRITE}{4}{20} -STR_1786 :{INLINE_SPRITE}{NEWLINE}{20} -STR_1787 :{INLINE_SPRITE}{6}{20} -STR_1788 :{INLINE_SPRITE}{TINYFONT}{20} -STR_1789 :{INLINE_SPRITE}{BIGFONT}{20} +STR_1779 :{INLINE_SPRITE}{254}{19}{00}{00} Panda costume +STR_1780 :{INLINE_SPRITE}{255}{19}{00}{00} Tigre costume +STR_1781 :{INLINE_SPRITE}{00}{20}{00}{00} Elephant costume +STR_1782 :{INLINE_SPRITE}{01}{20}{00}{00} Roman costume +STR_1783 :{INLINE_SPRITE}{02}{20}{00}{00} Gorilla costume +STR_1784 :{INLINE_SPRITE}{03}{20}{00}{00} Snowman costume +STR_1785 :{INLINE_SPRITE}{04}{20}{00}{00} Knight costume +STR_1786 :{INLINE_SPRITE}{05}{20}{00}{00} Astronaut costume +STR_1787 :{INLINE_SPRITE}{06}{20}{00}{00} Bandit costume +STR_1788 :{INLINE_SPRITE}{07}{20}{00}{00} Sheriff costume +STR_1789 :{INLINE_SPRITE}{08}{20}{00}{00} Pirate costume STR_1790 :{SMALLFONT}{BLACK}Select uniform color for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform color: STR_1792 :Responding to {STRINGID} breakdown call @@ -1845,8 +1845,8 @@ STR_1843 :Favorite of: {COMMA16} guests STR_1844 :{SMALLFONT}{BLACK}Select information type to show in ride/attraction list STR_1845 :{MONTHYEAR} STR_1846 :{COMMA16} guests -STR_1847 :{INLINE_SPRITE}{OUTLINE}{20} -STR_1848 :{INLINE_SPRITE}{SMALLFONT}{20} +STR_1847 :{INLINE_SPRITE}{11}{20}{00}{00}{COMMA16} guests +STR_1848 :{INLINE_SPRITE}{10}{20}{00}{00}{COMMA16} guests STR_1849 :{WINDOW_COLOUR_2}Play music STR_1850 :{SMALLFONT}{BLACK}Select whether music should be played for this ride STR_1851 :{WINDOW_COLOUR_2}Running cost: {BLACK}{CURRENCY2DP} per hour @@ -1874,8 +1874,8 @@ STR_1872 :{COMMA16} STR_1873 :{WINDOW_COLOUR_2}Income: {BLACK}{CURRENCY} per hour STR_1874 :{WINDOW_COLOUR_2}Profit: {BLACK}{CURRENCY} per hour STR_1875 :{BLACK} {SPRITE}{BLACK} {STRINGID} -STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19} -STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19} +STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19}{00}{00}Inspect Rides +STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19}{00}{00}Fix Rides STR_1878 :{WINDOW_COLOUR_2}Inspection: STR_1879 :Every 10 minutes STR_1880 :Every 20 minutes diff --git a/data/language/english_uk.txt b/data/language/english_uk.txt index 08d97bbd76..b60498c9b2 100644 --- a/data/language/english_uk.txt +++ b/data/language/english_uk.txt @@ -1451,7 +1451,7 @@ STR_1446 :Looking at scenery STR_1447 :Leaving the park STR_1448 :Watching new ride being constructed STR_1449 :{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) -STR_1450 :{INLINE_SPRITE}{MEDIUMFONT}{20} +STR_1450 :{INLINE_SPRITE}{09}{20}{00}{00}{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) STR_1451 :{STRINGID}{NEWLINE}({STRINGID}) STR_1452 :Guest's name STR_1453 :Enter name for this guest:- @@ -1713,10 +1713,10 @@ STR_1708 :{SMALLFONT}{BLACK}Set patrol area for this staff member STR_1709 :Sack staff STR_1710 :Yes STR_1711 :{WINDOW_COLOUR_1}Are you sure you want to sack {STRINGID}? -STR_1712 :{INLINE_SPRITE}{247}{19} -STR_1713 :{INLINE_SPRITE}{248}{19} -STR_1714 :{INLINE_SPRITE}{249}{19} -STR_1715 :{INLINE_SPRITE}{250}{19} +STR_1712 :{INLINE_SPRITE}{247}{19}{00}{00}{WINDOW_COLOUR_2}Sweep footpaths +STR_1713 :{INLINE_SPRITE}{248}{19}{00}{00}{WINDOW_COLOUR_2}Water gardens +STR_1714 :{INLINE_SPRITE}{249}{19}{00}{00}{WINDOW_COLOUR_2}Empty litter bins +STR_1715 :{INLINE_SPRITE}{250}{19}{00}{00}{WINDOW_COLOUR_2}Mow grass STR_1716 :Invalid name for park STR_1717 :Can't rename park... STR_1718 :Park Name @@ -1780,17 +1780,17 @@ STR_1775 :Off STR_1776 :On STR_1777 :{WINDOW_COLOUR_2}Music: STR_1778 :{STRINGID} - - -STR_1779 :{INLINE_SPRITE}{254}{19} -STR_1780 :{INLINE_SPRITE}{255}{19} -STR_1781 :{INLINE_SPRITE} -STR_1782 :{INLINE_SPRITE}{MOVE_X}{20} -STR_1783 :{INLINE_SPRITE}{ADJUST_PALETTE}{20} -STR_1784 :{INLINE_SPRITE}{3}{20} -STR_1785 :{INLINE_SPRITE}{4}{20} -STR_1786 :{INLINE_SPRITE}{NEWLINE}{20} -STR_1787 :{INLINE_SPRITE}{NEWLINE_SMALLER}{20} -STR_1788 :{INLINE_SPRITE}{TINYFONT}{20} -STR_1789 :{INLINE_SPRITE}{BIGFONT}{20} +STR_1779 :{INLINE_SPRITE}{254}{19}{00}{00} Panda costume +STR_1780 :{INLINE_SPRITE}{255}{19}{00}{00} Tigre costume +STR_1781 :{INLINE_SPRITE}{00}{20}{00}{00} Elephant costume +STR_1782 :{INLINE_SPRITE}{01}{20}{00}{00} Roman costume +STR_1783 :{INLINE_SPRITE}{02}{20}{00}{00} Gorilla costume +STR_1784 :{INLINE_SPRITE}{03}{20}{00}{00} Snowman costume +STR_1785 :{INLINE_SPRITE}{04}{20}{00}{00} Knight costume +STR_1786 :{INLINE_SPRITE}{05}{20}{00}{00} Astronaut costume +STR_1787 :{INLINE_SPRITE}{06}{20}{00}{00} Bandit costume +STR_1788 :{INLINE_SPRITE}{07}{20}{00}{00} Sheriff costume +STR_1789 :{INLINE_SPRITE}{08}{20}{00}{00} Pirate costume STR_1790 :{SMALLFONT}{BLACK}Select uniform colour for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform colour: STR_1792 :Responding to {STRINGID} breakdown call @@ -1877,8 +1877,8 @@ STR_1872 :{COMMA16} STR_1873 :{WINDOW_COLOUR_2}Income: {BLACK}{CURRENCY} per hour STR_1874 :{WINDOW_COLOUR_2}Profit: {BLACK}{CURRENCY} per hour STR_1875 :{BLACK} {SPRITE}{BLACK} {STRINGID} -STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19} -STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19} +STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19}{00}{00}Inspect Rides +STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19}{00}{00}Fix Rides STR_1878 :{WINDOW_COLOUR_2}Inspection: STR_1879 :Every 10 minutes STR_1880 :Every 20 minutes diff --git a/data/language/english_us.txt b/data/language/english_us.txt index ad3f71c398..4b588c57bd 100644 --- a/data/language/english_us.txt +++ b/data/language/english_us.txt @@ -1451,7 +1451,7 @@ STR_1446 :Looking at scenery STR_1447 :Leaving the park STR_1448 :Watching new ride being constructed STR_1449 :{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) -STR_1450 :{INLINE_SPRITE}{MEDIUMFONT}{20} +STR_1450 :{INLINE_SPRITE}{09}{20}{00}{00}{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) STR_1451 :{STRINGID}{NEWLINE}({STRINGID}) STR_1452 :Guest's name STR_1453 :Enter name for this guest:- @@ -1713,10 +1713,10 @@ STR_1708 :{SMALLFONT}{BLACK}Set patrol area for this staff member STR_1709 :Sack staff STR_1710 :Yes STR_1711 :{WINDOW_COLOUR_1}Are you sure you want to sack {STRINGID}? -STR_1712 :{INLINE_SPRITE}{247}{19} -STR_1713 :{INLINE_SPRITE}{248}{19} -STR_1714 :{INLINE_SPRITE}{249}{19} -STR_1715 :{INLINE_SPRITE}{250}{19} +STR_1712 :{INLINE_SPRITE}{247}{19}{00}{00}{WINDOW_COLOUR_2}Sweep footpaths +STR_1713 :{INLINE_SPRITE}{248}{19}{00}{00}{WINDOW_COLOUR_2}Water gardens +STR_1714 :{INLINE_SPRITE}{249}{19}{00}{00}{WINDOW_COLOUR_2}Empty litter bins +STR_1715 :{INLINE_SPRITE}{250}{19}{00}{00}{WINDOW_COLOUR_2}Mow grass STR_1716 :Invalid name for park STR_1717 :Can't rename park... STR_1718 :Park Name @@ -1780,17 +1780,17 @@ STR_1775 :Off STR_1776 :On STR_1777 :{WINDOW_COLOUR_2}Music: STR_1778 :{STRINGID} - - -STR_1779 :{INLINE_SPRITE}{254}{19} -STR_1780 :{INLINE_SPRITE}{255}{19} -STR_1781 :{INLINE_SPRITE} -STR_1782 :{INLINE_SPRITE}{MOVE_X}{20} -STR_1783 :{INLINE_SPRITE}{ADJUST_PALETTE}{20} -STR_1784 :{INLINE_SPRITE}{3}{20} -STR_1785 :{INLINE_SPRITE}{4}{20} -STR_1786 :{INLINE_SPRITE}{NEWLINE}{20} -STR_1787 :{INLINE_SPRITE}{NEWLINE_SMALLER}{20} -STR_1788 :{INLINE_SPRITE}{TINYFONT}{20} -STR_1789 :{INLINE_SPRITE}{BIGFONT}{20} +STR_1779 :{INLINE_SPRITE}{254}{19}{00}{00} Panda costume +STR_1780 :{INLINE_SPRITE}{255}{19}{00}{00} Tigre costume +STR_1781 :{INLINE_SPRITE}{00}{20}{00}{00} Elephant costume +STR_1782 :{INLINE_SPRITE}{01}{20}{00}{00} Roman costume +STR_1783 :{INLINE_SPRITE}{02}{20}{00}{00} Gorilla costume +STR_1784 :{INLINE_SPRITE}{03}{20}{00}{00} Snowman costume +STR_1785 :{INLINE_SPRITE}{04}{20}{00}{00} Knight costume +STR_1786 :{INLINE_SPRITE}{05}{20}{00}{00} Astronaut costume +STR_1787 :{INLINE_SPRITE}{06}{20}{00}{00} Bandit costume +STR_1788 :{INLINE_SPRITE}{07}{20}{00}{00} Sheriff costume +STR_1789 :{INLINE_SPRITE}{08}{20}{00}{00} Pirate costume STR_1790 :{SMALLFONT}{BLACK}Select uniform color for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform color: STR_1792 :Responding to {STRINGID} breakdown call @@ -1877,8 +1877,8 @@ STR_1872 :{COMMA16} STR_1873 :{WINDOW_COLOUR_2}Income: {BLACK}{CURRENCY} per hour STR_1874 :{WINDOW_COLOUR_2}Profit: {BLACK}{CURRENCY} per hour STR_1875 :{BLACK} {SPRITE}{BLACK} {STRINGID} -STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19} -STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19} +STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19}{00}{00}Inspect Rides +STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19}{00}{00}Fix Rides STR_1878 :{WINDOW_COLOUR_2}Inspection: STR_1879 :Every 10 minutes STR_1880 :Every 20 minutes diff --git a/data/language/french.txt b/data/language/french.txt index ad3f71c398..4b588c57bd 100644 --- a/data/language/french.txt +++ b/data/language/french.txt @@ -1451,7 +1451,7 @@ STR_1446 :Looking at scenery STR_1447 :Leaving the park STR_1448 :Watching new ride being constructed STR_1449 :{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) -STR_1450 :{INLINE_SPRITE}{MEDIUMFONT}{20} +STR_1450 :{INLINE_SPRITE}{09}{20}{00}{00}{SPRITE} {STRINGID}{NEWLINE}({STRINGID}) STR_1451 :{STRINGID}{NEWLINE}({STRINGID}) STR_1452 :Guest's name STR_1453 :Enter name for this guest:- @@ -1713,10 +1713,10 @@ STR_1708 :{SMALLFONT}{BLACK}Set patrol area for this staff member STR_1709 :Sack staff STR_1710 :Yes STR_1711 :{WINDOW_COLOUR_1}Are you sure you want to sack {STRINGID}? -STR_1712 :{INLINE_SPRITE}{247}{19} -STR_1713 :{INLINE_SPRITE}{248}{19} -STR_1714 :{INLINE_SPRITE}{249}{19} -STR_1715 :{INLINE_SPRITE}{250}{19} +STR_1712 :{INLINE_SPRITE}{247}{19}{00}{00}{WINDOW_COLOUR_2}Sweep footpaths +STR_1713 :{INLINE_SPRITE}{248}{19}{00}{00}{WINDOW_COLOUR_2}Water gardens +STR_1714 :{INLINE_SPRITE}{249}{19}{00}{00}{WINDOW_COLOUR_2}Empty litter bins +STR_1715 :{INLINE_SPRITE}{250}{19}{00}{00}{WINDOW_COLOUR_2}Mow grass STR_1716 :Invalid name for park STR_1717 :Can't rename park... STR_1718 :Park Name @@ -1780,17 +1780,17 @@ STR_1775 :Off STR_1776 :On STR_1777 :{WINDOW_COLOUR_2}Music: STR_1778 :{STRINGID} - - -STR_1779 :{INLINE_SPRITE}{254}{19} -STR_1780 :{INLINE_SPRITE}{255}{19} -STR_1781 :{INLINE_SPRITE} -STR_1782 :{INLINE_SPRITE}{MOVE_X}{20} -STR_1783 :{INLINE_SPRITE}{ADJUST_PALETTE}{20} -STR_1784 :{INLINE_SPRITE}{3}{20} -STR_1785 :{INLINE_SPRITE}{4}{20} -STR_1786 :{INLINE_SPRITE}{NEWLINE}{20} -STR_1787 :{INLINE_SPRITE}{NEWLINE_SMALLER}{20} -STR_1788 :{INLINE_SPRITE}{TINYFONT}{20} -STR_1789 :{INLINE_SPRITE}{BIGFONT}{20} +STR_1779 :{INLINE_SPRITE}{254}{19}{00}{00} Panda costume +STR_1780 :{INLINE_SPRITE}{255}{19}{00}{00} Tigre costume +STR_1781 :{INLINE_SPRITE}{00}{20}{00}{00} Elephant costume +STR_1782 :{INLINE_SPRITE}{01}{20}{00}{00} Roman costume +STR_1783 :{INLINE_SPRITE}{02}{20}{00}{00} Gorilla costume +STR_1784 :{INLINE_SPRITE}{03}{20}{00}{00} Snowman costume +STR_1785 :{INLINE_SPRITE}{04}{20}{00}{00} Knight costume +STR_1786 :{INLINE_SPRITE}{05}{20}{00}{00} Astronaut costume +STR_1787 :{INLINE_SPRITE}{06}{20}{00}{00} Bandit costume +STR_1788 :{INLINE_SPRITE}{07}{20}{00}{00} Sheriff costume +STR_1789 :{INLINE_SPRITE}{08}{20}{00}{00} Pirate costume STR_1790 :{SMALLFONT}{BLACK}Select uniform color for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform color: STR_1792 :Responding to {STRINGID} breakdown call @@ -1877,8 +1877,8 @@ STR_1872 :{COMMA16} STR_1873 :{WINDOW_COLOUR_2}Income: {BLACK}{CURRENCY} per hour STR_1874 :{WINDOW_COLOUR_2}Profit: {BLACK}{CURRENCY} per hour STR_1875 :{BLACK} {SPRITE}{BLACK} {STRINGID} -STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19} -STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19} +STR_1876 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{251}{19}{00}{00}Inspect Rides +STR_1877 :{WINDOW_COLOUR_2}{INLINE_SPRITE}{252}{19}{00}{00}Fix Rides STR_1878 :{WINDOW_COLOUR_2}Inspection: STR_1879 :Every 10 minutes STR_1880 :Every 20 minutes From 4ec092096855b6106de179d39d98f8f095935490 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 14 Aug 2014 20:55:14 +0100 Subject: [PATCH 3/4] Trying to solve gfx issues --- src/gfx.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index f50d62c910..20083725df 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -818,11 +818,12 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui */ void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_pointer, uint8* palette_pointer, rct_drawpixelinfo *dpi, int image_type, int source_y_start, int height, int source_x_start, int width){ int zoom_level = dpi->zoom_level; + int zoom_amount = 1 << 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 += (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_amount; } else{ //If the start is negative we require to remove part of the image. @@ -879,7 +880,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 -= (1< 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){ uint8 al = *source_pointer; uint8 ah = *dest_pointer; if (image_type & IMAGE_TYPE_MIX_BACKGROUND) @@ -893,7 +894,7 @@ void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_point //Doesnt use source pointer ??? mix with background only? //Not Tested - for (; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, dest_pointer++){ uint8 pixel = *dest_pointer; pixel = palette_pointer[pixel]; *dest_pointer = pixel; @@ -901,14 +902,14 @@ void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_point } else { - for (; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){ *dest_pointer = *source_pointer; } } } //Add a line to the drawing surface pointer - next_dest_pointer += (int)(dpi->width >> zoom_level) + (int)dpi->pitch; + next_dest_pointer += dpi->width / zoom_amount + dpi->pitch; } } @@ -1053,13 +1054,17 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in if ( dpi->zoom_level && (g1_source->flags & (1<<5)) ){ return; } + //Its used super often so we will define it to a seperate variable. int zoom_level = dpi->zoom_level; - uint16 zoom_mask = 0xFFFF << zoom_level; + int zoom_amount = 1 << zoom_level; + int zoom_mask = 0xFFFFFFFF << 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 = ((sint16)y + g1_source->y_offset - dpi->y) >> zoom_level; + sint16 dest_start_y = ((y + g1_source->y_offset)&zoom_mask) - dpi->y; + dest_start_y /= zoom_amount; //This is the start y coordinate on the source int source_start_y = 0; @@ -1073,7 +1078,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< (dpi->height >> zoom_level)){ + if (dest_end_y > (dpi->height/zoom_amount)){ //If the destination y is outside of the drawing //image reduce the height of the image - height -= dest_end_y - (dpi->height >> zoom_level); + height -= dest_end_y - dpi->height / zoom_amount; } //If the image no longer has anything to draw if (height <= 0)return; @@ -1094,8 +1099,10 @@ 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 = ((sint16)x + g1_source->x_offset - dpi->x) >> zoom_level; - + sint16 dest_start_x = ((x + g1_source->x_offset) & zoom_mask) - dpi->x; + dest_start_x /= zoom_amount; + + if (dest_start_x < 0){ //If the destination is negative reduce the width //image will cut off the side @@ -1105,17 +1112,17 @@ 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< (dpi->width>>zoom_level)){ + if (dest_end_x > (dpi->width/zoom_amount)){ //If the destination x is outside of the drawing area //reduce the image width. - width -= dest_end_x - (dpi->width >> zoom_level); + width -= dest_end_x - (dpi->width / zoom_amount); //If there is no image to draw. if (width <= 0)return; } @@ -1123,7 +1130,7 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in uint8* dest_pointer = (uint8*)dpi->bits; //Move the pointer to the start point of the destination - dest_pointer += ((dpi->width >> zoom_level) + dpi->pitch)*dest_start_y + dest_start_x; + dest_pointer += ((dpi->width / zoom_amount) + dpi->pitch)*dest_start_y + dest_start_x; height <<= zoom_level; width <<= zoom_level; From d8ab81c456149b6a3729eaef9255fb91849b1ec3 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Fri, 15 Aug 2014 15:07:35 +0100 Subject: [PATCH 4/4] Fixed Zoom bug. No longer uses undefined behaviour. --- src/gfx.c | 88 +++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/src/gfx.c b/src/gfx.c index 20083725df..83a214c543 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -690,6 +690,7 @@ void gfx_fill_rect_inset(rct_drawpixelinfo* dpi, short left, short top, short ri */ 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; + uint8 zoom_amount = 1 << zoom_level; //Requires use of palette? if (image_type & IMAGE_TYPE_USE_PALETTE){ @@ -697,12 +698,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 -= (1<width << zoom_level); - uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width << zoom_level); - uint8* next_dest_pointer = dest_pointer + (dest_dpi->width >> zoom_level) + dest_dpi->pitch; + for (; height > 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, unknown_pointer += zoom_amount, dest_pointer++){ uint8 pixel = *source_pointer; pixel = palette_pointer[pixel]; pixel &= *unknown_pointer; @@ -718,10 +719,10 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui } //image colour adjusted? - for (; height > 0; height -= (1<width<width >> zoom_level) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; + for (int no_pixels = width; no_pixels > 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){ uint8 pixel = *source_pointer; pixel = palette_pointer[pixel]; if (pixel){ @@ -738,11 +739,11 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui //Mix with background. It only uses source pointer for //telling if it needs to be drawn not for colour. if (image_type & IMAGE_TYPE_MIX_BACKGROUND){//Not tested - for (; height > 0; height -= (1<width << zoom_level); - uint8* next_dest_pointer = dest_pointer + (dest_dpi->width >> zoom_level) + dest_dpi->pitch; + for (; height > 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, source_pointer += zoom_amount, dest_pointer++){ uint8 pixel = *source_pointer; if (pixel){ pixel = *dest_pointer; @@ -759,11 +760,11 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui //Basic bitmap no fancy stuff if (!(source_image->flags & G1_FLAG_BMP)){//Not tested - for (; height > 0; height-=(1<width << zoom_level); - uint8* next_dest_pointer = dest_pointer + (dest_dpi->width >> zoom_level) + dest_dpi->pitch; + for (; height > 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount){ *dest_pointer = *source_pointer; } @@ -776,12 +777,12 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui if (RCT2_GLOBAL(0x9E3CDC, uint32) != 0){//Not tested. I can't actually work out when this code runs. unknown_pointer += source_pointer - source_image->offset; - for (; height > 0; height -= (1<width << zoom_level); - uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width << zoom_level); - uint8* next_dest_pointer = dest_pointer + (dest_dpi->width >> zoom_level) + dest_dpi->pitch; + for (; height > 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_unknown_pointer = unknown_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount, unknown_pointer += zoom_amount){ uint8 pixel = *source_pointer; pixel &= *unknown_pointer; if (pixel){ @@ -795,11 +796,11 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui } //Basic bitmap with no draw pixels - for (; height > 0; height -= (1<width << zoom_level); - uint8* next_dest_pointer = dest_pointer + (dest_dpi->width >> zoom_level) + dest_dpi->pitch; + for (; height > 0; height -= zoom_amount){ + uint8* next_source_pointer = source_pointer + (uint32)(source_image->width * zoom_amount); + uint8* next_dest_pointer = dest_pointer + (dest_dpi->width / zoom_amount) + dest_dpi->pitch; - for (int no_pixels = width; no_pixels > 0; no_pixels -= (1< 0; no_pixels -= zoom_amount, dest_pointer++, source_pointer += zoom_amount){ uint8 pixel = *source_pointer; if (pixel){ *dest_pointer = pixel; @@ -1023,7 +1024,7 @@ 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. + //Zooming code has been integrated into main code. //if (dpi->zoom_level >= 1){ //These have not been tested // //something to do with zooming // if (dpi->zoom_level == 1){ @@ -1061,14 +1062,12 @@ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, in int zoom_mask = 0xFFFFFFFF << zoom_level; //This will be the height of the drawn image - int height = g1_source->height >> zoom_level; + int height = g1_source->height; //This is the start y coordinate on the destination sint16 dest_start_y = ((y + g1_source->y_offset)&zoom_mask) - dpi->y; - dest_start_y /= zoom_amount; //This is the start y coordinate on the source int source_start_y = 0; - if (dest_start_y < 0){ //If the destination y is negative reduce the height of the //image as we will cut off the bottom @@ -1078,30 +1077,30 @@ 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_amount; + source_start_y -= dest_start_y; //The destination start is now reset to 0 dest_start_y = 0; } - int dest_end_y = dest_start_y + height; - if (dest_end_y > (dpi->height/zoom_amount)){ + if (dest_end_y > dpi->height){ //If the destination y is outside of the drawing //image reduce the height of the image - height -= dest_end_y - dpi->height / zoom_amount; + height -= dest_end_y - dpi->height; } //If the image no longer has anything to draw if (height <= 0)return; + dest_start_y /= zoom_amount; + dest_end_y /= zoom_amount; + //This will be the width of the drawn image - int width = g1_source->width >> zoom_level; + int width = g1_source->width; //This is the source start x coordinate int source_start_x = 0; //This is the destination start x coordinate sint16 dest_start_x = ((x + g1_source->x_offset) & zoom_mask) - dpi->x; - dest_start_x /= zoom_amount; - if (dest_start_x < 0){ //If the destination is negative reduce the width @@ -1112,29 +1111,28 @@ 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_amount; + source_start_x -= dest_start_x; //Reset the destination to 0 dest_start_x = 0; } int dest_end_x = dest_start_x + width; - if (dest_end_x > (dpi->width/zoom_amount)){ + if (dest_end_x > dpi->width){ //If the destination x is outside of the drawing area //reduce the image width. - width -= dest_end_x - (dpi->width / zoom_amount); + width -= dest_end_x - dpi->width; //If there is no image to draw. if (width <= 0)return; } - + dest_start_x /= zoom_amount; + dest_end_x /= zoom_amount; + uint8* dest_pointer = (uint8*)dpi->bits; //Move the pointer to the start point of the destination dest_pointer += ((dpi->width / zoom_amount) + dpi->pitch)*dest_start_y + dest_start_x; - - 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 //rle encoded sprites so that will be handled within this function