aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-01-05 23:53:16 +0000
committerMax Horn2003-01-05 23:53:16 +0000
commitd9515432e4a1ed57d693c37aba2e6e2812b1fdae (patch)
tree7be1c6c857ea726ff1c22ef3cdb75e56b0d32410
parenta0d4234e8945464da1a125c954f1f7e7ff2c40a3 (diff)
downloadscummvm-rg350-d9515432e4a1ed57d693c37aba2e6e2812b1fdae.tar.gz
scummvm-rg350-d9515432e4a1ed57d693c37aba2e6e2812b1fdae.tar.bz2
scummvm-rg350-d9515432e4a1ed57d693c37aba2e6e2812b1fdae.zip
started unifying code in akos.cpp and costume.cpp
svn-id: r6343
-rw-r--r--scumm/actor.cpp33
-rw-r--r--scumm/akos.cpp103
-rw-r--r--scumm/akos.h97
-rw-r--r--scumm/costume.cpp91
-rw-r--r--scumm/costume.h47
5 files changed, 195 insertions, 176 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index e57af33565..16fe2b5019 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -920,12 +920,12 @@ void Actor::drawActorCostume()
if (!(_vm->_features & GF_AFTER_V7)) {
CostumeRenderer cr(_vm);
- cr._actorX = x - _vm->virtscr->xstart;
+ cr._actorX = x - _vm->virtscr[0].xstart;
cr._actorY = y - elevation;
cr._scaleX = scalex;
cr._scaleY = scaley;
- cr._outheight = _vm->virtscr->height;
+ cr._outheight = _vm->virtscr[0].height;
// FIXME - Hack to fix two glitches in the scene where Bobbin
// heals Rusty: Bobbin's feet get masked when Rusty shows him
@@ -980,28 +980,32 @@ void Actor::drawActorCostume()
else if (cr._zbuf > _vm->gdi._numZBuffer)
cr._zbuf = (byte)_vm->gdi._numZBuffer;
+ cr._shadow_mode = shadow_mode;
cr._shadow_table = _vm->_shadowPalette;
cr.setCostume(costume);
cr.setPalette(palette);
cr.setFacing(facing);
- top = 0xFF;
+ cr.draw_top = top = 0xFF;
+ cr.draw_bottom = bottom = 0;
- bottom = 0;
+ cr._dirty_id = number;
/* if the actor is partially hidden, redraw it next frame */
- if (cr.drawCostume(this) & 1) {
+ if (cr.drawCostume(cost) & 1) {
needBgReset = true;
needRedraw = true;
}
+ top = cr.draw_top;
+ bottom = cr.draw_bottom;
} else {
AkosRenderer ar(_vm);
ar.charsetmask = true;
- ar._x = x - _vm->virtscr->xstart;
+ ar._x = x - _vm->virtscr[0].xstart;
ar._y = y - elevation;
- ar.scale_x = scalex;
- ar.scale_y = scaley;
+ ar._scaleX = scalex;
+ ar._scaleY = scaley;
ar.clipping = forceClip;
if (ar.clipping == 100) {
ar.clipping = _vm->getMaskFromBox(walkbox);
@@ -1009,9 +1013,9 @@ void Actor::drawActorCostume()
ar.clipping = _vm->gdi._numZBuffer;
}
- ar.outptr = _vm->virtscr->screenPtr + _vm->virtscr->xstart;
- ar.outwidth = _vm->virtscr->width;
- ar.outheight = _vm->virtscr->height;
+ ar.outptr = _vm->virtscr[0].screenPtr + _vm->virtscr[0].xstart;
+ ar.outwidth = _vm->virtscr[0].width;
+ ar.outheight = _vm->virtscr[0].height;
ar.shadow_mode = shadow_mode;
ar.shadow_table = _vm->_shadowPalette;
@@ -1020,13 +1024,12 @@ void Actor::drawActorCostume()
ar.setPalette(palette);
ar.setFacing(this);
- ar.dirty_id = number;
-
- ar.cd = &cost;
+ ar._dirty_id = number;
ar.draw_top = top = 0x7fffffff;
ar.draw_bottom = bottom = 0;
- if (ar.drawCostume()) {
+
+ if (ar.drawCostume(cost)) {
needBgReset = true;
needRedraw = true;
}
diff --git a/scumm/akos.cpp b/scumm/akos.cpp
index 9c9db46cca..41d80853cf 100644
--- a/scumm/akos.cpp
+++ b/scumm/akos.cpp
@@ -25,6 +25,49 @@
#include "akos.h"
#include "imuse.h"
+
+enum AkosOpcodes {
+ AKC_Return = 0xC001,
+ AKC_SetVar = 0xC010,
+ AKC_CmdQue3 = 0xC015,
+ AKC_ComplexChan = 0xC020,
+ AKC_Jump = 0xC030,
+ AKC_JumpIfSet = 0xC031,
+ AKC_AddVar = 0xC040,
+ AKC_Ignore = 0xC050,
+ AKC_IncVar = 0xC060,
+ AKC_CmdQue3Quick = 0xC061,
+ AKC_SkipStart = 0xC070,
+ AKC_SkipE = 0xC070,
+ AKC_SkipNE = 0xC071,
+ AKC_SkipL = 0xC072,
+ AKC_SkipLE = 0xC073,
+ AKC_SkipG = 0xC074,
+ AKC_SkipGE = 0xC075,
+ AKC_StartAnim = 0xC080,
+ AKC_StartVarAnim = 0xC081,
+ AKC_Random = 0xC082,
+ AKC_SetActorClip = 0xC083,
+ AKC_StartAnimInActor = 0xC084,
+ AKC_SetVarInActor = 0xC085,
+ AKC_HideActor = 0xC086,
+ AKC_SetDrawOffs = 0xC087,
+ AKC_JumpTable = 0xC088,
+ AKC_SoundStuff = 0xC089,
+ AKC_Flip = 0xC08A,
+ AKC_Cmd3 = 0xC08B,
+ AKC_Ignore3 = 0xC08C,
+ AKC_Ignore2 = 0xC08D,
+ AKC_JumpStart = 0xC090,
+ AKC_JumpE = 0xC090,
+ AKC_JumpNE = 0xC091,
+ AKC_JumpL = 0xC092,
+ AKC_JumpLE = 0xC093,
+ AKC_JumpG = 0xC094,
+ AKC_JumpGE = 0xC095,
+ AKC_ClearFlag = 0xC09F
+};
+
bool Scumm::akos_hasManyDirections(Actor *a)
{
if (_features & GF_NEW_COSTUMES) {
@@ -170,18 +213,18 @@ void AkosRenderer::setFacing(Actor *a)
mirror ^= 1;
}
-bool AkosRenderer::drawCostume()
+bool AkosRenderer::drawCostume(const CostumeData &cost)
{
int i;
bool result = false;
move_x = move_y = 0;
for (i = 0; i < 16; i++)
- result |= drawCostumeChannel(i);
+ result |= drawLimb(cost, i);
return result;
}
-bool AkosRenderer::drawCostumeChannel(int chan)
+bool AkosRenderer::drawLimb(const CostumeData &cost, int limb)
{
uint code;
byte *p;
@@ -189,10 +232,10 @@ bool AkosRenderer::drawCostumeChannel(int chan)
AkosCI *the_akci;
uint i, extra;
- if (!cd->active[chan] || cd->stopped & (1 << chan))
+ if (!cost.active[limb] || cost.stopped & (1 << limb))
return false;
- p = aksq + cd->curpos[chan];
+ p = aksq + cost.curpos[limb];
code = p[0];
if (code & 0x80)
@@ -301,7 +344,7 @@ void AkosRenderer::codec1_genericDecode()
len = *src++;
do {
- if (*scaleytab++ < scale_y) {
+ if (*scaleytab++ < _scaleY) {
if (color && y < outheight
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
*dst = palette[color];
@@ -318,7 +361,7 @@ void AkosRenderer::codec1_genericDecode()
scaleytab = &v1.scaletable[v1.tmp_y];
- if (v1.scaletable[v1.tmp_x] < scale_x) {
+ if (v1.scaletable[v1.tmp_x] < _scaleX) {
v1.x += v1.scaleXstep;
if (v1.x < 0 || v1.x >= _vm->_realWidth)
return;
@@ -366,7 +409,7 @@ void AkosRenderer::codec1_spec1()
len = *src++;
do {
- if (*scaleytab++ < scale_y) {
+ if (*scaleytab++ < _scaleY) {
if (color && y < outheight
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
pcolor = palette[color];
@@ -386,7 +429,7 @@ void AkosRenderer::codec1_spec1()
scaleytab = &v1.scaletable[v1.tmp_y];
- if (v1.scaletable[v1.tmp_x] < scale_x) {
+ if (v1.scaletable[v1.tmp_x] < _scaleX) {
v1.x += v1.scaleXstep;
if (v1.x < 0 || v1.x >= _vm->_realWidth)
return;
@@ -439,7 +482,7 @@ void AkosRenderer::codec1_spec3()
len = *src++;
do {
- if (*scaleytab++ < scale_y) {
+ if (*scaleytab++ < _scaleY) {
if (color && y < outheight
&& (!v1.mask_ptr || !((mask[0] | mask[v1.imgbufoffs]) & maskbit))) {
pcolor = palette[color];
@@ -462,7 +505,7 @@ void AkosRenderer::codec1_spec3()
scaleytab = &v1.scaletable[v1.tmp_y];
- if (v1.scaletable[v1.tmp_x] < scale_x) {
+ if (v1.scaletable[v1.tmp_x] < _scaleX) {
v1.x += v1.scaleXstep;
if (v1.x < 0 || v1.x >= _vm->_realWidth)
return;
@@ -615,7 +658,7 @@ void AkosRenderer::codec1()
v1.shl = 4;
}
- use_scaling = (scale_x != 0xFF) || (scale_y != 0xFF);
+ use_scaling = (_scaleX != 0xFF) || (_scaleY != 0xFF);
cur_x = _x;
cur_y = _y;
@@ -634,7 +677,7 @@ void AkosRenderer::codec1()
tmp_x = 0x180 - move_x_cur;
j = tmp_x;
for (i = 0; i < move_x_cur; i++) {
- if (v1.scaletable[j++] < scale_x)
+ if (v1.scaletable[j++] < _scaleX)
cur_x -= v1.scaleXstep;
}
@@ -646,7 +689,7 @@ void AkosRenderer::codec1()
skip++;
tmp_x = j;
}
- if (v1.scaletable[j++] < scale_x)
+ if (v1.scaletable[j++] < _scaleX)
x_right++;
}
} else {
@@ -655,7 +698,7 @@ void AkosRenderer::codec1()
tmp_x = 0x180 + move_x_cur;
j = tmp_x;
for (i = 0; i < move_x_cur; i++) {
- if (v1.scaletable[j++] < scale_x)
+ if (v1.scaletable[j++] < _scaleX)
cur_x += v1.scaleXstep;
}
@@ -667,7 +710,7 @@ void AkosRenderer::codec1()
tmp_x = j;
skip++;
}
- if (v1.scaletable[j--] < scale_x)
+ if (v1.scaletable[j--] < _scaleX)
x_left--;
}
}
@@ -683,14 +726,14 @@ void AkosRenderer::codec1()
tmp_y = 0x180 - move_y_cur;
for (i = 0; i < move_y_cur; i++) {
- if (v1.scaletable[tmp_y++] < scale_y)
+ if (v1.scaletable[tmp_y++] < _scaleY)
cur_y -= step;
}
y_top = y_bottom = cur_y;
tmp_y = 0x180 - move_y_cur;
for (i = 0; i < _height; i++) {
- if (v1.scaletable[tmp_y++] < scale_y)
+ if (v1.scaletable[tmp_y++] < _scaleY)
y_bottom++;
}
@@ -769,7 +812,7 @@ void AkosRenderer::codec1()
if (v1.skip_width <= 0 || _height <= 0)
return;
- _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, 1 << dirty_id);
+ _vm->updateDirtyRect(0, x_left, x_right, y_top, y_bottom, 1 << _dirty_id);
y_clipping = ((uint) y_bottom > outheight || y_top < 0);
@@ -779,9 +822,9 @@ void AkosRenderer::codec1()
if ((uint) y_bottom > (uint) outheight)
y_bottom = outheight;
- if (y_top < draw_top)
+ if (draw_top > y_top)
draw_top = y_top;
- if (y_bottom > draw_bottom)
+ if (draw_bottom < y_bottom)
draw_bottom = y_bottom;
if (cur_x == -1)
@@ -889,11 +932,11 @@ void AkosRenderer::codec5() {
if ((clip_right <= clip_left) || (clip_top >= clip_bottom))
return;
- _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << dirty_id);
+ _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << _dirty_id);
- if (clip_top < draw_top)
+ if (draw_top > clip_top)
draw_top = clip_top;
- if (clip_bottom > draw_bottom)
+ if (draw_bottom < clip_bottom)
draw_bottom = clip_bottom + 1;
BompDrawData bdd;
@@ -1217,17 +1260,15 @@ void AkosRenderer::codec16() {
clip_bottom -= tmp_y;
}
- if((clip_left >= clip_right) || (clip_top >= clip_bottom))
+ if ((clip_left >= clip_right) || (clip_top >= clip_bottom))
return;
- _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << dirty_id);
- if(clip_top < draw_top) {
- draw_top = clip_top;
- }
+ _vm->updateDirtyRect(0, clip_left, clip_right + 1, clip_top, clip_bottom + 1, 1 << _dirty_id);
- if(clip_bottom > draw_bottom) {
+ if (draw_top > clip_top)
+ draw_top = clip_top;
+ if (draw_bottom < clip_bottom)
draw_bottom = clip_bottom + 1;
- }
int32 width_unk, height_unk;
diff --git a/scumm/akos.h b/scumm/akos.h
index b3ce917299..545250c955 100644
--- a/scumm/akos.h
+++ b/scumm/akos.h
@@ -20,6 +20,8 @@
*
*/
+#ifndef AKOS_H
+#define AKOS_H
#if !defined(__GNUC__)
@@ -53,20 +55,29 @@ struct AkosCI {
#endif
struct AkosRenderer {
-//protected:
- CostumeData *cd;
- int _x, _y; /* where to draw costume */
- byte scale_x, scale_y; /* scaling */
- byte clipping; /* clip mask */
- bool charsetmask; // FIXME - it seems charsetmask is only set once, in actor.cpp, to true. So can we get rid of it?!?
+public:
+ byte _dirty_id;
+
byte shadow_mode;
- uint16 codec;
- bool mirror; /* draw actor mirrored */
- byte dirty_id;
+ byte *shadow_table;
+
+ int _x, _y;
+ byte _scaleX, _scaleY;
+ byte clipping;
+ bool charsetmask; // FIXME - it seems charsetmask is only set once, in actor.cpp, to true. So can we get rid of it?!?
+
+ int draw_top, draw_bottom;
+
byte *outptr;
uint outwidth, outheight;
+
+protected:
+ Scumm *_vm;
int32 _numStrips;
+ uint16 codec;
+ bool mirror; /* draw actor mirrored */
+
/* pointer to various parts of the costume resource */
byte *akos;
AkosHeader *akhd;
@@ -79,19 +90,13 @@ struct AkosRenderer {
int _width, _height;
byte *srcptr;
- byte *shadow_table;
- /* put less used stuff at the bottom to optimize opcodes */
- int draw_top, draw_bottom;
-protected:
byte *akpl, *akci, *aksq;
AkosOffset *akof;
byte *akcd;
byte palette[256];
- Scumm *_vm;
-
struct {
/* codec stuff */
const byte *scaletable;
@@ -117,25 +122,27 @@ protected:
byte shift;
uint16 bits;
byte numbits;
- byte * dataptr;
+ byte *dataptr;
byte buffer[336];
} akos16;
public:
-
// Constructor, sets all data to 0
AkosRenderer(Scumm *scumm) {
memset(this, 0, sizeof(AkosRenderer));
_vm = scumm;
_numStrips = _vm->gdi._numStrips;
}
- bool drawCostume();
+
void setPalette(byte *palette);
+ void setFacing(Actor *a);
void setCostume(int costume);
- void setFacing(Actor * a);
+
+ bool drawCostume(const CostumeData &cost);
protected:
- bool drawCostumeChannel(int chan);
+ bool drawLimb(const CostumeData &cost, int limb);
+
void codec1();
void codec1_spec1();
void codec1_spec2();
@@ -147,52 +154,12 @@ protected:
void codec16();
void akos16SetupBitReader(byte *src);
- void akos16PutOnScreen(byte * dest, byte * src, byte transparency, int32 count);
+ void akos16PutOnScreen(byte *dest, 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);
- void akos16Decompress(byte * dest, int32 pitch, byte * src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency);
- void akos16DecompressMask(byte * dest, int32 pitch, byte * src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency, byte * maskptr, int32 bitpos_start);
+ void akos16ApplyMask(byte *dest, byte *maskptr, byte bits, int32 count, byte fillwith);
+ void akos16Decompress(byte *dest, int32 pitch, byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency);
+ void akos16DecompressMask(byte *dest, int32 pitch, byte *src, int32 t_width, int32 t_height, int32 dir, int32 numskip_before, int32 numskip_after, byte transparency, byte *maskptr, int32 bitpos_start);
};
-enum AkosOpcodes {
- AKC_Return = 0xC001,
- AKC_SetVar = 0xC010,
- AKC_CmdQue3 = 0xC015,
- AKC_ComplexChan = 0xC020,
- AKC_Jump = 0xC030,
- AKC_JumpIfSet = 0xC031,
- AKC_AddVar = 0xC040,
- AKC_Ignore = 0xC050,
- AKC_IncVar = 0xC060,
- AKC_CmdQue3Quick = 0xC061,
- AKC_SkipStart = 0xC070,
- AKC_SkipE = 0xC070,
- AKC_SkipNE = 0xC071,
- AKC_SkipL = 0xC072,
- AKC_SkipLE = 0xC073,
- AKC_SkipG = 0xC074,
- AKC_SkipGE = 0xC075,
- AKC_StartAnim = 0xC080,
- AKC_StartVarAnim = 0xC081,
- AKC_Random = 0xC082,
- AKC_SetActorClip = 0xC083,
- AKC_StartAnimInActor = 0xC084,
- AKC_SetVarInActor = 0xC085,
- AKC_HideActor = 0xC086,
- AKC_SetDrawOffs = 0xC087,
- AKC_JumpTable = 0xC088,
- AKC_SoundStuff = 0xC089,
- AKC_Flip = 0xC08A,
- AKC_Cmd3 = 0xC08B,
- AKC_Ignore3 = 0xC08C,
- AKC_Ignore2 = 0xC08D,
- AKC_JumpStart = 0xC090,
- AKC_JumpE = 0xC090,
- AKC_JumpNE = 0xC091,
- AKC_JumpL = 0xC092,
- AKC_JumpLE = 0xC093,
- AKC_JumpG = 0xC094,
- AKC_JumpGE = 0xC095,
- AKC_ClearFlag = 0xC09F
-};
+#endif
diff --git a/scumm/costume.cpp b/scumm/costume.cpp
index 256725a7fa..dbda0389e2 100644
--- a/scumm/costume.cpp
+++ b/scumm/costume.cpp
@@ -78,7 +78,7 @@ const byte cost_scaleTable[256] = {
238, 30, 158, 94, 222, 62, 190, 126, 254
};
-byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
+byte CostumeRenderer::mainRoutine(int slot, int frame)
{
int xmove, ymove, i, b, s;
uint scal;
@@ -90,7 +90,8 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
newAmiCost = (_vm->_gameId == GID_MONKEY2 || _vm->_gameId == GID_INDY4) && (_vm->_features & GF_AMIGA);
- CHECK_HEAP _maskval = 0xF;
+ CHECK_HEAP
+ _maskval = 0xF;
_shrval = 4;
if (_loaded._numColors == 32) {
_maskval = 7;
@@ -212,7 +213,7 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
_scaleIndexXStep = 1;
_ypostop = _ypos;
- _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, 1 << a->number);
+ _vm->updateDirtyRect(0, _left, _right + 1, _top, _bottom, 1 << _dirty_id);
if (_top >= (int)_outheight || _bottom <= 0)
return 0;
@@ -220,13 +221,12 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
_ypitch = _height * _vm->_realWidth;
_docontinue = 0;
b = 1;
- if (_left > (_vm->_realWidth - 1) || _right <= 0)
+ if (_left >= _vm->_realWidth || _right <= 0)
return 1;
if (_mirror) {
_ypitch--;
- if (scaling == 0) {
+ if (scaling == 0)
s = -_xpos;
- }
if (s > 0) {
if (!newAmiCost) {
_width2 -= s;
@@ -274,14 +274,15 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
if ((uint) _bottom > _outheight)
_bottom = _outheight;
- if (a->top > _top)
- a->top = _top;
+ if (draw_top > _top)
+ draw_top = _top;
- if (a->bottom < _bottom)
- a->bottom = _bottom;
+ if (draw_bottom < _bottom)
+ draw_bottom = _bottom;
if (_height2 + _top >= 256) {
- CHECK_HEAP return 2;
+ CHECK_HEAP
+ return 2;
}
_bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + _vm->virtscr[0].xstart + _ypos * _vm->_realWidth + _xpos;
@@ -308,8 +309,9 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
_mask_ptr_dest = _mask_ptr + _xpos / 8;
}
- CHECK_HEAP if (a->shadow_mode) {
- proc_special(a, (masking << 1) + charsetmask);
+ CHECK_HEAP
+ if (_shadow_mode) {
+ proc_special((masking << 1) + charsetmask);
return b;
}
@@ -356,7 +358,8 @@ byte CostumeRenderer::mainRoutine(Actor *a, int slot, int frame)
break;
}
- CHECK_HEAP return b;
+ CHECK_HEAP
+ return b;
}
void CostumeRenderer::proc6()
@@ -1093,7 +1096,7 @@ void CostumeRenderer::proc1_ami()
} while (1);
}
-void CostumeRenderer::proc_special(Actor *a, byte mask2)
+void CostumeRenderer::proc_special(byte mask2)
{
byte *mask, *src, *dst, *dstorg;
byte maskbit, len, height, pcolor, width;
@@ -1107,11 +1110,11 @@ void CostumeRenderer::proc_special(Actor *a, byte mask2)
byte shadow4;
byte shadow5;
- shadow1 = a->shadow_mode & 0x80;
- shadow2 = a->shadow_mode & 0x40;
- shadow3 = a->shadow_mode & 0x20;
- shadow4 = a->shadow_mode & 0x10;
- shadow5 = a->shadow_mode & 0x0F;
+ shadow1 = _shadow_mode & 0x80;
+ shadow2 = _shadow_mode & 0x40;
+ shadow3 = _shadow_mode & 0x20;
+ shadow4 = _shadow_mode & 0x10;
+ shadow5 = _shadow_mode & 0x0F;
mask = _mask_ptr = _mask_ptr_dest;
maskbit = revBitMask[_xpos & 7];
@@ -1224,46 +1227,42 @@ void LoadedCostume::loadCostume(int id)
_dataptr = _ptr + READ_LE_UINT16(_ptr + _numColors + 8);
}
-byte CostumeRenderer::drawOneSlot(Actor *a, int slot)
+byte CostumeRenderer::drawCostume(const CostumeData &cost)
{
+ int i;
+ byte result = 0;
- if (!(_vm->_features & GF_AFTER_V7)) {
- int i;
- int code;
- CostumeData *cd = &a->cost;
+ _xmove = _ymove = 0;
+ for (i = 0; i != 16; i++)
+ result |= drawLimb(cost, i);
+ return result;
+}
- if (cd->curpos[slot] == 0xFFFF || cd->stopped & (1 << slot))
- return 0;
+byte CostumeRenderer::drawLimb(const CostumeData &cost, int limb)
+{
+ int i;
+ int code;
- i = cd->curpos[slot] & 0x7FFF;
+ if (cost.curpos[limb] == 0xFFFF || cost.stopped & (1 << limb))
+ return 0;
- _frameptr = _loaded._ptr + READ_LE_UINT16(_loaded._ptr + _loaded._numColors + slot * 2 + 10);
+ i = cost.curpos[limb] & 0x7FFF;
- code = _loaded._dataptr[i] & 0x7F;
+ _frameptr = _loaded._ptr + READ_LE_UINT16(_loaded._ptr + _loaded._numColors + limb * 2 + 10);
- _srcptr = _loaded._ptr + READ_LE_UINT16(_frameptr + code * 2);
+ code = _loaded._dataptr[i] & 0x7F;
- if (code != 0x7B) {
- if (!(_vm->_features & GF_OLD256) || code < 0x79)
- return mainRoutine(a, slot, code);
- }
+ _srcptr = _loaded._ptr + READ_LE_UINT16(_frameptr + code * 2);
+
+ if (code != 0x7B) {
+ if (!(_vm->_features & GF_OLD256) || code < 0x79)
+ return mainRoutine(limb, code);
}
return 0;
}
-byte CostumeRenderer::drawCostume(Actor *a)
-{
- int i;
- byte r = 0;
-
- _xmove = _ymove = 0;
- for (i = 0; i != 16; i++)
- r |= drawOneSlot(a, i);
- return r;
-}
-
int Scumm::cost_frameToAnim(Actor *a, int frame)
{
return newDirToOldDir(a->facing) + frame * 4;
diff --git a/scumm/costume.h b/scumm/costume.h
index 1d5c58efdc..4a9328965b 100644
--- a/scumm/costume.h
+++ b/scumm/costume.h
@@ -43,21 +43,29 @@ protected:
class CostumeRenderer {
+public:
+ byte _dirty_id;
+
+ byte _shadow_mode;
+ byte *_shadow_table;
+
+ int _actorX, _actorY;
+ byte _zbuf;
+ uint _scaleX, _scaleY;
+
+ int draw_top, draw_bottom;
+
+ uint _outheight;
+
protected:
Scumm *_vm;
int32 _numStrips;
LoadedCostume _loaded;
-public:
- byte *_shadow_table;
-
byte *_frameptr;
byte *_srcptr;
byte *_bgbak_ptr, *_backbuff_ptr, *_mask_ptr, *_mask_ptr_dest;
- int _actorX, _actorY;
- byte _zbuf;
- uint _scaleX, _scaleY;
int _xmove, _ymove;
bool _mirror;
byte _maskval;
@@ -68,7 +76,6 @@ public:
int _height;
int _xpos, _ypos;
- uint _outheight;
int _scaleIndexXStep;
int _scaleIndexYStep;
byte _scaleIndexX; /* must wrap at 256 */
@@ -84,6 +91,18 @@ public:
byte _replen;
byte _palette[32];
+public:
+ CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->gdi._numStrips), _loaded(vm) {}
+
+ void setPalette(byte *palette);
+ void setFacing(uint16 facing);
+ void setCostume(int costume);
+
+ byte drawCostume(const CostumeData &cost);
+
+protected:
+ byte drawLimb(const CostumeData &cost, int limb);
+
void proc6();
void proc5();
void proc4();
@@ -96,19 +115,9 @@ public:
void proc3_ami();
void proc2_ami();
void proc1_ami();
- void proc_special(Actor *a, byte mask);
- byte mainRoutine(Actor *a, int slot, int frame);
+ void proc_special(byte mask);
+ byte mainRoutine(int limb, int frame);
void ignorePakCols(int num);
-
- byte drawOneSlot(Actor *a, int slot);
- byte drawCostume(Actor *a);
-
- void setPalette(byte *palette);
- void setFacing(uint16 facing);
- void setCostume(int costume);
-
-public:
- CostumeRenderer(Scumm *vm) : _vm(vm), _numStrips(vm->gdi._numStrips), _loaded(vm) {}
};
#endif