[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.410,2.411 gfx.h,1.105,1.106 verbs.cpp,1.119,1.120
Eugene Sandulenko
sev at users.sourceforge.net
Tue Mar 22 13:07:44 CET 2005
- Previous message: [Scummvm-cvs-logs] CVS: web/docs md5.inc,1.56,1.57
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.401,2.402 script_v100he.cpp,2.96,2.97 script_v72he.cpp,2.222,2.223 script_v7he.cpp,2.134,2.135 script_v90he.cpp,2.190,2.191
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16656
Modified Files:
gfx.cpp gfx.h verbs.cpp
Log Message:
Patch from Quietust for MM NES
o objects now update tile colors and mask data
o mask data is drawn from the correct offset
o verbs are drawn in the correct color
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.410
retrieving revision 2.411
diff -u -d -r2.410 -r2.411
--- gfx.cpp 21 Mar 2005 23:51:29 -0000 2.410
+++ gfx.cpp 22 Mar 2005 21:06:41 -0000 2.411
@@ -1440,7 +1440,7 @@
if (_vm->_version == 1) {
mask_ptr = getMaskBuffer(x, y, 1);
if (_vm->_features & GF_NES) {
- drawStripNESMask(mask_ptr, stripnr, height);
+ drawStripNESMask(mask_ptr, stripnr, height, _C64ObjectMode);
} else {
drawStripC64Mask(mask_ptr, stripnr, width, height);
}
@@ -1833,8 +1833,7 @@
void decodeNESTileData(const byte *src, byte *dest) {
int len = READ_LE_UINT16(src); src += 2;
const byte *end = src + len;
- int numtiles;
- numtiles = *src++; // not currently used
+ int numtiles = *src++; // not currently used
while (src < end) {
byte data = *src++;
for (int j = 0; j < (data & 0x7F); j++)
@@ -1886,12 +1885,13 @@
const byte *mdata = room + READ_LE_UINT16(room + 0x0E);
int mask = *mdata++;
- if (mask == 0)
- return;
- if (mask != 1) {
- debug(0,"NES room %i has irregular mask count %i!",_vm->_currentRoom,mask);
+ if (mask == 0) {
+ _NEShasmask = false;
return;
}
+ _NEShasmask = true;
+ if (mask != 1)
+ debug(0,"NES room %i has irregular mask count %i!",_vm->_currentRoom,mask);
int mwidth = *mdata++;
for (i = 0; i < 16; i++) {
n = 0;
@@ -1906,14 +1906,16 @@
}
void Gdi::decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height) {
- int y;
+ int x, y;
_NESObj_x = xpos;
+
+ // decode tile update data
+ memcpy(_NESNametableObj,_NESNametable,16*64);
ypos /= 8;
height /= 8;
-
for (y = ypos; y < ypos + height; y++) {
- int x = xpos;
+ x = xpos;
while (x < xpos + width) {
byte len = *ptr++;
for (int i = 0; i < (len & 0x7F); i++)
@@ -1922,6 +1924,64 @@
ptr++;
}
}
+
+ int ax, ay;
+ // decode attribute update data
+ memcpy(_NESAttributesObj, _NESAttributes,64);
+ y = height / 2;
+ ay = ypos;
+ while (y) {
+ ax = xpos + 2;
+ x = 0;
+ int adata = 0;
+ while (x < (width >> 1)) {
+ if (!(x & 3))
+ adata = *ptr++;
+ byte *dest = &_NESAttributesObj[((ay << 2) & 0x30) | ((ax >> 2) & 0xF)];
+
+ int aand = 3;
+ int aor = adata & 3;
+ if (ay & 0x02) {
+ aand <<= 4;
+ aor <<= 4;
+ }
+ if (ax & 0x02) {
+ aand <<= 2;
+ aor <<= 2;
+ }
+ *dest = ((~aand) & *dest) | aor;
+
+ adata >>= 2;
+ ax += 2;
+ x++;
+ }
+ ay += 2;
+ y--;
+ }
+
+ // decode mask update data
+ if (!_NEShasmask)
+ return;
+ memcpy(_NESMasktableObj, _NESMasktable,16*8);
+ int mx, mwidth;
+ int lmask, rmask;
+ mx = *ptr++;
+ mwidth = *ptr++;
+ lmask = *ptr++;
+ rmask = *ptr++;
+
+ y = 0;
+ do {
+ byte *dest = &_NESMasktableObj[y + ypos][mx];
+ *dest++ = (*dest & lmask) | *ptr++;
+ for (x = 1; x < mwidth; x++) {
+ if (x + 1 == mwidth)
+ *dest++ = (*dest & rmask) | *ptr++;
+ else
+ *dest++ = *ptr++;
+ }
+ y++;
+ } while (y < height);
}
void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height, bool isObject) {
@@ -1937,8 +1997,8 @@
return;
}
for (int y = top; y < top + height; y++) {
- int palette = (_NESAttributes[((y << 2) & 0x30) | ((x >> 2) & 0xF)] >> (((y & 2) << 1) | (x & 2))) & 0x3;
- int tile = isObject ? _NESNametableObj[y][x] : _NESNametable[y][x];
+ int palette = ((isObject ? _NESAttributesObj : _NESAttributes)[((y << 2) & 0x30) | ((x >> 2) & 0xF)] >> (((y & 2) << 1) | (x & 2))) & 0x3;
+ int tile = (isObject ? _NESNametableObj : _NESNametable)[y][x];
for (int i = 0; i < 8; i++) {
byte c0 = _vm->_NESPatTable[tile * 16 + i];
@@ -1950,15 +2010,21 @@
}
}
-void Gdi::drawStripNESMask(byte *dst, int stripnr, int height) const {
+void Gdi::drawStripNESMask(byte *dst, int stripnr, int height, bool isObject) const {
+ if (!_NEShasmask)
+ return;
height /= 8;
- int x = stripnr;
+ int x = stripnr + 2;
+
+ if (isObject)
+ x += _NESObj_x; // for objects, need to start at the left edge of the object, not the screen
if (x > 63) {
debug(0,"NES tried to mask invalid strip %i",stripnr);
return;
}
for (int y = 0; y < height; y++) {
- byte c = ((_NESMasktable[y][x >> 3] >> (x & 7)) & 1) ? 0xFF : 0x00;
+ // the ? 0xFF : 0x00 here might be backwards - '1' bits indicate that sprites can get hidden
+ byte c = (((isObject ? _NESMasktableObj : _NESMasktable)[y][x >> 3] >> (x & 7)) & 1) ? 0xFF : 0x00;
for (int i = 0; i < 8; i++) {
*dst = c;
dst += _numStrips;
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -d -r1.105 -r1.106
--- gfx.h 21 Mar 2005 23:51:47 -0000 1.105
+++ gfx.h 22 Mar 2005 21:07:00 -0000 1.106
@@ -229,11 +229,12 @@
byte _C64MaskMap[4096], _C64MaskChar[4096];
bool _C64ObjectMode;
- byte _NESNametable[16][64], _NESAttributes[64];
byte _NESBaseTiles;
- byte _NESNametableObj[16][64];
- byte _NESMasktable[16][8];
+ byte _NESNametable[16][64], _NESNametableObj[16][64];
+ byte _NESAttributes[64], _NESAttributesObj[64];
+ byte _NESMasktable[16][8], _NESMasktableObj[16][8];
int _NESObj_x;
+ bool _NEShasmask;
/* Bitmap decompressors */
bool decompressBitmap(byte *dst, int dstPitch, const byte *src, int numLinesToProcess);
@@ -258,7 +259,7 @@
/* Mask decompressors */
void drawStripC64Mask(byte *dst, int stripnr, int width, int height) const;
- void drawStripNESMask(byte *dst, int stripnr, int height) const;
+ void drawStripNESMask(byte *dst, int stripnr, int height, bool isObject) const;
void decompressMaskImgOr(byte *dst, const byte *src, int height) const;
void decompressMaskImg(byte *dst, const byte *src, int height) const;
Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- verbs.cpp 22 Mar 2005 00:46:48 -0000 1.119
+++ verbs.cpp 22 Mar 2005 21:07:00 -0000 1.120
@@ -40,7 +40,11 @@
int i;
int arrow_color, color, hi_color;
- if (_version == 1) {
+ if (_features & GF_NES) {
+ color = 0;
+ hi_color = 0;
+ arrow_color = 0;
+ } else if (_version == 1) {
color = 16;
hi_color = 7;
arrow_color = 6;
- Previous message: [Scummvm-cvs-logs] CVS: web/docs md5.inc,1.56,1.57
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.401,2.402 script_v100he.cpp,2.96,2.97 script_v72he.cpp,2.222,2.223 script_v7he.cpp,2.134,2.135 script_v90he.cpp,2.190,2.191
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list