ScummVM API documentation
fixed.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BOFLIB_FIXED_H
24 #define BAGEL_BOFLIB_FIXED_H
25 
26 #include "bagel/boflib/object.h"
27 #include "bagel/boflib/misc.h"
28 
29 namespace Bagel {
30 namespace SpaceBar {
31 
32 class CBofFixed : public CBofObject {
33 private:
34  Fixed _lVal;
35  CBofFixed(const Fixed Arg) {
36  _lVal = Arg;
37  }
38 
39 public:
40  // Constructors
41  CBofFixed() {
42  _lVal = 0L;
43  }
44  CBofFixed(const CBofFixed &Arg) {
45  _lVal = Arg._lVal;
46  }
47  CBofFixed(const int Arg) {
48  _lVal = (Fixed)(((long)(Arg)) << 16);
49  }
50  CBofFixed(const double Arg) {
51  _lVal = (Fixed)(Arg * (1 << 16));
52  }
53 
54  // Operators
55  // inline CBofFixed operator =(const CBofFixed& Arg) const;
56  CBofFixed operator+(const CBofFixed &Arg) const {
57  return _lVal + Arg._lVal;
58  }
59  CBofFixed operator-(const CBofFixed &Arg) const {
60  return _lVal - Arg._lVal;
61  }
62 
63  CBofFixed operator*(const CBofFixed &Arg) const {
64  return fixedMultiply(_lVal, Arg._lVal);
65  }
66 
67  CBofFixed operator/(const CBofFixed &Arg) const {
68  return fixedDivide(_lVal, Arg._lVal);
69  }
70 
71  CBofFixed operator-=(const CBofFixed &Arg) {
72  _lVal -= Arg._lVal;
73  return *this;
74  }
75 
76  CBofFixed operator+=(const CBofFixed &Arg) {
77  _lVal += Arg._lVal;
78  return *this;
79  }
80 
81  CBofFixed operator*=(const CBofFixed &Arg) {
82  _lVal = _lVal * Arg._lVal;
83 
84  return *this;
85  }
86 
87  CBofFixed operator/=(const CBofFixed &Arg) {
88  _lVal = _lVal / Arg._lVal;
89 
90  return *this;
91  }
92 
93  CBofFixed operator=(const CBofFixed &Arg) {
94  _lVal = Arg._lVal;
95  return *this;
96  }
97 
98  // Conversion operators
99  operator int() {
100  return (int)(((int32)_lVal) >> 16);
101  }
102 };
103 
104 } // namespace SpaceBar
105 } // namespace Bagel
106 
107 #endif
Definition: object.h:28
Definition: afxwin.h:27
Definition: fixed.h:32