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
30namespace Awe {
31
33
34enum {
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
46enum {
47 kPaulaFreq = 7159092
48};
49
50struct 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
65struct 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
76struct QuadStrip {
77 enum {
78 MAX_VERTICES = 70
79 };
80
81 uint8 numVertices = 0;
82 Point vertices[MAX_VERTICES];
83};
84
85struct 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
99struct 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
Language
Definition: language.h:45
Definition: intern.h:85
Definition: intern.h:99
Definition: intern.h:65
Definition: intern.h:50
Definition: intern.h:76
int16 y
Definition: rect.h:49
int16 x
Definition: rect.h:48
Definition: rect.h:144