ScummVM API documentation
intern.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 AWE_INTERN_H
23 #define AWE_INTERN_H
24 
25 #include "common/algorithm.h"
26 #include "common/endian.h"
27 #include "common/language.h"
28 #include "common/rect.h"
29 
30 namespace Awe {
31 
32 using Common::Language;
33 
34 enum {
35  kPartCopyProtection = 16000,
36  kPartIntro = 16001,
37  kPartWater = 16002,
38  kPartPrison = 16003,
39  kPartCite = 16004,
40  kPartArene = 16005,
41  kPartLuxe = 16006,
42  kPartFinal = 16007,
43  kPartPassword = 16008
44 };
45 
46 enum {
47  kPaulaFreq = 7159092
48 };
49 
50 struct Ptr {
51  uint8 *pc = nullptr;
52  bool byteSwap = false;
53 
54  uint8 fetchByte() {
55  return *pc++;
56  }
57 
58  uint16 fetchWord() {
59  const uint16 i = byteSwap ? READ_LE_UINT16(pc) : READ_BE_UINT16(pc);
60  pc += 2;
61  return i;
62  }
63 };
64 
65 struct Point : public Common::Point {
66  Point() : Common::Point() {}
67  Point(int16 xx, int16 yy) : Common::Point(xx, yy) {}
68  Point(const Point &p) : Common::Point(p) {}
69 
70  void scale(int u, int v) {
71  x = (x * u) >> 16;
72  y = (y * v) >> 16;
73  }
74 };
75 
76 struct QuadStrip {
77  enum {
78  MAX_VERTICES = 70
79  };
80 
81  uint8 numVertices = 0;
82  Point vertices[MAX_VERTICES];
83 };
84 
85 struct Color {
86  byte rgb[3];
87  uint8 &r = rgb[0];
88  uint8 &g = rgb[1];
89  uint8 &b = rgb[2];
90 
91  Color() {
92  clear();
93  }
94  void clear() {
95  r = g = b = 0;
96  }
97 };
98 
99 struct Frac {
100  static const int BITS = 16;
101  static const int MASK = (1 << BITS) - 1;
102  uint32 inc = 0;
103  uint64 offset = 0;
104 
105  void reset(int n, int d) {
106  inc = (((int64)n) << BITS) / d;
107  offset = 0;
108  }
109 
110  uint32 getInt() const {
111  return offset >> BITS;
112  }
113  uint32 getFrac() const {
114  return offset & MASK;
115  }
116  int interpolate(int sample1, int sample2) const {
117  const int fp = getFrac();
118  return (sample1 * (MASK - fp) + sample2 * fp) >> BITS;
119  }
120 };
121 
122 } // namespace Awe
123 
124 #endif
Definition: intern.h:65
Definition: intern.h:85
Definition: intern.h:99
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: rect.h:144
Definition: aifc_player.h:29
Definition: intern.h:76
Definition: intern.h:50
Language
Definition: language.h:45