aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/akos.cpp35
-rw-r--r--scumm/akos.h7
-rw-r--r--scumm/gfx.cpp94
-rw-r--r--scumm/scumm.h23
4 files changed, 72 insertions, 87 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp
index 807c2042b4..5f3b436ef4 100644
--- a/scumm/akos.cpp
+++ b/scumm/akos.cpp
@@ -820,25 +820,6 @@ void AkosRenderer::akos16SetupBitReader(const byte *src) {
akos16.dataptr = src + 4;
}
-void AkosRenderer::akos16PutOnScreen(byte *dst, const byte *src, byte transparency, int32 count) {
- if (count <= 0)
- return;
-
- switch(_shadow_mode) {
- case 0:
- _vm->bompApplyShadow0(src, dst, count, transparency);
- break;
- case 1:
- _vm->bompApplyShadow1(src, dst, count, transparency);
- break;
- case 3:
- _vm->bompApplyShadow3(src, dst, count, transparency);
- break;
- default:
- error("Unknown shadowMode %d", _shadow_mode);
- }
-}
-
#define AKOS16_FILL_BITS() \
if (akos16.numbits <= 8) { \
akos16.bits |= (*akos16.dataptr++) << akos16.numbits; \
@@ -934,16 +915,16 @@ void AkosRenderer::akos16Decompress(byte *dest, int32 pitch, const byte *src, in
akos16SkipData(numskip_before);
}
- while (t_height != 0) {
+ assert(t_height > 0);
+ assert(t_width > 0);
+ while (t_height--) {
akos16DecodeLine(tmp_buf, t_width, dir);
- akos16PutOnScreen(dest, akos16.buffer, transparency, t_width);
+ _vm->bompApplyShadow(_shadow_mode, akos16.buffer, dest, t_width, transparency);
if (numskip_after != 0) {
akos16SkipData(numskip_after);
}
dest += pitch;
-
- t_height--;
}
}
@@ -964,18 +945,18 @@ void AkosRenderer::akos16DecompressMask(byte *dest, int32 pitch, const byte *src
maskpitch = _numStrips;
- while (t_height != 0) {
+ assert(t_height > 0);
+ assert(t_width > 0);
+ while (t_height--) {
akos16DecodeLine(tmp_buf, t_width, dir);
akos16ApplyMask(akos16.buffer, maskptr, (byte)bitpos_start, t_width, transparency);
- akos16PutOnScreen(dest, akos16.buffer, transparency, t_width);
+ _vm->bompApplyShadow(_shadow_mode, akos16.buffer, dest, t_width, transparency);
if (numskip_after != 0) {
akos16SkipData(numskip_after);
}
dest += pitch;
maskptr += maskpitch;
-
- t_height--;
}
}
diff --git a/scumm/akos.h b/scumm/akos.h
index 040820711e..79212fa7e7 100644
--- a/scumm/akos.h
+++ b/scumm/akos.h
@@ -74,14 +74,13 @@ public:
protected:
byte drawLimb(const CostumeData &cost, int limb);
- byte codec1(int _xmoveCur, int _ymoveCur);
+ byte codec1(int xmoveCur, int ymoveCur);
void codec1_genericDecode();
- byte codec5(int _xmoveCur, int _ymoveCur);
+ byte codec5(int xmoveCur, int ymoveCur);
- byte codec16(int _xmoveCur, int _ymoveCur);
+ byte codec16(int xmoveCur, int ymoveCur);
void akos16SetupBitReader(const byte *src);
- void akos16PutOnScreen(byte *dest, const byte *src, byte transparency, int32 count);
void akos16SkipData(int32 numskip);
void akos16DecodeLine(byte *buf, int32 numbytes, int32 dir);
void akos16ApplyMask(byte *dest, byte *maskptr, byte bits, int32 count, byte fillwith);
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index 3a034c51ae..921587609e 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -3173,6 +3173,12 @@ void Scumm::useBompCursor(const byte *im, int width, int height) {
_cursor.height = height;
_cursor.animate = 0;
+ // Skip the header
+ if (_features & GF_AFTER_V8) {
+ im += 16;
+ } else {
+ im += 18;
+ }
decompressBomp(_grabbedCursor, im, width, height);
updateCursor();
@@ -3254,24 +3260,25 @@ int32 Scumm::bompDecodeLineMode1(const byte *src, byte *line_buffer, int32 size)
if (size <= 0)
return t_size;
- int32 len = size;
+ int len, num;
+ byte code, color;
+
+ len = size;
src += 2;
while (len) {
- byte code = *src++;
- int32 num = (code >> 1) + 1;
+ code = *src++;
+ num = (code >> 1) + 1;
if (num > len)
num = len;
len -= num;
if (code & 1) {
- byte color = *src++;
- do
- *line_buffer++ = color;
- while (--num);
+ color = *src++;
+ memset(line_buffer, color, num);
} else {
- do
- *line_buffer++ = *src++;
- while (--num);
+ memcpy(line_buffer, src, num);
+ src += num;
}
+ line_buffer += num;
}
return t_size;
}
@@ -3282,23 +3289,24 @@ int32 Scumm::bompDecodeLineMode3(const byte *src, byte *line_buffer, int32 size)
if (size <= 0)
return t_size;
- int32 len = size;
+ int len, num;
+ byte code, color;
+
+ len = size;
src += 2;
while (len) {
- byte code = *src++;
- int32 num = (code >> 1) + 1;
+ code = *src++;
+ num = (code >> 1) + 1;
if (num > len)
num = len;
len -= num;
+ line_buffer -= num;
if (code & 1) {
- byte color = *src++;
- do
- *--line_buffer = color;
- while (--num);
+ color = *src++;
+ memset(line_buffer, color, num);
} else {
- do
- *--line_buffer = *src++;
- while (--num);
+ memcpy(line_buffer, src, num);
+ src += num;
}
}
return t_size;
@@ -3320,7 +3328,23 @@ void Scumm::bompApplyMask(byte *line_buffer, byte *mask_src, byte bits, int32 si
}
}
-void Scumm::bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+void Scumm::bompApplyShadow(int shadowMode, const byte *line_buffer, byte *dst, int32 size, byte transparency) const {
+ assert(size > 0);
+ switch(shadowMode) {
+ case 0:
+ bompApplyShadow0(line_buffer, dst, size, transparency);
+ break;
+ case 1:
+ bompApplyShadow1(line_buffer, dst, size, transparency);
+ break;
+ case 3:
+ bompApplyShadow3(line_buffer, dst, size, transparency);
+ break;
+ default:
+ error("Unknown shadow mode %d", shadowMode);
+ }
+}
+void Scumm::bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency) const {
while(size-- > 0) {
byte tmp = *line_buffer++;
if (tmp != transparency) {
@@ -3330,7 +3354,7 @@ void Scumm::bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byt
}
}
-void Scumm::bompApplyShadow1(const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+void Scumm::bompApplyShadow1(const byte *line_buffer, byte *dst, int32 size, byte transparency) const {
while(size-- > 0) {
byte tmp = *line_buffer++;
if (tmp != transparency) {
@@ -3343,7 +3367,7 @@ void Scumm::bompApplyShadow1(const byte *line_buffer, byte *dst, int32 size, byt
}
}
-void Scumm::bompApplyShadow3(const byte *line_buffer, byte *dst, int32 size, byte transparency) {
+void Scumm::bompApplyShadow3(const byte *line_buffer, byte *dst, int32 size, byte transparency) const {
while(size-- > 0) {
byte tmp = *line_buffer++;
if (tmp != transparency) {
@@ -3356,7 +3380,7 @@ void Scumm::bompApplyShadow3(const byte *line_buffer, byte *dst, int32 size, byt
}
}
-void Scumm::bompApplyActorPalette(byte *line_buffer, int32 size) {
+void Scumm::bompApplyActorPalette(byte *line_buffer, int32 size) const {
if (_bompActorPalettePtr != 0) {
*(_bompActorPalettePtr + 255) = 255;
while(1) {
@@ -3391,13 +3415,6 @@ void Scumm::decompressBomp(byte *dst, const byte *src, int w, int h) {
int len, num;
byte code, color;
- // Skip the header
- if (_features & GF_AFTER_V8) {
- src += 16;
- } else {
- src += 18;
- }
-
do {
len = w;
src += 2;
@@ -3532,20 +3549,7 @@ void Scumm::drawBomp(const BompDrawData &bd, int decode_mode, int mask) {
bompApplyMask(line_ptr, charset_mask, bits, clip_right);
bompApplyActorPalette(line_ptr, clip_right);
-
- switch(bd.shadowMode) {
- case 0:
- bompApplyShadow0(line_ptr, dst, clip_right);
- break;
- case 1:
- bompApplyShadow1(line_ptr, dst, clip_right);
- break;
- case 3:
- bompApplyShadow3(line_ptr, dst, clip_right);
- break;
- default:
- error("Unknown bomp shadowMode %d", bd.shadowMode);
- }
+ bompApplyShadow(bd.shadowMode, line_ptr, dst, clip_right, 255);
}
mask_out += mask_pitch;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 9b51829693..62da645d4e 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -902,19 +902,20 @@ public:
void drawBomp(const BompDrawData &bd, int decode_mode, int mask);
protected:
- void decompressBomp(byte *dst, const byte *src, int w, int h);
- int32 setupBompScale(byte *scaling, int32 size, byte scale);
- void bompScaleFuncX(byte *line_buffer, byte *scaling_x_ptr, byte skip, int32 size);
- int32 bompDecodeLineMode0(const byte *src, byte *line_buffer, int32 size);
- int32 bompDecodeLineMode1(const byte *src, byte *line_buffer, int32 size);
- int32 bompDecodeLineMode3(const byte *src, byte *line_buffer, int32 size);
- void bompApplyMask(byte *line_buffer, byte *mask_out, byte bits, int32 size);
+ static void decompressBomp(byte *dst, const byte *src, int w, int h);
+ static int32 setupBompScale(byte *scaling, int32 size, byte scale);
+ static void bompScaleFuncX(byte *line_buffer, byte *scaling_x_ptr, byte skip, int32 size);
+ static int32 bompDecodeLineMode0(const byte *src, byte *line_buffer, int32 size);
+ static int32 bompDecodeLineMode1(const byte *src, byte *line_buffer, int32 size);
+ static int32 bompDecodeLineMode3(const byte *src, byte *line_buffer, int32 size);
+ static void bompApplyMask(byte *line_buffer, byte *mask_out, byte bits, int32 size);
public:
- void bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency = 255);
- void bompApplyShadow1(const byte *line_buffer, byte *dst, int32 size, byte transparency = 255);
- void bompApplyShadow3(const byte *line_buffer, byte *dst, int32 size, byte transparency = 255);
+ void bompApplyShadow(int shadowMode, const byte *line_buffer, byte *dst, int32 size, byte transparency) const;
protected:
- void bompApplyActorPalette(byte *line_buffer, int32 size);
+ void bompApplyShadow0(const byte *line_buffer, byte *dst, int32 size, byte transparency) const;
+ void bompApplyShadow1(const byte *line_buffer, byte *dst, int32 size, byte transparency) const;
+ void bompApplyShadow3(const byte *line_buffer, byte *dst, int32 size, byte transparency) const;
+ void bompApplyActorPalette(byte *line_buffer, int32 size) const;
bool _shakeEnabled;
uint _shakeFrame;