ScummVM API documentation
atari-graphics-videl.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_VIDEL_H
23 #define BACKENDS_GRAPHICS_ATARI_VIDEL_H
24 
25 #include "backends/graphics/atari/atari-graphics.h"
26 
27 #include "backends/graphics/atari/atari-c2p-asm.h"
28 #include "backends/graphics/atari/atari-graphics-asm.h"
29 #include "common/system.h"
30 
32 public:
34  // using virtual methods so must be done here
35  allocateSurfaces();
36  }
37 
39  // using virtual methods so must be done here
40  freeSurfaces();
41  }
42 
43 private:
44  void copyRectToSurface(Graphics::Surface &dstSurface, int dstBitsPerPixel, const Graphics::Surface &srcSurface,
45  int destX, int destY,
46  const Common::Rect &subRect) const override {
47  // 'pChunkyEnd' is a delicate parameter: the c2p routine compares it to the address register
48  // used for pixel reading; two common mistakes:
49  // 1. (subRect.left, subRect.bottom) = beginning of the next line *including the offset*
50  // 2. (subRect.right, subRect.bottom) = even worse, end of the *next* line, not current one
51  const byte *pChunky = (const byte *)srcSurface.getBasePtr(subRect.left, subRect.top);
52  const byte *pChunkyEnd = (const byte *)srcSurface.getBasePtr(subRect.right, subRect.bottom-1);
53 
54  byte *pScreen = (byte *)dstSurface.getPixels() + destY * dstSurface.pitch + destX * dstBitsPerPixel/8;
55 
56  if (dstBitsPerPixel == 8) {
57  if (srcSurface.pitch == subRect.width()) {
58  if (srcSurface.pitch == dstSurface.pitch) {
59  asm_c2p1x1_8(pChunky, pChunkyEnd, pScreen);
60  return;
61  } else if (srcSurface.pitch == dstSurface.pitch/2) {
62  asm_c2p1x1_8_tt(pChunky, pChunkyEnd, pScreen, dstSurface.pitch);
63  return;
64  }
65  }
66 
67  asm_c2p1x1_8_rect(
68  pChunky, pChunkyEnd,
69  subRect.width(),
70  srcSurface.pitch,
71  pScreen,
72  dstSurface.pitch);
73  } else {
74  if (srcSurface.pitch == subRect.width() && srcSurface.pitch/2 == dstSurface.pitch) {
75  asm_c2p1x1_4(pChunky, pChunkyEnd, pScreen);
76  return;
77  }
78 
79  asm_c2p1x1_4_rect(
80  pChunky, pChunkyEnd,
81  subRect.width(),
82  srcSurface.pitch,
83  pScreen,
84  dstSurface.pitch);
85  }
86  }
87 
88  void drawMaskedSprite(Graphics::Surface &dstSurface, int dstBitsPerPixel,
89  const Graphics::Surface &srcSurface, const Graphics::Surface &srcMask,
90  int destX, int destY,
91  const Common::Rect &subRect) override {
92  if (dstBitsPerPixel == 4) {
93  asm_draw_4bpl_sprite(
94  (uint16 *)dstSurface.getPixels(), (const uint16 *)srcSurface.getBasePtr(subRect.left, subRect.top),
95  (const uint16 *)srcMask.getBasePtr(subRect.left, subRect.top),
96  destX, destY,
97  dstSurface.pitch, subRect.width(), subRect.height());
98  } else if (dstBitsPerPixel == 8) {
99  asm_draw_8bpl_sprite(
100  (uint16 *)dstSurface.getPixels(), (const uint16 *)srcSurface.getBasePtr(subRect.left, subRect.top),
101  (const uint16 *)srcMask.getBasePtr(subRect.left, subRect.top),
102  destX, destY,
103  dstSurface.pitch, subRect.width(), subRect.height());
104  }
105  }
106 
107  Common::Rect alignRect(int x, int y, int w, int h) const override {
108  return Common::Rect(x & (-16), y, (x + w + 15) & (-16), y + h);
109  }
110 };
111 
112 #endif
int32 pitch
Definition: surface.h:83
Definition: surface.h:67
int16 right
Definition: rect.h:146
Definition: rect.h:144
const void * getBasePtr(int x, int y) const
Definition: surface.h:138
int16 width() const
Definition: rect.h:191
Definition: atari-graphics-videl.h:31
int16 left
Definition: rect.h:145
Definition: atari-graphics.h:40
const void * getPixels() const
Definition: surface.h:108
int16 height() const
Definition: rect.h:192