ScummVM API documentation
atari-screen.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 #ifndef BACKENDS_GRAPHICS_ATARI_SCREEN_H
23 #define BACKENDS_GRAPHICS_ATARI_SCREEN_H
24 
25 #include <unordered_set>
26 #include <mint/ostruct.h> // _RGB
27 
28 #include "common/ptr.h"
29 
30 #include "atari-cursor.h"
31 #include "atari-surface.h"
32 
33 template<>
34 struct std::hash<Common::Rect>
35 {
36  std::size_t operator()(Common::Rect const& rect) const noexcept
37  {
38  return 31 * (31 * (31 * rect.left + rect.top) + rect.right) + rect.bottom;
39  }
40 };
41 
42 class Palette {
43 public:
44  void clear() {
45  memset(_data, 0, sizeof(_data));
46  entries = 0;
47  }
48 
49  uint16 *const tt = reinterpret_cast<uint16*>(_data);
50  _RGB *const falcon = reinterpret_cast<_RGB*>(_data);
51 
52  int entries = 0;
53 
54 private:
55  byte _data[256*4] = {};
56 };
57 
58 struct Screen {
60 
61  Screen(bool tt, int width, int height, const Graphics::PixelFormat &format, const Palette *palette);
62 
63  void reset(int width, int height, const Graphics::Surface &boundingSurf);
64  // must be called before any rectangle drawing
65  void addDirtyRect(const Graphics::Surface &srcSurface, int x, int y, int w, int h, bool directRendering);
66 
67  void clearDirtyRects() {
68  dirtyRects.clear();
69  fullRedraw = false;
70  }
71 
73  const Palette *palette;
74  DirtyRects dirtyRects;
75  bool fullRedraw = false;
76 
77  Cursor cursor;
78 
79  int rez = -1;
80  int mode = -1;
81  const Common::ScopedPtr<AtariSurface> &offsettedSurf = _offsettedSurf;
82 
83 private:
84  static constexpr size_t ALIGN = 16; // 16 bytes
85 
86  enum SteTtRezValue {
87  kRezValueSTLow = 0, // 320x200@4bpp, ST palette
88  kRezValueSTMid = 1, // 640x200@2bpp, ST palette
89  kRezValueSTHigh = 2, // 640x400@1bpp, ST palette
90  kRezValueTTLow = 7, // 320x480@8bpp, TT palette
91  kRezValueTTMid = 4, // 640x480@4bpp, TT palette
92  kRezValueTTHigh = 6 // 1280x960@1bpp, TT palette
93  };
94 
95  bool _tt;
96  Common::ScopedPtr<AtariSurface> _offsettedSurf;
97 };
98 
99 #endif // BACKENDS_GRAPHICS_ATARI_SCREEN_H
Definition: surface.h:67
T left
Definition: rect.h:170
Definition: pixelformat.h:138
Definition: rect.h:524
Definition: atari-screen.h:58
T right
Definition: rect.h:171
Definition: atari-cursor.h:35
Definition: algorithm.h:29
Definition: atari-screen.h:42