equal
deleted
inserted
replaced
16 #include "video/video_driver.hpp" |
16 #include "video/video_driver.hpp" |
17 #include "strings_func.h" |
17 #include "strings_func.h" |
18 #include "core/math_func.hpp" |
18 #include "core/math_func.hpp" |
19 #include "settings_type.h" |
19 #include "settings_type.h" |
20 #include "core/alloc_func.hpp" |
20 #include "core/alloc_func.hpp" |
|
21 #include "core/sort_func.hpp" |
21 #include "landscape_type.h" |
22 #include "landscape_type.h" |
22 |
23 |
23 #include "table/palettes.h" |
24 #include "table/palettes.h" |
24 #include "table/sprites.h" |
25 #include "table/sprites.h" |
25 #include "table/control_codes.h" |
26 #include "table/control_codes.h" |
687 } else { |
688 } else { |
688 GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH)), x, y, BM_NORMAL, sub); |
689 GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH)), x, y, BM_NORMAL, sub); |
689 } |
690 } |
690 } |
691 } |
691 |
692 |
692 static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub) |
693 static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub) |
693 { |
694 { |
694 const DrawPixelInfo *dpi = _cur_dpi; |
695 const DrawPixelInfo *dpi = _cur_dpi; |
695 Blitter::BlitterParams bp; |
696 Blitter::BlitterParams bp; |
696 |
697 |
697 /* Amount of pixels to clip from the source sprite */ |
698 /* Amount of pixels to clip from the source sprite */ |
713 bp.sprite_height = sprite->height; |
714 bp.sprite_height = sprite->height; |
714 bp.width = UnScaleByZoom(sprite->width - clip_left - clip_right, dpi->zoom); |
715 bp.width = UnScaleByZoom(sprite->width - clip_left - clip_right, dpi->zoom); |
715 bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom); |
716 bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom); |
716 bp.top = 0; |
717 bp.top = 0; |
717 bp.left = 0; |
718 bp.left = 0; |
718 bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom); |
719 bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom); |
719 bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom); |
720 bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom); |
720 |
721 |
721 x += ScaleByZoom(bp.skip_left, dpi->zoom); |
722 x += ScaleByZoom(bp.skip_left, dpi->zoom); |
722 y += ScaleByZoom(bp.skip_top, dpi->zoom); |
723 y += ScaleByZoom(bp.skip_top, dpi->zoom); |
723 |
724 |
724 bp.dst = dpi->dst_ptr; |
725 bp.dst = dpi->dst_ptr; |
764 x += ScaleByZoom(bp.width, dpi->zoom) - dpi->width; |
765 x += ScaleByZoom(bp.width, dpi->zoom) - dpi->width; |
765 if (x > 0) { |
766 if (x > 0) { |
766 bp.width -= UnScaleByZoom(x, dpi->zoom); |
767 bp.width -= UnScaleByZoom(x, dpi->zoom); |
767 if (bp.width <= 0) return; |
768 if (bp.width <= 0) return; |
768 } |
769 } |
|
770 |
|
771 assert(bp.skip_left + bp.width <= UnScaleByZoom(sprite->width, dpi->zoom)); |
|
772 assert(bp.skip_top + bp.height <= UnScaleByZoom(sprite->height, dpi->zoom)); |
769 |
773 |
770 BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom); |
774 BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom); |
771 } |
775 } |
772 |
776 |
773 void DoPaletteAnimations(); |
777 void DoPaletteAnimations(); |
1307 DEBUG(driver, 0, "Could not find a suitable fullscreen resolution"); |
1311 DEBUG(driver, 0, "Could not find a suitable fullscreen resolution"); |
1308 } |
1312 } |
1309 return result; |
1313 return result; |
1310 } |
1314 } |
1311 |
1315 |
1312 static int CDECL compare_res(const void *pa, const void *pb) |
1316 static int CDECL compare_res(const Dimension *pa, const Dimension *pb) |
1313 { |
1317 { |
1314 int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0]; |
1318 int x = pa->width - pb->width; |
1315 if (x != 0) return x; |
1319 if (x != 0) return x; |
1316 return ((const uint16*)pa)[1] - ((const uint16*)pb)[1]; |
1320 return pa->height - pb->height; |
1317 } |
1321 } |
1318 |
1322 |
1319 void SortResolutions(int count) |
1323 void SortResolutions(int count) |
1320 { |
1324 { |
1321 qsort(_resolutions, count, sizeof(_resolutions[0]), compare_res); |
1325 QSortT(_resolutions, count, &compare_res); |
1322 } |
1326 } |