ScummVM API documentation
nut_renderer.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#if !defined(SCUMM_NUT_RENDERER_H) && defined(ENABLE_SCUMM_7_8)
23#define SCUMM_NUT_RENDERER_H
24
25#include "common/file.h"
26#include "graphics/surface.h"
27#include "scumm/charset_v7.h"
28
29namespace Scumm {
30
31class ScummEngine;
32
33class NutRenderer {
34protected:
35
36 enum {
37 kDefaultTransparentColor = 0,
38 kSmush44TransparentColor = 2
39 };
40
41 ScummEngine *_vm;
42 int _numChars;
43 int _fontHeight;
44 int _spacing;
45 byte *_decodedData;
46 const int _direction;
47
48 const int8 *_2byteShadowXOffsetTable;
49 const int8 *_2byteShadowYOffsetTable;
50 uint8 *_2byteColorTable;
51 uint8 *_2byteMainColor;
52 const int _2byteSteps;
53
54 struct {
55 uint16 width;
56 uint16 height;
57 int16 xoffs; // X offset from NUT frame header (for sprite positioning)
58 int16 yoffs; // Y offset from NUT frame header (for sprite positioning)
59 byte *src;
60 byte transparency;
61 } _chars[256];
62
63 void codec1(byte *dst, const byte *src, int width, int height, int pitch);
64 void codec21(byte *dst, const byte *src, int width, int height, int pitch);
65
66 void loadFont(const char *filename);
67
68public:
69 NutRenderer(ScummEngine *vm, const char *filename = nullptr);
70 virtual ~NutRenderer();
71 void loadFontFromData(const byte *data, int32 dataSize);
72 int getNumChars() const { return _numChars; }
73
74 void drawFrame(byte *dst, int c, int x, int y, int pitch = -1);
75 int draw2byte(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, uint16 chr);
76 int drawCharV7(byte *buffer, Common::Rect &clipRect, int x, int y, int pitch, int16 col, TextStyleFlags flags, byte chr, bool hardcodedColors = false, bool smushColorMode = false);
77
78 int getCharWidth(byte c) const;
79 int getCharHeight(byte c) const;
80 int16 getCharXOffset(byte c) const { return _chars[c].xoffs; }
81 int16 getCharYOffset(byte c) const { return _chars[c].yoffs; }
82 const byte *getCharData(byte c);
83 byte getCharTransparency(byte c) const { return _chars[c].transparency; }
84 byte getBpp() const { return 8; }
85
86 int getFontHeight() const { return _fontHeight; }
87};
88
89} // End of namespace Scumm
90
91#endif
Definition: actor.h:30
Definition: rect.h:536