diff options
| -rw-r--r-- | scumm/costume.cpp | 2 | ||||
| -rw-r--r-- | scumm/gfx.cpp | 34 | ||||
| -rw-r--r-- | scumm/gfx.h | 5 | ||||
| -rw-r--r-- | scumm/object.cpp | 6 | ||||
| -rw-r--r-- | scumm/verbs.cpp | 66 | 
5 files changed, 84 insertions, 29 deletions
| diff --git a/scumm/costume.cpp b/scumm/costume.cpp index 27c5a4ce5b..d160c27be1 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -842,7 +842,7 @@ void ScummEngine::cost_decodeData(Actor *a, int frame, uint usemask) {  	if (_features & GF_NES) {  		a->_cost.curpos[0] = 0;  		a->_cost.start[0] = 0; -		a->_cost.end[0] = getResourceAddress(rtCostume,a->_costume)[2+0*2+1]; +		a->_cost.end[0] = getResourceAddress(rtCostume, a->_costume)[2 + 8 * frame + 2 * newDirToOldDir(a->getFacing()) + 1];  		a->_cost.frame[0] = frame;  		return;  	} diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 509d297bb9..99d8fb0859 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1371,7 +1371,7 @@ void Gdi::drawBitmap(const byte *ptr, VirtScreen *vs, int x, int y, const int wi  		if (_vm->_version == 1) {  			if (_vm->_features & GF_NES) -				drawStripNES(dstPtr, vs->pitch, stripnr, height); +				drawStripNES(dstPtr, vs->pitch, stripnr, y, height, _C64ObjectMode);  			else if (_C64ObjectMode)  				drawStripC64Object(dstPtr, vs->pitch, stripnr, width, height);  			else @@ -1872,22 +1872,40 @@ void Gdi::decodeNESGfx(const byte *room) {  	// there's another pointer at room + 0x0E, but I don't know what data it points at  } -void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int height) { +void Gdi::decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height) { +	int y; + +	_NESObj_x = xpos; +	ypos /= 8; +	height /= 8; + +	for (y = ypos; y < ypos + height; y++) { +		int x = xpos; +		while (x < xpos + width) { +			byte len = *ptr++; +			for (int i = 0; i < (len & 0x7F); i++) +				_NESNametableObj[y][2 + x++] = (len & 0x80) ? (*ptr++) : (*ptr); +			if (!(len & 0x80)) +				ptr++; +		} +	} +} + +void Gdi::drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height, bool isObject) {  //	printf("drawStripNES, pitch=%i, strip=%i, height=%i\n",dstPitch,stripnr,height); +	top /= 8;  	height /= 8;  	int x = stripnr + 2;	// NES version has a 2 tile gap on each edge -	if (height > 16) { -//		debug(0,"NES room data %i (not 128) pixels high!\n",height); -		height = 16; -	} +	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 render invalid strip %i",stripnr);  		return;  	} -	for (int y = 0; y < height; y++) { +	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 = _NESNametable[y][x]; +		int tile = isObject ? _NESNametableObj[y][x] : _NESNametable[y][x];  		for (int i = 0; i < 8; i++) {  			byte c0 = _NESPatTable[tile * 16 + i]; diff --git a/scumm/gfx.h b/scumm/gfx.h index df55ca8a5b..d32682e5bb 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -231,6 +231,8 @@ protected:  	byte _NESPatTable[4096], _NESNametable[16][64], _NESAttributes[64], _NESPalette[16];  	byte _NESBaseTiles; +	byte _NESNametableObj[16][64]; +	int _NESObj_x;  	/* Bitmap decompressors */  	bool decompressBitmap(byte *dst, int dstPitch, const byte *src, int numLinesToProcess); @@ -238,7 +240,7 @@ protected:  	void drawStripEGA(byte *dst, int dstPitch, const byte *src, int height) const;  	void drawStripC64Object(byte *dst, int dstPitch, int stripnr, int width, int height);  	void drawStripC64Background(byte *dst, int dstPitch, int stripnr, int height); -	void drawStripNES(byte *dst, int dstPitch, int stripnr, int height); +	void drawStripNES(byte *dst, int dstPitch, int stripnr, int top, int height, bool isObject);  	void drawStripComplex(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const;  	void drawStripBasicH(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const; @@ -280,6 +282,7 @@ public:  	StripTable *generateStripTable(const byte *src, int width, int height, StripTable *table) const;  	void decodeC64Gfx(const byte *src, byte *dst, int size) const;  	void decodeNESGfx(const byte *room); +	void decodeNESObject(const byte *ptr, int xpos, int ypos, int width, int height);  	void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip);  	void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h); diff --git a/scumm/object.cpp b/scumm/object.cpp index 11ba41d06e..b535709a9e 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -482,7 +482,11 @@ void ScummEngine::drawObject(int obj, int arg) {  		if (_version == 1) {  			gdi._C64ObjectMode = true; -			gdi.decodeC64Gfx(ptr, gdi._C64ObjectMap, width * (height / 8) * 3); +			if (_features & GF_NES) { +				gdi.decodeNESObject(ptr, xpos, ypos, width, height); +			} else { +				gdi.decodeC64Gfx(ptr, gdi._C64ObjectMap, width * (height / 8) * 3); +			}  		}  		// Sam & Max needs this to fix object-layering problems with  		// the inventory and conversation icons. diff --git a/scumm/verbs.cpp b/scumm/verbs.cpp index d7d3b95d6e..dc514cf8c2 100644 --- a/scumm/verbs.cpp +++ b/scumm/verbs.cpp @@ -55,19 +55,32 @@ void ScummEngine_v2::initV2MouseOver() {  	// Inventory items  	for (i = 0; i < 2; i++) { -		v2_mouseover_boxes[2 * i].rect.left = 0; -		v2_mouseover_boxes[2 * i].rect.right = 144; -		v2_mouseover_boxes[2 * i].rect.top = 32 + 8 * i; -		v2_mouseover_boxes[2 * i].rect.bottom = v2_mouseover_boxes[2 * i].rect.top + 8; +		if (_features & GF_NES) { +			v2_mouseover_boxes[2 * i].rect.left = 0; +			v2_mouseover_boxes[2 * i].rect.right = 96; +			v2_mouseover_boxes[2 * i].rect.top = 48 + 8 * i; +			v2_mouseover_boxes[2 * i].rect.bottom = v2_mouseover_boxes[2 * i].rect.top + 8; +		} else { +			v2_mouseover_boxes[2 * i].rect.left = 0; +			v2_mouseover_boxes[2 * i].rect.right = 144; +			v2_mouseover_boxes[2 * i].rect.top = 32 + 8 * i; +			v2_mouseover_boxes[2 * i].rect.bottom = v2_mouseover_boxes[2 * i].rect.top + 8; +		}  		v2_mouseover_boxes[2 * i].color = color;  		v2_mouseover_boxes[2 * i].hicolor = hi_color; - -		v2_mouseover_boxes[2 * i + 1].rect.left = 176; -		v2_mouseover_boxes[2 * i + 1].rect.right = 320; -		v2_mouseover_boxes[2 * i + 1].rect.top = v2_mouseover_boxes[2 * i].rect.top; -		v2_mouseover_boxes[2 * i + 1].rect.bottom = v2_mouseover_boxes[2 * i].rect.bottom; +		if (_features & GF_NES) { +			v2_mouseover_boxes[2 * i + 1].rect.left = 128; +			v2_mouseover_boxes[2 * i + 1].rect.right = 224; +			v2_mouseover_boxes[2 * i + 1].rect.top = v2_mouseover_boxes[2 * i].rect.top; +			v2_mouseover_boxes[2 * i + 1].rect.bottom = v2_mouseover_boxes[2 * i].rect.bottom; +		} else { +			v2_mouseover_boxes[2 * i + 1].rect.left = 176; +			v2_mouseover_boxes[2 * i + 1].rect.right = 320; +			v2_mouseover_boxes[2 * i + 1].rect.top = v2_mouseover_boxes[2 * i].rect.top; +			v2_mouseover_boxes[2 * i + 1].rect.bottom = v2_mouseover_boxes[2 * i].rect.bottom; +		}  		v2_mouseover_boxes[2 * i + 1].color = color;  		v2_mouseover_boxes[2 * i + 1].hicolor = hi_color; @@ -75,18 +88,32 @@ void ScummEngine_v2::initV2MouseOver() {  	// Inventory arrows -	v2_mouseover_boxes[kInventoryUpArrow].rect.left = 144; -	v2_mouseover_boxes[kInventoryUpArrow].rect.right = 176; -	v2_mouseover_boxes[kInventoryUpArrow].rect.top = 32; -	v2_mouseover_boxes[kInventoryUpArrow].rect.bottom = 40; +	if (_features & GF_NES) { +		v2_mouseover_boxes[kInventoryUpArrow].rect.left = 96; +		v2_mouseover_boxes[kInventoryUpArrow].rect.right = 128; +		v2_mouseover_boxes[kInventoryUpArrow].rect.top = 48; +		v2_mouseover_boxes[kInventoryUpArrow].rect.bottom = 56; +	} else { +		v2_mouseover_boxes[kInventoryUpArrow].rect.left = 144; +		v2_mouseover_boxes[kInventoryUpArrow].rect.right = 176; +		v2_mouseover_boxes[kInventoryUpArrow].rect.top = 32; +		v2_mouseover_boxes[kInventoryUpArrow].rect.bottom = 40; +	}  	v2_mouseover_boxes[kInventoryUpArrow].color = arrow_color;  	v2_mouseover_boxes[kInventoryUpArrow].hicolor = hi_color; -	v2_mouseover_boxes[kInventoryDownArrow].rect.left = 144; -	v2_mouseover_boxes[kInventoryDownArrow].rect.right = 176; -	v2_mouseover_boxes[kInventoryDownArrow].rect.top = 40; -	v2_mouseover_boxes[kInventoryDownArrow].rect.bottom = 48; +	if (_features & GF_NES) { +		v2_mouseover_boxes[kInventoryDownArrow].rect.left = 96; +		v2_mouseover_boxes[kInventoryDownArrow].rect.right = 128; +		v2_mouseover_boxes[kInventoryDownArrow].rect.top = 56; +		v2_mouseover_boxes[kInventoryDownArrow].rect.bottom = 64; +	} else { +		v2_mouseover_boxes[kInventoryDownArrow].rect.left = 144; +		v2_mouseover_boxes[kInventoryDownArrow].rect.right = 176; +		v2_mouseover_boxes[kInventoryDownArrow].rect.top = 40; +		v2_mouseover_boxes[kInventoryDownArrow].rect.bottom = 48; +	}  	v2_mouseover_boxes[kInventoryDownArrow].color = arrow_color;  	v2_mouseover_boxes[kInventoryDownArrow].hicolor = hi_color; @@ -94,7 +121,10 @@ void ScummEngine_v2::initV2MouseOver() {  	// Sentence line  	v2_mouseover_boxes[kSentenceLine].rect.left = 0; -	v2_mouseover_boxes[kSentenceLine].rect.right = 320; +	if (_features & GF_NES) +		v2_mouseover_boxes[kSentenceLine].rect.right = 224; +	else +		v2_mouseover_boxes[kSentenceLine].rect.right = 320;  	v2_mouseover_boxes[kSentenceLine].rect.top = 0;  	v2_mouseover_boxes[kSentenceLine].rect.bottom = 8; | 
