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>
27 
28 #include "common/rect.h"
29 #include "graphics/surface.h"
30 
31 #include "atari-cursor.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 
43 
44 class Palette {
45 public:
46  void clear() {
47  memset(data, 0, sizeof(data));
48  entries = 0;
49  }
50 
51  uint16 *const tt = reinterpret_cast<uint16*>(data);
52  _RGB *const falcon = reinterpret_cast<_RGB*>(data);
53 
54  int entries = 0;
55 
56 private:
57  byte data[256*4] = {};
58 };
59 
60 struct Screen {
62 
63  Screen(AtariGraphicsManager *manager, int width, int height, const Graphics::PixelFormat &format, const Palette *palette);
64  ~Screen();
65 
66  void reset(int width, int height, int bitsPerPixel, bool resetCursorPosition);
67  // must be called before any rectangle drawing
68  void addDirtyRect(const Graphics::Surface &srcSurface, const Common::Rect &rect, bool directRendering);
69 
70  void clearDirtyRects() {
71  dirtyRects.clear();
72  fullRedraw = false;
73  }
74 
75  Graphics::Surface surf;
76  const Palette *palette;
77  DirtyRects dirtyRects;
78  bool fullRedraw = false;
79 
80  Cursor cursor;
81 
82  int rez = -1;
83  int mode = -1;
84  Graphics::Surface *const offsettedSurf = &_offsettedSurf;
85 
86 private:
87  static constexpr size_t ALIGN = 16; // 16 bytes
88 
89  enum SteTtRezValue {
90  kRezValueSTLow = 0, // 320x200@4bpp, ST palette
91  kRezValueSTMid = 1, // 640x200@2bpp, ST palette
92  kRezValueSTHigh = 2, // 640x400@1bpp, ST palette
93  kRezValueTTLow = 7, // 320x480@8bpp, TT palette
94  kRezValueTTMid = 4, // 640x480@4bpp, TT palette
95  kRezValueTTHigh = 6 // 1280x960@1bpp, TT palette
96  };
97 
98  const AtariGraphicsManager *_manager;
99 
100  Graphics::Surface _offsettedSurf;
101 };
102 
103 #endif // BACKENDS_GRAPHICS_ATARI_SCREEN_H
Definition: surface.h:67
Definition: pixelformat.h:138
int16 right
Definition: rect.h:146
Definition: rect.h:144
Definition: atari-screen.h:60
Definition: atari-cursor.h:38
Definition: algorithm.h:29
int16 left
Definition: rect.h:145
Definition: atari-graphics.h:40
Definition: atari-screen.h:44