From d7695542cdd486dbb29e3cc7d0bc8c317760d185 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 6 Sep 2011 00:16:07 +0200 Subject: CGE: Remove various defines and functions from "general" Those were already present in ScummVM (thanks Fingolfin for point out) --- engines/cge/cge_main.cpp | 4 ++-- engines/cge/events.cpp | 2 +- engines/cge/general.cpp | 35 ----------------------------------- engines/cge/general.h | 23 ----------------------- engines/cge/snail.cpp | 8 ++++---- engines/cge/text.cpp | 4 ++-- 6 files changed, 9 insertions(+), 67 deletions(-) (limited to 'engines') diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 9b1afed245..5970a3e339 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -691,8 +691,8 @@ System::System(CGEEngine *vm) : Sprite(vm, NULL), _vm(vm) { } void System::setPal() { - Dac *p = _vga->_sysPal + 256 - ArrayCount(_stdPal); - for (uint i = 0; i < ArrayCount(_stdPal); i++) { + Dac *p = _vga->_sysPal + 256 - ARRAYSIZE(_stdPal); + for (uint i = 0; i < ARRAYSIZE(_stdPal); i++) { p[i]._r = _stdPal[i]._r >> 2; p[i]._g = _stdPal[i]._g >> 2; p[i]._b = _stdPal[i]._b >> 2; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index 9cbf889dfe..072771ebac 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -94,7 +94,7 @@ Keyboard::~Keyboard() { } Sprite *Keyboard::setClient(Sprite *spr) { - swap(_client, spr); + SWAP(_client, spr); return spr; } diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index c20da2466c..8fbf545535 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -124,30 +124,6 @@ char *forceExt(char *buf, const char *name, const char *ext) { return buf; } -uint16 atow(const char *a) { - if (!a) - return 0; - - uint16 w = 0; - while (IsDigit(*a)) - w = (10 * w) + (*(a++) & 0xF); - return w; -} - -uint16 xtow(const char *x) { - if (!x) - return 0; - - uint16 w = 0; - while (IsHxDig(*x)) { - register uint16 d = *(x++); - if (d > '9') - d -= 'A' - ('9' + 1); - w = (w << 4) | (d & 0xF); - } - return w; -} - char *wtom(uint16 val, char *str, int radix, int len) { while (--len >= 0) { uint16 w = val % radix; @@ -159,17 +135,6 @@ char *wtom(uint16 val, char *str, int radix, int len) { return str; } -char *dwtom(uint32 val, char *str, int radix, int len) { - while (--len >= 0) { - uint16 w = (uint16) (val % radix); - if (w > 9) - w += ('A' - ('9' + 1)); - str[len] = '0' + w; - val /= radix; - } - return str; -} - void sndSetVolume() { // USeless for ScummVM } diff --git a/engines/cge/general.h b/engines/cge/general.h index ad5abba6b1..33abd1e852 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -38,9 +38,6 @@ namespace CGE { #define kCryptSeed 0xA5 #define kMaxFile 128 -#define IsDigit(c) ((c) >= '0' && (c) <= '9') -#define IsHxDig(c) (IsDigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) struct Dac { uint8 _r; @@ -50,27 +47,7 @@ struct Dac { typedef uint16 Crypt(void *buf, uint16 siz, uint16 seed); -template -void swap(T &A, T &B) { - T a = A; - A = B; - B = a; -} - -template -T max(T A, T B) { - return (A > B) ? A : B; -} - -template -T min(T A, T B) { - return (A < B) ? A : B; -} - -uint16 atow(const char *a); -uint16 xtow(const char *x); char *wtom(uint16 val, char *str, int radix, int len); -char *dwtom(uint32 val, char *str, int radix, int len); int takeEnum(const char **tab, const char *text); uint16 chkSum(void *m, uint16 n); char *mergeExt(char *buf, const char *name, const char *ext); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index bffbe7c628..2d15b61d97 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -587,10 +587,10 @@ void CGEEngine::snSwap(Sprite *spr, int xref) { bool was1 = (was == 0 || was == _now); bool xwas1 = (xwas == 0 || xwas == _now); - swap(spr->_cave, xspr->_cave); - swap(spr->_x, xspr->_x); - swap(spr->_y, xspr->_y); - swap(spr->_z, xspr->_z); + SWAP(spr->_cave, xspr->_cave); + SWAP(spr->_x, xspr->_x); + SWAP(spr->_y, xspr->_y); + SWAP(spr->_z, xspr->_z); if (spr->_flags._kept) { int n = findPocket(spr); if (n >= 0) diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index 973aadd23a..6076fdd8ff 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -92,7 +92,7 @@ void Text::preload(int from, int upto) { char *s; if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (!IsDigit(*s)) + if (!isdigit(*s)) continue; int ref = atoi(s); @@ -136,7 +136,7 @@ char *Text::load(int idx, int ref) { line[-- n] = '\0'; if ((s = strtok(line, " =,;/\t\n")) == NULL) continue; - if (!IsDigit(*s)) + if (!isdigit(*s)) continue; int r = atoi(s); -- cgit v1.2.3