Fix actor glitches in C64 maniac and minor cleanup

svn-id: r21001
This commit is contained in:
Travis Howell 2006-03-02 02:10:54 +00:00
parent fd8f11f7a4
commit e3a48bf276

View file

@ -1006,9 +1006,7 @@ byte C64CostumeRenderer::drawLimb(const Actor *a, int limb) {
int off = (offH << 8) + offL; int off = (offH << 8) + offL;
const byte *data = _loaded._baseptr + off; const byte *data = _loaded._baseptr + off;
const byte actorColors[] = { const byte palette[] = {0, 10, actorColorsMMC64[_actorID], 0};
0, 10, actorColorsMMC64[_actorID], 0
};
int width = *data++; int width = *data++;
int height = *data++; int height = *data++;
@ -1042,45 +1040,52 @@ byte C64CostumeRenderer::drawLimb(const Actor *a, int limb) {
xpos += _actorX - (a->_width / 2) + 4; xpos += _actorX - (a->_width / 2) + 4;
ypos += _actorY - _loaded._maxHeight; ypos += _actorY - _loaded._maxHeight;
// This code is very similar to procC64()
if (flipped) { if (flipped) {
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
byte c = data[y*width+x]; byte color = data[y * width + x];
byte b, d; byte pcolor;
int realX = 0; int realX = 0;
if (offsetX == 0||offsetX == 1) { if (offsetX == 0||offsetX == 1) {
realX = width-(x+1); realX = width-(x+1);
} else if (offsetX == 2) { } else if (offsetX == 2) {
realX = width-(x+2); realX = width-(x+2);
} }
byte *dest = &(((byte*)_out.pixels)[((y + ypos) * _out.pitch) + ((realX * 8) + xpos)]);
int destY = y + ypos;
int destX = realX * 8 + xpos;
if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) {
byte *destPtr = &(((byte*)_out.pixels)[destY * _out.pitch + destX]);
for (int i = 0; i <= 6; i += 2) { for (int i = 0; i <= 6; i += 2) {
if ((d = (c >> i) & 0x03)) { pcolor = (color >> i) & 3;
b = actorColors[d]; if (pcolor) {
*dest++ = b; destPtr[0] = palette[pcolor];
*dest++ = b; destPtr[1] = palette[pcolor];
continue; }
destPtr += 2;
} }
dest += 2;
} }
} }
} }
} else { } else {
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
byte c = data[y*width+x]; byte color = data[y * width + x];
byte b, d; byte pcolor;
byte *dest = &(((byte*)_out.pixels)[((y + ypos) * _out.pitch) + ((x * 8) + xpos)]);
int destY = y + ypos;
int destX = x * 8 + xpos;
if (destY >= 0 && destY < _out.h && destX >= 0 && destX < _out.w) {
byte *destPtr = &(((byte*)_out.pixels)[destY * _out.pitch + destX]);
for (int i = 6; i >= 0; i -= 2) { for (int i = 6; i >= 0; i -= 2) {
if ((d = (c >> i) & 0x03)) { pcolor = (color >> i) & 3;
b = actorColors[d]; if (pcolor) {
*dest++ = b; destPtr[0] = palette[pcolor];
*dest++ = b; destPtr[1] = palette[pcolor];
continue; }
destPtr += 2;
} }
dest += 2;
} }
} }
} }