ScummVM API documentation
display_a2.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 #include "adl/display.h"
23 
24 #ifndef ADL_DISPLAY_A2_H
25 #define ADL_DISPLAY_A2_H
26 
27 namespace Adl {
28 
29 class Display_A2 : public Display {
30 public:
31  Display_A2();
32  ~Display_A2() override;
33 
34  enum {
35  kGfxWidth = 280,
36  kGfxHeight = 192,
37  kGfxPitch = kGfxWidth / 7,
38  kGfxSize = kGfxPitch * kGfxHeight,
39  kTextWidth = 40,
40  kTextHeight = 24,
41  kSplitHeight = 32
42  };
43 
44  void init() override;
45 
46  // Graphics
47  uint getGfxWidth() const { return kGfxWidth; }
48  uint getGfxHeight() const { return kGfxHeight; }
49  uint getGfxPitch() const { return kGfxPitch; }
50  void loadFrameBuffer(Common::ReadStream &stream, byte *dst) const ;
51  void loadFrameBuffer(Common::ReadStream &stream);
52  void putPixel(const Common::Point &p, byte color);
53  void setPixelByte(const Common::Point &p, byte color);
54  void setPixelBit(const Common::Point &p, byte color);
55  void setPixelPalette(const Common::Point &p, byte color);
56  byte getPixelByte(const Common::Point &p) const;
57  bool getPixelBit(const Common::Point &p) const;
58  void clear(byte color);
59 
60  // Text
61  char asciiToNative(char c) const override { return c | 0x80; }
62  void printChar(char c) override;
63  void showCursor(bool enable) override;
64 
65 protected:
66  class TextReader {
67  public:
68  static uint16 getBits(const Display_A2 *display, uint y, uint x) {
69  const uint charPos = (y >> 3) * kTextWidth + x;
70  byte m = display->_textBuf[charPos];
71  byte b = _font[m & 0x3f][y % 8];
72 
73  if (display->_showCursor && charPos == display->_cursorPos) {
74  if (!display->_enableApple2eCursor) {
75  m = (m & 0x3f) | 0x40;
76  } else {
77  if (display->_blink) {
78  byte cursor[] = {
79  0x00, 0x00, 0x2a, 0x14,
80  0x2a, 0x14, 0x2a, 0x00
81  };
82 
83  b = cursor[y % 8];
84  }
85  }
86  }
87 
88  if (!(m & 0x80) && (!(m & 0x40) || display->_blink))
89  b = ~b;
90 
91  return b & 0x7f;
92  }
93 
94  static uint8 getStartY(const Display_A2 *display) {
95  if (display->_mode == kModeText)
96  return 0;
97  else
98  return kGfxHeight - kSplitHeight;
99  }
100 
101  static uint8 getEndY(const Display_A2 *display) { return kGfxHeight; }
102  };
103 
104  class GfxReader {
105  public:
106  static uint16 getBits(const Display_A2 *display, uint y, uint x) {
107  return display->_frameBuf[y * kGfxPitch + x];
108  }
109 
110  static uint8 getStartY(const Display_A2 *display) { return 0; }
111 
112  static uint8 getEndY(const Display_A2 *display) {
113  if (display->_mode == kModeGraphics)
114  return kGfxHeight;
115  else
116  return kGfxHeight - kSplitHeight;
117  }
118  };
119 
120  byte *_frameBuf;
121  bool _showCursor;
122  bool _enableColor;
123  bool _enableScanlines;
124  bool _enableMonoText;
125  bool _enableApple2eCursor;
126  bool _blink;
127 
128 private:
129  void writeFrameBuffer(const Common::Point &p, byte color, byte mask);
130 
131  static const byte _font[64][8];
132 };
133 
134 Display_A2 *Display_A2_create();
135 
136 } // End of namespace Adl
137 
138 #endif
Definition: display_a2.h:29
Definition: display_a2.h:104
Definition: adl.h:55
Definition: display.h:34
Definition: rect.h:45
Definition: stream.h:385
Definition: display_a2.h:66