1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "sherlock/surface.h"
24 #include "sherlock/fonts.h"
25 #include "sherlock/sherlock.h"
26 
27 namespace Sherlock {
28 
BaseSurface()29 BaseSurface::BaseSurface() : Graphics::Screen(0, 0), Fonts() {
30 	free();		// Free the 0x0 surface allocated by Graphics::Screen
31 }
32 
BaseSurface(int width_,int height_)33 BaseSurface::BaseSurface(int width_, int height_) : Graphics::Screen(width_, height_),
34 		Fonts() {
35 	create(width_, height_);
36 }
37 
BaseSurface(int width_,int height_,const Graphics::PixelFormat & pf)38 BaseSurface::BaseSurface(int width_, int height_, const Graphics::PixelFormat &pf) :
39 		Graphics::Screen(width_, height_, pf), Fonts() {
40 }
41 
writeString(const Common::String & str,const Common::Point & pt,uint overrideColor)42 void BaseSurface::writeString(const Common::String &str, const Common::Point &pt, uint overrideColor) {
43 	Fonts::writeString(this, str, pt, overrideColor);
44 }
45 
writeFancyString(const Common::String & str,const Common::Point & pt,uint overrideColor1,uint overrideColor2)46 void BaseSurface::writeFancyString(const Common::String &str, const Common::Point &pt, uint overrideColor1, uint overrideColor2) {
47 	writeString(str, Common::Point(pt.x, pt.y), overrideColor1);
48 	writeString(str, Common::Point(pt.x + 1, pt.y), overrideColor1);
49 	writeString(str, Common::Point(pt.x + 2, pt.y), overrideColor1);
50 	writeString(str, Common::Point(pt.x, pt.y + 1), overrideColor1);
51 	writeString(str, Common::Point(pt.x + 2, pt.y + 1), overrideColor1);
52 	writeString(str, Common::Point(pt.x, pt.y + 2), overrideColor1);
53 	writeString(str, Common::Point(pt.x + 1, pt.y + 2), overrideColor1);
54 	writeString(str, Common::Point(pt.x + 2, pt.y + 2), overrideColor1);
55 	writeString(str, Common::Point(pt.x + 1, pt.y + 1), overrideColor2);
56 }
57 
SHtransBlitFrom(const ImageFrame & src,const Common::Point & pt,bool flipped,int overrideColor,int scaleVal)58 void BaseSurface::SHtransBlitFrom(const ImageFrame &src, const Common::Point &pt,
59 		bool flipped, int overrideColor, int scaleVal) {
60 	Common::Point drawPt(pt.x + src.sDrawXOffset(scaleVal), pt.y + src.sDrawYOffset(scaleVal));
61 	SHtransBlitFrom(src._frame, drawPt, flipped, overrideColor, scaleVal);
62 }
63 
SHtransBlitFrom(const Graphics::Surface & src,const Common::Point & pt,bool flipped,int overrideColor,int scaleVal)64 void BaseSurface::SHtransBlitFrom(const Graphics::Surface &src, const Common::Point &pt,
65 		bool flipped, int overrideColor, int scaleVal) {
66 	Common::Rect srcRect(0, 0, src.w, src.h);
67 	Common::Rect destRect(pt.x, pt.y, pt.x + src.w * SCALE_THRESHOLD / scaleVal,
68 		pt.y + src.h * SCALE_THRESHOLD / scaleVal);
69 
70 	Graphics::Screen::transBlitFrom(src, srcRect, destRect, IS_3DO ? 0 : TRANSPARENCY,
71 		flipped, overrideColor);
72 }
73 
74 
75 } // End of namespace Sherlock
76