30#include "common/serializer.h"
31#include "common/events.h"
32#include "graphics/surface.h"
33#include "cge2/general.h"
34#include "cge2/bitmap.h"
35#include "cge2/snail.h"
36#include "cge2/spare.h"
42#define kVgaColDark 207
43#define kVgaColDarkGray 225
44#define kVgaColGray 231
45#define kVgaColLightGray 237
46#define kPixelTransp 0xFE
48#define kNoPtr ((uint8)-1)
51#define kPalSize (kPalCount * 3)
57 FXP (
int i0,
int f0 = 0) : v((i0 * 256) + ((i0 < 0) ? -f0 : f0)) {}
58 FXP &operator=(
const int &x) { v = x << 8;
return *
this; }
59 FXP operator+(
const FXP &x)
const {
FXP y; y.v = v + x.v;
return y; }
60 FXP operator-(
const FXP &x)
const {
FXP y; y.v = v - x.v;
return y; }
61 FXP operator*(
const FXP &x)
const;
62 FXP operator/(
const FXP &x)
const;
64 friend int &operator+=(
int &a,
const FXP &b) {
return a += b.trunc(); }
65 friend int &operator-=(
int &a,
const FXP &b) {
return a -= b.trunc(); }
66 friend FXP &operator+=(
FXP &a,
const int &b) { a.v += b << 8;
return a; }
67 friend FXP &operator-=(
FXP &a,
const int &b) { a.v -= b << 8;
return a; }
68 friend bool operator==(
const FXP &a,
const FXP &b) {
return a.v == b.v; }
69 friend bool operator!=(
const FXP &a,
const FXP &b) {
return a.v != b.v; }
70 friend bool operator<(
const FXP &a,
const FXP &b) {
return a.v < b.v; }
71 friend bool operator>(
const FXP &a,
const FXP &b) {
return a.v > b.v; }
72 int trunc(
void)
const {
return v >> 8; }
73 int round(
void)
const {
return (v + 0x80) >> 8; }
74 bool empty()
const {
return v == 0; }
83 V3D operator+(
const V3D &p)
const {
return V3D(_x + p._x, _y + p._y, _z + p._z); }
84 V3D operator-(
const V3D &p)
const {
return V3D(_x - p._x, _y - p._y, _z - p._z); }
85 V3D operator*(
long n)
const {
return V3D(_x * n, _y * n, _z * n); }
86 V3D operator/ (
long n)
const {
return V3D(_x / n, _y / n, _z / n); }
87 bool operator==(
const V3D &p)
const {
return _x == p._x && _y == p._y && _z == p._z; }
88 bool operator!=(
const V3D &p)
const {
return _x != p._x || _y != p._y || _z != p._z; }
89 V3D& operator+=(
const V3D &x) {
return *
this = *
this + x; }
90 V3D& operator-=(
const V3D &x) {
return *
this = *
this - x; }
97 V2D &operator=(
const V3D &p3) {
98 FXP m = _vm->_eye->_z / (p3._z - _vm->_eye->_z);
99 FXP posx = _vm->_eye->_x + (_vm->_eye->_x - p3._x) * m;
101 FXP posy = _vm->_eye->_y + (_vm->_eye->_y - p3._y) * m;
108 bool operator<(
const V2D &p)
const {
return (
x < p.
x) && (
y < p.
y); }
109 bool operator<=(
const V2D &p)
const {
return (
x <= p.
x) && (
y <= p.
y); }
110 bool operator>(
const V2D &p)
const {
return (
x > p.
x) && (
y > p.
y); }
111 bool operator>=(
const V2D &p)
const {
return (
x >= p.
x) && (
y >= p.
y); }
112 V2D operator+(
const V2D &p)
const {
return V2D(_vm,
x + p.
x,
y + p.
y); }
113 V2D operator-(
const V2D &p)
const {
return V2D(_vm,
x - p.
x,
y - p.
y); }
114 bool operator==(
const V3D &p)
const {
V3D tmp(
x,
y);
return tmp._x == p._x && tmp._y == p._y && tmp._z == p._z; }
115 bool operator!=(
const V3D &p)
const {
V3D tmp(
x,
y);
return tmp._x != p._x || tmp._y != p._y || tmp._z == p._z; }
116 bool operator==(
const V2D &p)
const {
return x == p.
x &&
y == p.
y; }
117 uint16 area() {
return x *
y; }
118 bool limited(
const V2D &p) {
119 return ((
x < p.
x) && (
y < p.
y));
122 FXP m = _vm->_eye->_z / (_vm->_eye->_z - z);
125 return V2D(_vm, posx.trunc(), posy.trunc());
181 struct {
byte _ptr, _cnt; } _actionCtrl[kActions];
185 char _file[kMaxFile];
191 static Seq _stdSeq8[];
195 inline bool active() {
196 return _ext !=
nullptr;
198 Sprite(CGE2Engine *vm);
199 Sprite(CGE2Engine *vm, BitmapPtr shp,
int cnt);
202 void setShapeList(BitmapPtr shp,
int cnt);
205 int labVal(Action snq,
int lab);
206 virtual Sprite *expand();
207 virtual Sprite *contract();
209 void setName(
char *newName);
210 inline char *name() {
211 return (_ext) ? _ext->_name :
nullptr;
213 void gotoxyz(
int x,
int y,
int z = 0);
215 void gotoxyz(V2D pos);
216 void gotoxyz_(V2D pos);
217 void gotoxyz(V3D pos);
219 void show(uint16 pg);
220 void hide(uint16 pg);
224 void step(
int nr = -1);
225 Seq *setSeq(Seq *seq);
226 CommandHandler::Command *snList(Action type);
227 virtual void touch(uint16 mask, V2D pos);
229 virtual void setScene(
int c);
230 void clrHide() {
if (_ext) _ext->_b0 =
nullptr; }
234 static void (*notify) ();
255 void clear() { _head = _tail =
nullptr; }
269 uint8 closest(
Dac *pal,
const uint8 colR,
const uint8 colG,
const uint8 colB);
277 struct { uint8 _org, _len, _cnt, _dly; } _rot;
282 uint8 *glass(
Dac *pal,
const uint8 colR,
const uint8 colG,
const uint8 colB);
283 void getColors(
Dac *tab);
284 void setColors(
Dac *tab,
int lum);
285 void clear(uint8 color);
286 void copyPage(uint16 d, uint16 s);
287 void sunrise(
Dac *tab);
292 uint8 closest(
Dac *pal,
Dac x);
294 void palToDac(
const byte *palData,
Dac *tab);
295 void dacToPal(
const Dac *tab,
byte *palData);
Definition: serializer.h:80
int16 y
Definition: rect.h:49
int16 x
Definition: rect.h:48