ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
types.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef ROLAND_TYPES_H
21 #define ROLAND_TYPES_H
22 
23 #include <cstdint>
24 #include <string>
25 
27 namespace sdltk
28 {
29  typedef std::string String;
30 }
31 typedef std::string tSTRING;
32 
33 
34 //enum Bits {Bit0=1, Bit1=2, Bit2=4, Bit3=8, Bit4=16, Bit5=32, Bit6=64, Bit7=128};
35 
36 // **************
37 // *** signed ***
38 // **************
39 #ifndef tBYTE
40  typedef int8_t tBYTE;
41 #else
42  #error "*** tBYTE is already defined and may not match requested size. ***"
43 #endif
44 
45 #ifndef tWORD
46  typedef int16_t tWORD;
47 #else
48  #error "*** tWORD is already defined and may not match requested size. ***"
49 #endif
50 
51 #ifndef tDWORD
52  typedef int32_t tDWORD;
53 #else
54  #error "*** tDWORD is already defined and may not match requested size. ***"
55 #endif
56 
57 #ifndef tQWORD
58  typedef int64_t tQWORD;
59 #else
60  #error "*** tQWORD is already defined and may not match requested size. ***"
61 #endif
62 
63 #ifndef tINT64
64  typedef int64_t tINT64;
65 #else
66  #error "*** tINT64 is already defined and may not match requested size. ***"
67 #endif
68 
69 
70 // ****************
71 // *** unsigned ***
72 // ****************
73 #ifndef tBYTE
74  typedef uint8_t tUBYTE;
75 #else
76  #error "*** tUBYTE is already defined and may not match requested size. ***"
77 #endif
78 
79 #ifndef tWORD
80  typedef uint16_t tUWORD;
81 #else
82  #error "*** tUWORD is already defined and may not match requested size. ***"
83 #endif
84 
85 #ifndef tDWORD
86  typedef uint32_t tUDWORD;
87 #else
88  #error "*** tUDWORD is already defined and may not match requested size. ***"
89 #endif
90 
91 #ifndef tQWORD
92  typedef uint64_t tUQWORD;
93 #else
94  #error "*** tUQWORD is already defined and may not match requested size. ***"
95 #endif
96 
97 #ifndef tINT64
98  typedef uint64_t tUINT64;
99 #else
100  #error "*** tUINT64 is already defined and may not match requested size. ***"
101 #endif
102 
103 
104 #ifndef tREGPAIR
105  typedef union
106  {
107  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
108  struct { tUBYTE l, h, h2, h3; } b;
109  struct { tUWORD l, h; } w;
110  #else
111  struct { tUBYTE h3, h2, h, l; } b;
112  struct { tUWORD h, l; } w;
113  #endif
114  tDWORD d;
115  } tREGPAIR;
116 #else
117  #error "*** tREGPAIR is already defined and may not match requested size. ***"
118 #endif
119 
120 #ifndef uint
121  typedef unsigned int uint;
122 #else
123  #warning "*** uint is already defined and may not match requested size. ***"
124 #endif
125 
126 #ifndef uchar
127  typedef unsigned char uchar;
128 #else
129  #warning "*** uchar is already defined and may not match requested size. ***"
130 #endif
131 
132 
134 static const tUBYTE bit_values[8] =
135 {
136  0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
137 };
138 
139 
140 
141 /*
142 class tWORD
143 {
144 public:
145  tWORD() {}
146  ~tWORD() {}
147 
148  operator short int() {return mValue.Both;}
149  tWORD & operator=(const short int & w)
150  {mValue.Both=w; return *this;}
151  tWORD & operator--()
152  {mValue.Both--; return *this;}
153 
154  tBYTE low() {return mValue.Low;}
155  tBYTE high() {return mValue.High;}
156 
157  void setLow (tBYTE w) {mValue.Low = w;}
158  void setHigh(tBYTE w) {mValue.High = w;}
159 
160 private:
161  typedef union
162  {
163  struct
164  {
165  tBYTE Low;
166  tBYTE High;
167  };
168  short int Both;
169  } WORD_t;
170 
171  WORD_t mValue;
172 };
173 
174 class tUWORD
175 {
176 public:
177  tUWORD() {}
178  tUWORD(unsigned short int v) {mValue.Both=v;}
179  ~tUWORD() {}
180 
181  operator unsigned short int() {return mValue.Both;}
182  operator uint() {return (uint) mValue.Both;}
183  operator int() {return (int) mValue.Both;}
184  operator bool() {return (bool) mValue.Both;}
185 
186  //tUWORD operator+ (const tUWORD & w)
187  // {return tUWORD(mValue.Both + w.both());}
188 
189  tUWORD operator-(const int & w)
190  {return tUWORD(mValue.Both - (unsigned short int) w);}
191 
192  tUWORD operator+(const int & w)
193  {return tUWORD(mValue.Both + (unsigned short int) w);}
194 
195  tUWORD operator*(const int & w)
196  {return tUWORD(mValue.Both * (unsigned short int) w);}
197 
198  tUWORD* operator&(tUWORD & w)
199  {return w.ptr();}
200 
201  tUWORD & operator=(const unsigned short int & w)
202  {mValue.Both=w; return *this;}
203 
204  tUWORD & operator-=(const unsigned short int & w)
205  {mValue.Both-=w; return *this;}
206 
207  tUWORD & operator+=(const unsigned short int & w)
208  {mValue.Both+=w; return *this;}
209 
210  bool operator<(const tUWORD & v) const
211  {return (bool) (mValue.Both < v.both());}
212  bool operator<=(const tUWORD & v) const
213  {return (bool) (mValue.Both <= v.both());}
214  bool operator>(const tUWORD & v) const
215  {return (bool) (mValue.Both > v.both());}
216  bool operator>=(const tUWORD & v) const
217  {return (bool) (mValue.Both >= v.both());}
218  bool operator==(const tUWORD & v) const
219  {return (bool) (mValue.Both == v.both());}
220  bool operator!=(const tUWORD & v) const
221  {return (bool) (mValue.Both != v.both());}
222 
223  */
224 
225  /*
226  bool operator<(const unsigned short int & v) const
227  {return (bool) (mValue.Both < v);}
228  bool operator<=(const unsigned short int & v) const
229  {return (bool) (mValue.Both <= v);}
230  bool operator>(const unsigned short int & v) const
231  {return (bool) (mValue.Both > v);}
232  bool operator>=(const unsigned short int & v) const
233  {return (bool) (mValue.Both >= v);}
234  bool operator==(const unsigned short int & v) const
235  {return (bool) (mValue.Both == v);}
236  bool operator!=(const unsigned short int & v) const
237  {return (bool) (mValue.Both != v);}
238  */
239 
240 /*
241  tUWORD & operator--()
242  {--mValue.Both; return *this;}
243 
244  tUWORD operator--(int)
245  {tUWORD tmp(*this);--mValue.Both; return tmp;}
246 
247  tUWORD & operator++()
248  {++mValue.Both; return *this;}
249 
250  tUWORD operator++(int)
251  {tUWORD tmp(*this);++mValue.Both; return tmp;}
252 
253 
254  tUBYTE low() {return mValue.Low;}
255  tUBYTE high() {return mValue.High;}
256 
257  const unsigned short int both() const {return mValue.Both;}
258 
259  void setLow (tUBYTE w) {mValue.Low = w;}
260  void setHigh(tUBYTE w) {mValue.High = w;}
261 
262  tUWORD* ptr() {return this;}
263 
264 private:
265  typedef union
266  {
267  struct
268  {
269  tUBYTE Low;
270  tUBYTE High;
271  };
272  unsigned short int Both;
273  } UWORD_t;
274 
275  UWORD_t mValue;
276 };
277 */
278 
279 #endif // ROLAND_TYPES_H
280 
std::string tSTRING
Definition: types.h:31
GLuint GLfloat GLenum cap GLsizei GLuint *textures GLenum GLint *params void GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLfloat GLfloat y GLubyte GLubyte GLubyte b
Definition: glfunclist.h:27
uint32_t tUDWORD
Definition: types.h:86
unsigned char uchar
Definition: types.h:127
int64_t tINT64
Definition: types.h:64
uint64_t tUINT64
Definition: types.h:98
static const tUBYTE bit_values[8]
Definition: types.h:134
uint64_t tUQWORD
Definition: types.h:92
int8_t tBYTE
Definition: types.h:40
uint8_t tUBYTE
Definition: types.h:74
unsigned int uint
Definition: types.h:121
uint16_t tUWORD
Definition: types.h:80
int16_t tWORD
Definition: types.h:46
std::string String
Definition: types.h:29
int64_t tQWORD
Definition: types.h:58
the SDL based Stuff
Definition: audio.cpp:22
int32_t tDWORD
Definition: types.h:52