aboutsummaryrefslogtreecommitdiff
path: root/engines/cge
diff options
context:
space:
mode:
authorStrangerke2011-09-16 07:55:50 +0200
committerStrangerke2011-09-16 07:55:50 +0200
commit70c5b695df24dd9da6d7838939d3c448f602471a (patch)
treeeebe88633eef498525175328706963a27929ecff /engines/cge
parent15bf8050b822db25c3ab4802c0e8438d0151a3cd (diff)
downloadscummvm-rg350-70c5b695df24dd9da6d7838939d3c448f602471a.tar.gz
scummvm-rg350-70c5b695df24dd9da6d7838939d3c448f602471a.tar.bz2
scummvm-rg350-70c5b695df24dd9da6d7838939d3c448f602471a.zip
CGE: move two global functions to Vga
Diffstat (limited to 'engines/cge')
-rw-r--r--engines/cge/cge_main.cpp2
-rw-r--r--engines/cge/game.cpp13
-rw-r--r--engines/cge/game.h2
-rw-r--r--engines/cge/vga13h.cpp51
-rw-r--r--engines/cge/vga13h.h34
5 files changed, 45 insertions, 57 deletions
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index c5450aefd3..dde8fd1c11 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -674,7 +674,7 @@ void CGEEngine::sceneUp() {
if (_shadow) {
_vga->_showQ->remove(_shadow);
- _shadow->makeXlat(glass(_vga->_sysPal, 204, 204, 204));
+ _shadow->makeXlat(_vga->glass(_vga->_sysPal, 204, 204, 204));
_vga->_showQ->insert(_shadow, _hero);
_shadow->_z = _hero->_z;
}
diff --git a/engines/cge/game.cpp b/engines/cge/game.cpp
index f3855c147d..115de222ad 100644
--- a/engines/cge/game.cpp
+++ b/engines/cge/game.cpp
@@ -30,19 +30,6 @@
namespace CGE {
-uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b) {
- uint8 *x = (uint8 *)malloc(256);
- if (x) {
- uint16 i;
- for (i = 0; i < 256; i++) {
- x[i] = closest(pal, mkDac(((uint16)(pal[i]._r) * r) / 255,
- ((uint16)(pal[i]._g) * g) / 255,
- ((uint16)(pal[i]._b) * b) / 255));
- }
- }
- return x;
-}
-
const int Fly::_l = 20,
Fly::_t = 40,
Fly::_r = 110,
diff --git a/engines/cge/game.h b/engines/cge/game.h
index 63d686239e..88ef4344ba 100644
--- a/engines/cge/game.h
+++ b/engines/cge/game.h
@@ -32,8 +32,6 @@
namespace CGE {
-uint8 *glass(Dac *pal, uint8 r, uint8 g, uint8 b);
-
class Fly : public Sprite {
static const int _l;
static const int _t;
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index f0fbd630e1..3d092e755c 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -54,16 +54,6 @@ Seq *getConstantSeq(bool seqFlag) {
return seq;
}
-extern "C" void SNDMIDIPlay();
-
-Dac mkDac(uint8 r, uint8 g, uint8 b) {
- static Dac x;
- x._r = r;
- x._g = g;
- x._b = b;
- return x;
-}
-
Sprite::Sprite(CGEEngine *vm, BitmapPtr *shpP)
: _x(0), _y(0), _z(0), _nearPtr(0), _takePtr(0),
_next(NULL), _prev(NULL), _seqPtr(kNoSeq), _time(0),
@@ -722,6 +712,47 @@ void Vga::getColors(Dac *tab) {
palToDac(palData, tab);
}
+uint8 Vga::closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) {
+#define f(col, lum) ((((uint16)(col)) << 8) / lum)
+ uint16 i, dif = 0xFFFF, found = 0;
+ uint16 L = colR + colG + colB;
+ if (!L)
+ L++;
+ uint16 R = f(colR, L), G = f(colG, L), B = f(colB, L);
+ for (i = 0; i < 256; i++) {
+ uint16 l = pal[i]._r + pal[i]._g + pal[i]._b;
+ if (!l)
+ l++;
+ int r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l);
+ uint16 D = ((r > R) ? (r - R) : (R - r)) +
+ ((g > G) ? (g - G) : (G - g)) +
+ ((b > B) ? (b - B) : (B - b)) +
+ ((l > L) ? (l - L) : (L - l)) * 10 ;
+
+ if (D < dif) {
+ found = i;
+ dif = D;
+ if (D == 0)
+ break; // exact!
+ }
+ }
+ return found;
+#undef f
+}
+
+uint8 *Vga::glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB) {
+ uint8 *x = (uint8 *)malloc(256);
+ if (x) {
+ uint16 i;
+ for (i = 0; i < 256; i++) {
+ x[i] = closest(pal, ((uint16)(pal[i]._r) * colR) / 255,
+ ((uint16)(pal[i]._g) * colG) / 255,
+ ((uint16)(pal[i]._b) * colB) / 255);
+ }
+ }
+ return x;
+}
+
void Vga::palToDac(const byte *palData, Dac *tab) {
const byte *colP = palData;
for (int idx = 0; idx < kPalCount; idx++, colP += 3) {
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index f382e05a44..f52d8ba2f5 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -191,6 +191,8 @@ class Vga {
void updateColors();
void setColors();
void waitVR();
+ uint8 closest(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
+
public:
uint32 _frmCnt;
Queue *_showQ;
@@ -202,6 +204,7 @@ public:
Vga();
~Vga();
+ uint8 *glass(Dac *pal, const uint8 colR, const uint8 colG, const uint8 colB);
void getColors(Dac *tab);
void setColors(Dac *tab, int lum);
void clear(uint8 color);
@@ -235,37 +238,6 @@ public:
PocLight(CGEEngine *vm);
};
-Dac mkDac(uint8 r, uint8 g, uint8 b);
-
-template <class CBLK>
-uint8 closest(CBLK *pal, CBLK x) {
-#define f(col, lum) ((((uint16)(col)) << 8) / lum)
- uint16 i, dif = 0xFFFF, found = 0;
- uint16 L = x._r + x._g + x._b;
- if (!L)
- L++;
- uint16 R = f(x._r, L), G = f(x._g, L), B = f(x._b, L);
- for (i = 0; i < 256; i++) {
- uint16 l = pal[i]._r + pal[i]._g + pal[i]._b;
- if (!l)
- l++;
- int r = f(pal[i]._r, l), g = f(pal[i]._g, l), b = f(pal[i]._b, l);
- uint16 D = ((r > R) ? (r - R) : (R - r)) +
- ((g > G) ? (g - G) : (G - g)) +
- ((b > B) ? (b - B) : (B - b)) +
- ((l > L) ? (l - L) : (L - l)) * 10 ;
-
- if (D < dif) {
- found = i;
- dif = D;
- if (D == 0)
- break; // exact!
- }
- }
- return found;
-#undef f
-}
-
} // End of namespace CGE
#endif