Initial commit
This commit is contained in:
50
engines/bagel/hodjnpodj/libs/array.h
Normal file
50
engines/bagel/hodjnpodj/libs/array.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_HODJNPODJ_LIBS_ARRAY_H
|
||||
#define BAGEL_HODJNPODJ_LIBS_ARRAY_H
|
||||
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
template<class T>
|
||||
class Array : public Common::Array<T> {
|
||||
public:
|
||||
int indexOf(const T elem) const {
|
||||
for (uint i = 0; i < this->size(); ++i) {
|
||||
if (this->operator[](i) == elem)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void remove(T elem) {
|
||||
int idx = this->indexOf(elem);
|
||||
if (idx != -1)
|
||||
this->remove_at(idx);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
72
engines/bagel/hodjnpodj/libs/dialog_unit.h
Normal file
72
engines/bagel/hodjnpodj/libs/dialog_unit.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_HODJNPODJ_LIBS_DIALOG_UNIT_H
|
||||
#define BAGEL_HODJNPODJ_LIBS_DIALOG_UNIT_H
|
||||
|
||||
#include "common/rect.h"
|
||||
#include "bagel/hodjnpodj/gfx/gfx_surface.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
constexpr double X_FACTOR = 4.6;
|
||||
|
||||
struct DialogPoint : public Common::Point {
|
||||
public:
|
||||
DialogPoint(int xx, int yy) {
|
||||
GfxSurface s;
|
||||
s.setFontSize(8);
|
||||
this->x = (xx * s.getStringWidth("X")) / X_FACTOR;
|
||||
this->y = (yy * s.getStringHeight()) / 8;
|
||||
}
|
||||
DialogPoint(int fontSize, int xx, int yy) {
|
||||
GfxSurface s;
|
||||
s.setFontSize(fontSize);
|
||||
this->x = (xx * s.getStringWidth("X")) / X_FACTOR;
|
||||
this->y = (yy * s.getStringHeight()) / 8;
|
||||
}
|
||||
};
|
||||
|
||||
struct DialogRect : public Common::Rect {
|
||||
public:
|
||||
DialogRect(int x, int y, int w, int h) {
|
||||
GfxSurface s;
|
||||
s.setFontSize(8);
|
||||
left = (x * s.getStringWidth("X")) / X_FACTOR;
|
||||
top = (y * s.getStringHeight()) / 8;
|
||||
right = left + (w * s.getStringWidth("X")) / X_FACTOR;
|
||||
bottom = top + (h * s.getStringHeight()) / 8;
|
||||
}
|
||||
DialogRect(int fontSize, int x, int y, int w, int h) {
|
||||
GfxSurface s;
|
||||
s.setFontSize(fontSize);
|
||||
left = (x * s.getStringWidth("X")) / X_FACTOR;
|
||||
top = (y * s.getStringHeight()) / 8;
|
||||
right = left + (w * s.getStringWidth("X")) / X_FACTOR;
|
||||
bottom = top + (h * s.getStringHeight()) / 8;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
35
engines/bagel/hodjnpodj/libs/macros.h
Normal file
35
engines/bagel/hodjnpodj/libs/macros.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_HODJNPODJ_LIBS_MACROS_H
|
||||
#define BAGEL_HODJNPODJ_LIBS_MACROS_H
|
||||
|
||||
#define EM(X) ErrorLog(".\\msg.log",(X));
|
||||
#define EMCR() ErrorLog(".\\msg.log","\n");
|
||||
#define EMTime(t) ErrorLog(".\\msg.log","%s",_strtime(t));
|
||||
#define EMLoc(i) ErrorLog(".\\msg.log","Locals Dump #%d",(i));
|
||||
|
||||
#define DMint(X) ErrorLog(".\\msg.log",#X"=%d",(X));
|
||||
#define DMstr(X) ErrorLog(".\\msg.log",#X"=%s",(X));
|
||||
#define DMaddr(X) {\
|
||||
(X)? ErrorLog(".\\msg.log",#X"=%p",(void _far*)(X)) : ErrorLog(".\\msg.log",#X"is nullptr"); }
|
||||
|
||||
#endif
|
||||
79
engines/bagel/hodjnpodj/libs/stdinc.h
Normal file
79
engines/bagel/hodjnpodj/libs/stdinc.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_HODJNPODJ_LIBS_VECTOR_H
|
||||
#define BAGEL_HODJNPODJ_LIBS_VECTOR_H
|
||||
|
||||
#include "bagel/boflib/stdinc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define PI (double)3.141592653
|
||||
#define RADCNVT ((double)180/PI) // PI is 180 degrees
|
||||
|
||||
#define Deg2Rad(d) (d/RADCNVT) // converts degrees to radians
|
||||
#define Rad2Deg(r) (r*RADCNVT) // converts radians to degrees
|
||||
|
||||
typedef Bagel::Vector VECTOR;
|
||||
|
||||
class CVector : public VECTOR {
|
||||
public:
|
||||
CVector();
|
||||
CVector(const VECTOR &src);
|
||||
CVector(double xx, double yy, double zz = 0);
|
||||
|
||||
// vector operations
|
||||
void Unitize();
|
||||
void Normalize();
|
||||
void SetVector(double xx, double yy, double zz = 0);
|
||||
double DotProduct(const VECTOR &rhs) const;
|
||||
void Rotate(double angle);
|
||||
void Reflect(const VECTOR &rhs);
|
||||
double AngleBetween(const VECTOR &rhs);
|
||||
double RealAngle(const VECTOR &rhs);
|
||||
double Length() const;
|
||||
|
||||
// Generic operations
|
||||
CVector operator +(const VECTOR &rhs) const;
|
||||
CVector operator +(double) const;
|
||||
CVector operator -(const VECTOR &rhs) const;
|
||||
CVector operator -(double) const;
|
||||
CVector operator *(double) const;
|
||||
CVector operator /(double) const;
|
||||
void operator +=(const VECTOR &rhs);
|
||||
void operator -=(const VECTOR &rhs);
|
||||
void operator *=(double);
|
||||
void operator /=(double);
|
||||
bool operator ==(const VECTOR &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
// misc Vector add-ons
|
||||
extern double distanceBetweenPoints(const VECTOR &v1, const VECTOR &v2);
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
253
engines/bagel/hodjnpodj/libs/vector.cpp
Normal file
253
engines/bagel/hodjnpodj/libs/vector.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bagel/hodjnpodj/libs/vector.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define UNIT_VECTOR_LENGTH 1
|
||||
|
||||
CVector::CVector() {
|
||||
x = y = z = 0;
|
||||
}
|
||||
|
||||
CVector::CVector(const VECTOR &src) {
|
||||
x = src.x;
|
||||
y = src.y;
|
||||
z = src.z;
|
||||
}
|
||||
|
||||
CVector::CVector(double xx, double yy, double zz) {
|
||||
x = xx;
|
||||
y = yy;
|
||||
z = zz;
|
||||
}
|
||||
|
||||
void CVector::Unitize() {
|
||||
double w;
|
||||
|
||||
// avoid division by zero errors
|
||||
assert(this->x != 0 || this->y != 0);
|
||||
|
||||
w = UNIT_VECTOR_LENGTH / (this->x * this->x + this->y * this->y);
|
||||
*this *= sqrt(w);
|
||||
}
|
||||
|
||||
void CVector::Normalize() {
|
||||
double length;
|
||||
|
||||
length = Length();
|
||||
|
||||
assert(length != 0);
|
||||
|
||||
if (length != 0) {
|
||||
this->x /= length;
|
||||
this->y /= length;
|
||||
}
|
||||
}
|
||||
|
||||
void CVector::SetVector(double xx, double yy, double zz) {
|
||||
x = xx;
|
||||
y = yy;
|
||||
z = zz;
|
||||
}
|
||||
|
||||
|
||||
double CVector::Length() const {
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
|
||||
double CVector::AngleBetween(const VECTOR &rhs) {
|
||||
CVector vTmp(rhs);
|
||||
double fCos, angle;
|
||||
|
||||
// Get the angle by getting the arc-cosine of the cosine of the
|
||||
// angle between the 2 vectors.
|
||||
fCos = this->DotProduct(vTmp) / (this->Length() * vTmp.Length());
|
||||
|
||||
if (fCos > 1.0) {
|
||||
fCos = 1.0;
|
||||
} else if (fCos < -1.0) {
|
||||
fCos = -1.0;
|
||||
}
|
||||
|
||||
angle = acos(fCos);
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
double CVector::DotProduct(const VECTOR &rhs) const {
|
||||
return (x * rhs.x) + (y * rhs.y);
|
||||
}
|
||||
|
||||
void CVector::Reflect(const VECTOR &vMirror) {
|
||||
CVector vTmp(vMirror);
|
||||
double angle, length;
|
||||
|
||||
// Unitize the vectors (scale the vector so it's length is 1 pixel)
|
||||
//
|
||||
length = this->Length();
|
||||
|
||||
this->Unitize();
|
||||
vTmp.Unitize();
|
||||
|
||||
angle = this->AngleBetween(vTmp);
|
||||
|
||||
// the vector reflection: R = 2 * N * cos(angle) - L
|
||||
*this = (vTmp * cos(angle) * 2 - *this) * length;
|
||||
}
|
||||
|
||||
void CVector::Rotate(double angle) {
|
||||
double co, si, xx, yy;
|
||||
|
||||
// get the sine and cosine of the angle
|
||||
co = cos(angle);
|
||||
si = sin(angle);
|
||||
|
||||
xx = this->x * co - this->y * si;
|
||||
yy = this->y * co + this->x * si;
|
||||
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
|
||||
double CVector::RealAngle(const VECTOR &rhs) {
|
||||
CVector vTmp;
|
||||
double angle;
|
||||
|
||||
vTmp = *this;
|
||||
angle = vTmp.AngleBetween(rhs);
|
||||
|
||||
if (angle != (double)0.0) {
|
||||
|
||||
vTmp.Rotate(angle);
|
||||
|
||||
// determine if the angle is greater then 180 degrees
|
||||
//
|
||||
if (((int)(vTmp.AngleBetween(rhs) * 1000) == 0)) {
|
||||
angle = 2 * PI - angle;
|
||||
}
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator +(const VECTOR &rhs) const {
|
||||
CVector vSum(this->x + rhs.x, this->y + rhs.y, this->z + rhs.z);
|
||||
|
||||
return vSum;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator +(double offset) const {
|
||||
CVector vSum(this->x + offset, this->y + offset, this->z + offset);
|
||||
|
||||
return vSum;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator -(const VECTOR &rhs) const {
|
||||
CVector vDif(this->x - rhs.x, this->y - rhs.y, this->z - rhs.z);
|
||||
|
||||
return vDif;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator -(double offset) const {
|
||||
CVector vDif(this->x - offset, this->y - offset, this->z - offset);
|
||||
|
||||
return vDif;
|
||||
}
|
||||
|
||||
|
||||
void CVector::operator +=(const VECTOR &rhs) {
|
||||
this->x += rhs.x;
|
||||
this->y += rhs.y;
|
||||
this->z += rhs.z;
|
||||
}
|
||||
|
||||
|
||||
void CVector::operator -=(const VECTOR &rhs) {
|
||||
this->x -= rhs.x;
|
||||
this->y -= rhs.y;
|
||||
this->z -= rhs.z;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator *(double scalar) const {
|
||||
CVector vProduct(this->x * scalar, this->y * scalar, this->z * scalar);
|
||||
|
||||
return vProduct;
|
||||
}
|
||||
|
||||
|
||||
CVector CVector::operator /(double scalar) const {
|
||||
// can't divide by 0
|
||||
assert(scalar != (double)0.0);
|
||||
|
||||
CVector vDividend;
|
||||
|
||||
if (scalar != (double)0.0) {
|
||||
vDividend.x = this->x / scalar;
|
||||
vDividend.y = this->y / scalar;
|
||||
vDividend.z = this->z / scalar;
|
||||
}
|
||||
|
||||
return vDividend;
|
||||
}
|
||||
|
||||
|
||||
void CVector::operator *=(double scalar) {
|
||||
this->x *= scalar;
|
||||
this->y *= scalar;
|
||||
this->z *= scalar;
|
||||
}
|
||||
|
||||
|
||||
void CVector::operator /=(double scalar) {
|
||||
// can't divide by 0
|
||||
assert(scalar != (double)0.0);
|
||||
|
||||
if (scalar != (double)0.0) {
|
||||
this->x /= scalar;
|
||||
this->y /= scalar;
|
||||
this->z /= scalar;
|
||||
}
|
||||
}
|
||||
|
||||
bool CVector::operator ==(const VECTOR &v) const {
|
||||
bool bReturn = ((this->x == v.x) && (this->y == v.y));
|
||||
return bReturn;
|
||||
}
|
||||
|
||||
|
||||
double distanceBetweenPoints(const VECTOR &v1, const VECTOR &v2) {
|
||||
CVector vTmp(v1.x - v2.x, v1.y - v2.y, 0);
|
||||
|
||||
return vTmp.Length();
|
||||
}
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
79
engines/bagel/hodjnpodj/libs/vector.h
Normal file
79
engines/bagel/hodjnpodj/libs/vector.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BAGEL_HODJNPODJ_LIBS_VECTOR_H
|
||||
#define BAGEL_HODJNPODJ_LIBS_VECTOR_H
|
||||
|
||||
#include "bagel/boflib/stdinc.h"
|
||||
|
||||
namespace Bagel {
|
||||
namespace HodjNPodj {
|
||||
|
||||
#define PI (double)3.141592653
|
||||
#define RADCNVT ((double)180/PI) // PI is 180 degrees
|
||||
|
||||
#define Deg2Rad(d) (d/RADCNVT) // converts degrees to radians
|
||||
#define Rad2Deg(r) (r*RADCNVT) // converts radians to degrees
|
||||
|
||||
typedef Bagel::Vector VECTOR;
|
||||
|
||||
class CVector : public VECTOR {
|
||||
public:
|
||||
CVector();
|
||||
CVector(const VECTOR &src);
|
||||
CVector(double xx, double yy, double zz = 0);
|
||||
|
||||
// vector operations
|
||||
void Unitize();
|
||||
void Normalize();
|
||||
void SetVector(double xx, double yy, double zz = 0);
|
||||
double DotProduct(const VECTOR &rhs) const;
|
||||
void Rotate(double angle);
|
||||
void Reflect(const VECTOR &rhs);
|
||||
double AngleBetween(const VECTOR &rhs);
|
||||
double RealAngle(const VECTOR &rhs);
|
||||
double Length() const;
|
||||
|
||||
// Generic operations
|
||||
CVector operator +(const VECTOR &rhs) const;
|
||||
CVector operator +(double) const;
|
||||
CVector operator -(const VECTOR &rhs) const;
|
||||
CVector operator -(double) const;
|
||||
CVector operator *(double) const;
|
||||
CVector operator /(double) const;
|
||||
void operator +=(const VECTOR &rhs);
|
||||
void operator -=(const VECTOR &rhs);
|
||||
void operator *=(double);
|
||||
void operator /=(double);
|
||||
bool operator ==(const VECTOR &rhs) const;
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
// misc Vector add-ons
|
||||
extern double distanceBetweenPoints(const VECTOR &v1, const VECTOR &v2);
|
||||
|
||||
} // namespace HodjNPodj
|
||||
} // namespace Bagel
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user