[Scummvm-git-logs] scummvm master -> e3040d29c825ad6f6ee4c59017292d60b260a07f

bluegr noreply at scummvm.org
Tue Apr 12 23:48:29 UTC 2022


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
fabec17274 CHEWY: Refactor initialization of cursor animations
e3040d29c8 CHEWY: Use the new text handling code for inventory item usage


Commit: fabec17274e5539f9d523d375354b20271467d51
    https://github.com/scummvm/scummvm/commit/fabec17274e5539f9d523d375354b20271467d51
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-04-13T02:48:10+03:00

Commit Message:
CHEWY: Refactor initialization of cursor animations

Changed paths:
    engines/chewy/cursor.cpp
    engines/chewy/cursor.h
    engines/chewy/globals.h
    engines/chewy/inits.cpp
    engines/chewy/main.cpp
    engines/chewy/ngstypes.h
    engines/chewy/rooms/room04.cpp
    engines/chewy/rooms/room24.cpp


diff --git a/engines/chewy/cursor.cpp b/engines/chewy/cursor.cpp
index 0e933d80f35..5b8b01e4408 100644
--- a/engines/chewy/cursor.cpp
+++ b/engines/chewy/cursor.cpp
@@ -29,7 +29,6 @@ namespace Chewy {
 Cursor::Cursor(CurBlk *curblkp) {
 	_curblk = curblkp;
 
-	_ani = nullptr;
 	_curAniCountdown = 0;
 	_aniCount = 0;
 }
@@ -42,11 +41,11 @@ void Cursor::plot_cur() {
 		_cursorMoveFl = false;
 
 		--_curAniCountdown;
-		if (_curAniCountdown <= 0 && _ani != nullptr) {
-			_curAniCountdown = _ani->_delay;
+		if (_curAniCountdown <= 0) {
+			_curAniCountdown = _animDelay;
 			++_aniCount;
-			if (_aniCount > _ani->_end)
-				_aniCount = _ani->_start;
+			if (_aniCount > _animEnd)
+				_aniCount = _animStart;
 		}
 
 		const uint16 w = READ_LE_INT16(_curblk->sprite[_aniCount]);
@@ -65,10 +64,12 @@ void Cursor::hide_cur() {
 	CursorMan.showMouse(false);
 }
 
-void Cursor::set_cur_ani(CurAni *ani1) {
-	_ani = ani1;
+void Cursor::setAnimation(uint8 start, uint8 end, int16 delay) {
+	_aniCount = _animStart = start;
+	_animEnd = end;
+	if (delay >= 0)
+		_animDelay = delay;
 	_curAniCountdown = 0;
-	_aniCount = _ani->_start;
 }
 
 void Cursor::move(int16 x, int16 y) {
diff --git a/engines/chewy/cursor.h b/engines/chewy/cursor.h
index 715389b7e72..698df518bdd 100644
--- a/engines/chewy/cursor.h
+++ b/engines/chewy/cursor.h
@@ -37,14 +37,18 @@ public:
 	void plot_cur();
 	void show_cur();
 	void hide_cur();
-	void set_cur_ani(CurAni *ani);
+	void setAnimation(uint8 start, uint8 end, int16 delay);
 	void move(int16 x, int16 y);
+	uint8 getAnimStart() const { return _animStart; }
 
 	CurBlk *_curblk = nullptr;
-	CurAni *_ani = nullptr;
 	int _scrWidth = 0;
 	int16 _curAniCountdown = 0;
 	int16 _aniCount = 0;
+
+	uint8 _animStart = 0;
+	uint8 _animEnd = 0;
+	int16 _animDelay = 0;
 };
 
 } // namespace Chewy
diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h
index 1f17bd72361..008875161a8 100644
--- a/engines/chewy/globals.h
+++ b/engines/chewy/globals.h
@@ -208,7 +208,6 @@ public:
 
 	MouseInfo _minfo;
 	CurBlk _curblk;
-	CurAni _curani;
 	RaumBlk _room_blk;
 	Flags _flags = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 					0, 0, 0, 0, 0, 0, 0, 0, 0 };
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index 945f33bccaf..ddb128b3816 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -57,12 +57,9 @@ void standard_init() {
 	_G(curtaf) = _G(mem)->taf_adr(CURSOR_TAF);
 
 	_G(curblk).sprite = _G(curtaf)->_image;
-	_G(curani)._start = 0;
-	_G(curani)._end = 0;
-	_G(curani)._delay = 0;
 	
 	_G(cur) = new Cursor(&_G(curblk));
-	_G(cur)->set_cur_ani(&_G(curani));
+	_G(cur)->setAnimation(0, 0, 0);
 
 	alloc_buffers();
 	_G(pal)[765] = 63;
diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index 70bc4127b3c..f24c11cab84 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -92,116 +92,77 @@ void free_buffers() {
 
 void cursorChoice(int16 nr) {
 	int16 ok = true;
+	int16 delay = -1;
+
 	if (nr != CUR_USER) {
 		_G(curblk).sprite = _G(curtaf)->_image;
-		_G(curani)._delay = (1 + _G(gameState).DelaySpeed) * 5;
+		delay = (1 + _G(gameState).DelaySpeed) * 5;
 	}
 	switch (nr) {
 	case CUR_WALK:
-		_G(curani)._start = 0;
-		_G(curani)._end = 3;
+		_G(cur)->setAnimation(0, 3, delay);
 		break;
-
 	case CUR_NO_WALK:
-		_G(curani)._start = 8;
-		_G(curani)._end = 8;
+		_G(cur)->setAnimation(8, 8, delay);
 		break;
-
 	case CUR_USE:
-		_G(curani)._start = 4;
-		_G(curani)._end = 7;
+		_G(cur)->setAnimation(4, 7, delay);
 		break;
-
 	case CUR_NO_USE:
-		_G(curani)._start = 4;
-		_G(curani)._end = 4;
+		_G(cur)->setAnimation(4, 4, delay);
 		break;
-
 	case CUR_NOPE:
-		_G(curani)._start = 9;
-		_G(curani)._end = 12;
+		_G(cur)->setAnimation(9, 12, delay);
 		break;
-
 	case CUR_LOOK:
-		_G(curani)._start = 13;
-		_G(curani)._end = 16;
+		_G(cur)->setAnimation(13, 16, delay);
 		break;
-
 	case CUR_NO_LOOK:
-		_G(curani)._start = 16;
-		_G(curani)._end = 16;
+		_G(cur)->setAnimation(16, 16, delay);
 		break;
-
 	case CUR_TALK:
-		_G(curani)._start = 17;
-		_G(curani)._end = 20;
+		_G(cur)->setAnimation(17, 20, delay);
 		break;
-
 	case CUR_NO_TALK:
-		_G(curani)._start = 17;
-		_G(curani)._end = 17;
+		_G(cur)->setAnimation(17, 17, delay);
 		break;
-
 	case CUR_INVENT:
-		_G(curani)._start = 21;
-		_G(curani)._end = 24;
+		_G(cur)->setAnimation(21, 24, delay);
 		break;
-
 	case CUR_AK_INVENT:
-		_G(curani)._start = _G(gameState).AkInvent;
-		_G(curani)._end = _G(gameState).AkInvent;
+		_G(cur)->setAnimation(_G(gameState).AkInvent, _G(gameState).AkInvent, delay);
 		_G(curblk).sprite = &_G(inv_spr)[0];
 		_G(gameState).inv_cur = true;
 		break;
-
 	case CUR_SAVE:
-		_G(curani)._start = 25;
-		_G(curani)._end = 25;
+		_G(cur)->setAnimation(25, 25, delay);
 		break;
-
 	case CUR_EXIT_LEFT:
-		_G(curani)._start = EXIT_LEFT_SPR;
-		_G(curani)._end = EXIT_LEFT_SPR;
+		_G(cur)->setAnimation(EXIT_LEFT_SPR, EXIT_LEFT_SPR, delay);
 		break;
-
 	case CUR_EXIT_RIGHT:
-		_G(curani)._start = EXIT_RIGHT_SPR;
-		_G(curani)._end = EXIT_RIGHT_SPR;
+		_G(cur)->setAnimation(EXIT_RIGHT_SPR, EXIT_RIGHT_SPR, delay);
 		break;
-
 	case CUR_EXIT_TOP:
-		_G(curani)._start = EXIT_ABOVE_SPR;
-		_G(curani)._end = EXIT_ABOVE_SPR;
+		_G(cur)->setAnimation(EXIT_ABOVE_SPR, EXIT_ABOVE_SPR, delay);
 		break;
-
 	case CUR_EXIT_BOTTOM:
-		_G(curani)._start = EXIT_BOTTOM_SPR;
-		_G(curani)._end = EXIT_BOTTOM_SPR;
+		_G(cur)->setAnimation(EXIT_BOTTOM_SPR, EXIT_BOTTOM_SPR, delay);
 		break;
-
 	case CUR_DISK:
-		_G(curani)._start = 30;
-		_G(curani)._end = 30;
+		_G(cur)->setAnimation(30, 30, delay);
 		break;
-
 	case CUR_HOWARD:
-		_G(curani)._start = 31;
-		_G(curani)._end = 31;
+		_G(cur)->setAnimation(31, 31, delay);
 		break;
-
 	case CUR_NICHELLE:
-		_G(curani)._start = 37;
-		_G(curani)._end = 37;
+		_G(cur)->setAnimation(37, 37, delay);
 		break;
-
 	case CUR_ZEIGE:
-		_G(curani)._start = 9;
-		_G(curani)._end = 9;
+		_G(cur)->setAnimation(9, 9, delay);
 		break;
 	case CUR_USER:
-
 		break;
-
 	default:
 		ok = false;
 		break;
@@ -209,9 +170,8 @@ void cursorChoice(int16 nr) {
 
 	if (ok) {
 		_cursorMoveFl = true;
-		_G(cur)->set_cur_ani(&_G(curani));
-		_G(gameState)._curWidth = READ_LE_INT16(_G(curblk).sprite[_G(curani)._start]);
-		_G(gameState)._curHeight = READ_LE_INT16(_G(curblk).sprite[_G(curani)._start] + 2);
+		_G(gameState)._curWidth = READ_LE_INT16(_G(curblk).sprite[_G(cur)->getAnimStart()]);
+		_G(gameState)._curHeight = READ_LE_INT16(_G(curblk).sprite[_G(cur)->getAnimStart()] + 2);
 	}
 }
 
diff --git a/engines/chewy/ngstypes.h b/engines/chewy/ngstypes.h
index ba110a965e8..af2edd72dbe 100644
--- a/engines/chewy/ngstypes.h
+++ b/engines/chewy/ngstypes.h
@@ -80,12 +80,6 @@ struct CurBlk {
 	byte **sprite = nullptr;
 };
 
-struct CurAni {
-	uint8 _start = 0;
-	uint8 _end = 0;
-	int16 _delay = 0;
-};
-
 struct CustomInfo {
 	byte *TempArea = 0;
 };
diff --git a/engines/chewy/rooms/room04.cpp b/engines/chewy/rooms/room04.cpp
index 7f99ffee691..99040a46c18 100644
--- a/engines/chewy/rooms/room04.cpp
+++ b/engines/chewy/rooms/room04.cpp
@@ -98,11 +98,9 @@ int16 Room4::comp_probe() {
 		_G(spr_info)[0]._y = CUR_POS[curX][1];
 
 		if (_G(minfo)._button == 1 || g_events->_kbInfo._keyCode == Common::KEYCODE_RETURN) {
-			_G(curani)._start = HAND_CLICK;
-			_G(curani)._end = HAND_CLICK;
+			_G(cur)->setAnimation(HAND_CLICK, HAND_CLICK, -1);
 		} else {
-			_G(curani)._start = HAND_NORMAL;
-			_G(curani)._end = HAND_NORMAL;
+			_G(cur)->setAnimation(HAND_NORMAL, HAND_NORMAL, -1);
 		}
 		cursorChoice(CUR_USER);
 		_G(gameState)._curHeight = 16;
diff --git a/engines/chewy/rooms/room24.cpp b/engines/chewy/rooms/room24.cpp
index c1134a631de..a821ac43476 100644
--- a/engines/chewy/rooms/room24.cpp
+++ b/engines/chewy/rooms/room24.cpp
@@ -24,6 +24,8 @@
 #include "chewy/globals.h"
 #include "chewy/room.h"
 #include "chewy/rooms/room24.h"
+
+#include "chewy/cursor.h"
 #include "chewy/sound.h"
 
 namespace Chewy {
@@ -42,8 +44,7 @@ void Room24::entry() {
 	_G(gameState).scrollx = 0;
 	_G(gameState).scrolly = 0;
 	_G(curblk).sprite = _G(room_blk)._detImage;
-	_G(curani)._start = 7;
-	_G(curani)._end = 10;
+	_G(cur)->setAnimation(7, 10, -1);
 	_G(menu_item) = CUR_USER;
 	cursorChoice(CUR_USER);
 


Commit: e3040d29c825ad6f6ee4c59017292d60b260a07f
    https://github.com/scummvm/scummvm/commit/e3040d29c825ad6f6ee4c59017292d60b260a07f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-04-13T02:48:11+03:00

Commit Message:
CHEWY: Use the new text handling code for inventory item usage

Changed paths:
    engines/chewy/dialogs/inventory.cpp
    engines/chewy/t_event.cpp
    engines/chewy/text.cpp


diff --git a/engines/chewy/dialogs/inventory.cpp b/engines/chewy/dialogs/inventory.cpp
index 48b93a565e7..9e2b5d522d8 100644
--- a/engines/chewy/dialogs/inventory.cpp
+++ b/engines/chewy/dialogs/inventory.cpp
@@ -391,7 +391,6 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
 	int16 visibleCount = 0;
 	Common::String itemName;
 	Common::StringArray itemDesc;
-	char *txt_adr = nullptr;
 	char c[2] = { 0 };
 	int16 ret = -1;
 	bool endLoop = false;
@@ -411,16 +410,14 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
 		visibleCount = 3;
 		yoff = 0;
 
-		if (ats_nr >= 15000) {
-			txt_adr = _G(atds)->ats_get_txt(ats_nr - 15000, TXT_MARK_USE, &lineCount, INV_USE_DEF);
-			//itemDesc = _G(atds)->getTextArray(0, ats_nr - 15000, INV_USE_DEF, TXT_MARK_USE);
-		} else {
-			txt_adr = _G(atds)->ats_get_txt(ats_nr, TXT_MARK_USE, &lineCount, INV_USE_DATA);
-			//itemDesc = _G(atds)->getTextArray(0, ats_nr, TXT_MARK_USE, INV_USE_DATA);
-		}
-		if (!txt_adr) {
+		if (ats_nr >= 15000)
+			itemDesc = _G(atds)->getTextArray(0, ats_nr - 15000, INV_USE_DEF, -1);
+		else
+			itemDesc = _G(atds)->getTextArray(0, ats_nr, INV_USE_DATA, -1);
+
+		lineCount = itemDesc.size();
+		if (itemDesc.size() == 0)
 			endLoop = true;
-		}
 	} else {
 		endLoop = true;
 	}
@@ -528,18 +525,12 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
 
 		int16 k = 0;
 
-		if (mode == INV_ATS_MODE) {
+		if (itemDesc.size() > 0) {
 			for (int16 i = startLine; i < lineCount && i < startLine + visibleCount; i++) {
 				_G(out)->printxy(WIN_LOOK_X, WIN_LOOK_Y + yoff + k * 10, 14, 300,
 								 _G(scr_width), itemDesc[i].c_str());
 				++k;
 			}
-		} else {
-			for (int16 i = startLine; i < lineCount && i < startLine + visibleCount; i++) {
-				_G(out)->printxy(WIN_LOOK_X, WIN_LOOK_Y + yoff + k * 10, 14, 300,
-								 _G(scr_width), _G(txt)->strPos(txt_adr, i));
-				++k;
-			}
 		}
 
 		_G(cur)->plot_cur();
diff --git a/engines/chewy/t_event.cpp b/engines/chewy/t_event.cpp
index 4422d6fab3f..b7d51e4a19f 100644
--- a/engines/chewy/t_event.cpp
+++ b/engines/chewy/t_event.cpp
@@ -2296,15 +2296,9 @@ void calc_inv_use_txt(int16 test_nr) {
 }
 
 static void calc_inv_get_text(int16 cur_inv, int16 test_nr) {
-	int16 txt_anz;
-
-	const char *s = _G(atds)->ats_get_txt(31, TXT_MARK_USE, &txt_anz, INV_USE_DEF);
-	//Common::String tmp = _G(atds)->getTextEntry(0, 31, INV_USE_DEF, TXT_MARK_USE);
-	_G(calc_inv_text_str1) = Common::String::format("%s ", s);
+	_G(calc_inv_text_str1) = _G(atds)->getTextEntry(0, 31, INV_USE_DEF) + " ";
 	_G(calc_inv_text_str1) += _G(atds)->getTextEntry(cur_inv, TXT_MARK_NAME, INV_ATS_DATA);
-
-	s = _G(atds)->ats_get_txt(32, TXT_MARK_USE, &txt_anz, INV_USE_DEF);
-	_G(calc_inv_text_str2) = Common::String::format("%s ", s);
+	_G(calc_inv_text_str2) = _G(atds)->getTextEntry(0, 32, INV_USE_DEF) + " ";
 	_G(calc_inv_text_str2) += _G(atds)->getTextEntry(test_nr, TXT_MARK_NAME, INV_ATS_DATA);
 }
 
diff --git a/engines/chewy/text.cpp b/engines/chewy/text.cpp
index 76b7b42a2da..6ffb0438050 100644
--- a/engines/chewy/text.cpp
+++ b/engines/chewy/text.cpp
@@ -102,6 +102,7 @@ TextEntry *Text::getText(uint chunk, uint entry, int type, int subEntry) {
 	case INV_USE_DEF:
 		chunk += kADSTextMax + kATSTextMax + kAADTextMax + kINVTextMax;
 		isInvDesc = true;
+		isText = true;
 		break;
 	case INV_ATS_DATA:
 		chunk += kADSTextMax + kATSTextMax + kAADTextMax;




More information about the Scummvm-git-logs mailing list