From 57e7680dd5cfc68da831b4103db5aa3c7daa7b49 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Wed, 24 Apr 2019 18:21:22 +0300 Subject: [PATCH] Fixed 16bpp blitter --- src/blitter/16bpp_anim.cpp | 2 +- src/blitter/16bpp_base.cpp | 11 ++++++++++- src/blitter/16bpp_base.hpp | 1 + src/blitter/16bpp_simple.cpp | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/blitter/16bpp_anim.cpp b/src/blitter/16bpp_anim.cpp index 115ffe9df5..f5a51cfb60 100644 --- a/src/blitter/16bpp_anim.cpp +++ b/src/blitter/16bpp_anim.cpp @@ -7,7 +7,7 @@ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . */ -/** @file 16bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */ +/** @file 16bpp_anim.cpp Implementation of the optimized 16 bpp blitter with animation support, currently broken. */ #include "../stdafx.h" #include "../video/video_driver.hpp" diff --git a/src/blitter/16bpp_base.cpp b/src/blitter/16bpp_base.cpp index 9161ce92c4..df1ba3ccb0 100644 --- a/src/blitter/16bpp_base.cpp +++ b/src/blitter/16bpp_base.cpp @@ -7,10 +7,11 @@ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . */ -/** @file 16bpp_base.cpp Implementation of base for 32 bpp blitters. */ +/** @file 16bpp_base.cpp Implementation of base for 16 bpp blitters. */ #include "../stdafx.h" #include "16bpp_base.hpp" +#include "common.hpp" void *Blitter_16bppBase::MoveTo(void *video, int x, int y) { @@ -22,6 +23,14 @@ void Blitter_16bppBase::SetPixel(void *video, int x, int y, uint8 colour) *((Colour16 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour); } +void Blitter_16bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) +{ + const Colour16 c = LookupColourInPalette(colour); + this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) { + *((Colour16 *)video + x + y * _screen.pitch) = c; + }); +} + void Blitter_16bppBase::DrawRect(void *video, int width, int height, uint8 colour) { Colour16 target = LookupColourInPalette(colour); diff --git a/src/blitter/16bpp_base.hpp b/src/blitter/16bpp_base.hpp index c4d63b0bd4..a4904f428a 100644 --- a/src/blitter/16bpp_base.hpp +++ b/src/blitter/16bpp_base.hpp @@ -42,6 +42,7 @@ public: /* virtual */ uint8 GetScreenDepth() { return 16; } /* virtual */ void *MoveTo(void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); + /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash); /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height); /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height); diff --git a/src/blitter/16bpp_simple.cpp b/src/blitter/16bpp_simple.cpp index fc0e83fff3..8f4017e793 100644 --- a/src/blitter/16bpp_simple.cpp +++ b/src/blitter/16bpp_simple.cpp @@ -7,7 +7,7 @@ * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . */ -/** @file 32bpp_simple.cpp Implementation of the simple 32 bpp blitter. */ +/** @file 32bpp_simple.cpp Implementation of the simple 16 bpp blitter. */ #include "../stdafx.h" #include "../zoom_func.h"