diff options
author | Max Horn | 2003-06-19 16:03:12 +0000 |
---|---|---|
committer | Max Horn | 2003-06-19 16:03:12 +0000 |
commit | 440100606c60124ad7beb0b3195fc8669498d1bc (patch) | |
tree | 540cf52d6ed51514ec875e21e4dc2ff49390d340 /scumm | |
parent | 1cca50b7436d246217fc9a5b39e1f5b2204fe9dc (diff) | |
download | scummvm-rg350-440100606c60124ad7beb0b3195fc8669498d1bc.tar.gz scummvm-rg350-440100606c60124ad7beb0b3195fc8669498d1bc.tar.bz2 scummvm-rg350-440100606c60124ad7beb0b3195fc8669498d1bc.zip |
made scale table const again; some cleanup in setupBompScale
svn-id: r8559
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/akos.cpp | 8 | ||||
-rw-r--r-- | scumm/akos.h | 6 | ||||
-rw-r--r-- | scumm/bomp.cpp | 73 |
3 files changed, 31 insertions, 56 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 45ca226f68..7767c10063 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -408,9 +408,9 @@ void AkosRenderer::codec1_genericDecode() { } #ifdef __PALM_OS__ -byte *default_scale_table; +const byte *defaultScaleTable; #else -byte default_scale_table[768] = { +const byte defaultScaleTable[768] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, @@ -524,7 +524,7 @@ byte AkosRenderer::codec1(int xmoveCur, int ymoveCur) { /* implement custom scale table */ - v1.scaletable = default_scale_table; + v1.scaletable = defaultScaleTable; // FIXME - which value for VAR_CUSTOMSCALETABLE in V8 ? if (_vm->VAR_CUSTOMSCALETABLE != 0xFF && _vm->isGlobInMemory(rtString, _vm->VAR(_vm->VAR_CUSTOMSCALETABLE))) { @@ -1368,7 +1368,7 @@ bool Scumm::akos_compare(int a, int b, byte cmd) { #ifdef __PALM_OS__ #include "scumm_globals.h" // init globals void Akos_initGlobals() { - GSETPTR(default_scale_table, GBVARS_DEFAULTSCALETABLE_INDEX, byte, GBVARS_SCUMM) + GSETPTR(defaultScaleTable, GBVARS_DEFAULTSCALETABLE_INDEX, byte, GBVARS_SCUMM) } void Akos_releaseGlobals() { GRELEASEPTR(GBVARS_DEFAULTSCALETABLE_INDEX, GBVARS_SCUMM) diff --git a/scumm/akos.h b/scumm/akos.h index 9cb5979cdd..a7d81df81e 100644 --- a/scumm/akos.h +++ b/scumm/akos.h @@ -25,6 +25,12 @@ #include "base-costume.h" +#ifdef __PALM_OS__ +extern const byte *defaultScaleTable; +#else +extern const byte defaultScaleTable[768]; +#endif + struct CostumeData; struct AkosHeader; struct AkosOffset; diff --git a/scumm/bomp.cpp b/scumm/bomp.cpp index 6d2a943175..a8360bfe22 100644 --- a/scumm/bomp.cpp +++ b/scumm/bomp.cpp @@ -21,6 +21,7 @@ #include "stdafx.h" #include "scumm.h" +#include "akos.h" #include "bomp.h" @@ -347,72 +348,40 @@ static byte _bompBitsTable[] = { 4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0, }; -extern byte default_scale_table[768]; - int32 setupBompScale(byte *scaling, int32 size, byte scale) { - uint32 tmp = (256 - (size >> 1)); - int32 count = (size + 7) >> 3; - assert(tmp < sizeof(default_scale_table)); - byte *tmp_ptr = default_scale_table + tmp; + byte tmp; + int32 count; + const byte *tmp_ptr; byte *tmp_scaling = scaling; byte a = 0; + byte ret_value = 0; + const int offsets[8] = { 3, 2, 1, 0, 7, 6, 5, 4 }; - while ((count--) != 0) { - tmp = *(tmp_ptr + 3); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 2); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 1); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 0); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp_ptr += 4; - - tmp = *(tmp_ptr + 3); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 2); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 1); - a <<= 1; - if (scale < tmp) { - a |= 1; - } - tmp = *(tmp_ptr + 0); - a <<= 1; - if (scale < tmp) { - a |= 1; + count = (256 - (size >> 1)); + assert(0 <= count && count < 768); + tmp_ptr = defaultScaleTable + count; + + count = (size + 7) >> 3; + while (count--) { + a = 0; + for (int i = 0; i < 8; i++) { + tmp = *(tmp_ptr + offsets[i]); + a <<= 1; + if (scale < tmp) { + a |= 1; + } } - tmp_ptr += 4; + tmp_ptr += 8; - *(tmp_scaling++) = a; + *tmp_scaling++ = a; } if ((size & 7) != 0) { *(tmp_scaling - 1) |= revBitMask[size & 7]; } count = (size + 7) >> 3; - byte ret_value = 0; while (count--) { tmp = *scaling++; - assert(tmp < sizeof(_bompBitsTable)); ret_value += _bompBitsTable[tmp]; } |