[Scummvm-cvs-logs] CVS: scummvm/sky logic.cpp,1.47,1.48 compact.cpp,1.6,1.7 compact.h,1.3,1.4

Oliver Kiehl olki at users.sourceforge.net
Mon May 26 12:26:11 CEST 2003


Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv11309

Modified Files:
	logic.cpp compact.cpp compact.h 
Log Message:
cleanup (add supportive function getSub() )


Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- logic.cpp	26 May 2003 19:04:04 -0000	1.47
+++ logic.cpp	26 May 2003 19:25:23 -0000	1.48
@@ -109,8 +109,8 @@
 	for (;;) {
 		uint16 mode = _compact->mode; // get pointer to current script
 		printf("compact mode: %d\n", mode);
-		uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + mode);
-		uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + mode + 2);
+		uint16 *scriptNo = SkyCompact::getSub(_compact, mode);
+		uint16 *offset   = SkyCompact::getSub(_compact, mode + 2);
 
 		uint32 scr = script(*scriptNo, *offset);
 		*scriptNo = (uint16)(scr & 0xffff);
@@ -224,7 +224,7 @@
 				// tell it it is waiting for us
 				cpt->extCompact->waitingFor = (uint16)(_scriptVariables[CUR_ID] & 0xffff);
 				// restart current script
-				*(uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2) = 0;
+				*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
 				_compact->logic = L_SCRIPT;
 				logicScript();
 				return;
@@ -267,7 +267,7 @@
 
 	// changed so restart the current script
 	// *not suitable for base initiated ARing
-	*(uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2) = 0;
+	*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
 
 	_compact->logic = L_SCRIPT;
 	logicScript();
@@ -340,13 +340,9 @@
 
 void SkyLogic::alt() {
 	// change the current script
-
 	_compact->logic = L_SCRIPT;
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2);
-	*scriptNo = _compact->extCompact->alt;
-	*offset = 0;
-
+	*SkyCompact::getSub(_compact, _compact->mode) = _compact->extCompact->alt;
+	*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
 	logicScript();
 }
 
@@ -432,7 +428,7 @@
 	// we are free, continue processing the script
 
 	// restart script one level below
-	*(uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode - 2) = 0;
+	*SkyCompact::getSub(_compact, _compact->mode - 2) = 0;
 	_compact->extCompact->waitingFor = 0xffff;
 
 	_compact->logic = L_SCRIPT;
@@ -614,8 +610,8 @@
 void SkyLogic::stopAndWait() {
 	_compact->mode += 4;
 
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2);
+	uint16 *scriptNo = SkyCompact::getSub(_compact, _compact->mode);
+	uint16 *offset   = SkyCompact::getSub(_compact, _compact->mode + 2);
 
 	*scriptNo = (uint16)(_compact->extCompact->stopScript & 0xffff);
 	*offset   = (uint16)(_compact->extCompact->stopScript >> 16);
@@ -1152,31 +1148,24 @@
 	_compact->logic = L_SCRIPT;
 	Compact *cpt = SkyState::fetchCompact(targetId);
 
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2);
-
-	*scriptNo = cpt->actionScript;
-	*offset = 0;
+	*SkyCompact::getSub(_compact, _compact->mode) = cpt->actionScript;
+	*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
 
 	return 0;
 }
 
 uint32 SkyLogic::fnStartSub(uint32 scr, uint32 b, uint32 c) {
 	_compact->mode += 4;
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2);
-	*scriptNo = (uint16)(scr & 0xffff);
-	*offset   = (uint16)(scr >> 16);
+	*SkyCompact::getSub(_compact, _compact->mode) = (uint16)(scr & 0xffff);
+	*SkyCompact::getSub(_compact, _compact->mode + 2) = (uint16)(scr >> 16);
 	return 0;
 }
 
 uint32 SkyLogic::fnTheyStartSub(uint32 mega, uint32 scr, uint32 c) {
 	Compact *cpt = SkyState::fetchCompact(mega);
 	cpt->mode += 4;
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(cpt, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(cpt, C_BASE_SUB + _compact->mode + 2);
-	*scriptNo = (uint16)(scr & 0xffff);
-	*offset   = (uint16)(scr >> 16);
+	*SkyCompact::getSub(cpt, _compact->mode) = (uint16)(scr & 0xffff);
+	*SkyCompact::getSub(cpt, _compact->mode + 2) = (uint16)(scr >> 16);
 	return 1;
 }
 
@@ -1235,10 +1224,9 @@
 	while (*getToTable != targetPlaceId)
 		getToTable += 2;
 
-	uint16 *scriptNo = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode);
-	uint16 *offset   = (uint16 *)SkyCompact::getCompactElem(_compact, C_BASE_SUB + _compact->mode + 2);
-	*scriptNo = *(getToTable + 1); // get new script
-	*offset = 0;
+	// get new script
+	*SkyCompact::getSub(_compact, _compact->mode) = *(getToTable + 1);
+	*SkyCompact::getSub(_compact, _compact->mode + 2) = 0;
 
 	return 0; // drop out of script
 }

Index: compact.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/compact.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- compact.cpp	2 May 2003 11:57:33 -0000	1.6
+++ compact.cpp	26 May 2003 19:25:24 -0000	1.7
@@ -50,6 +50,29 @@
 
 namespace SkyCompact {
 
+uint16 *getSub(Compact *cpt, uint16 mode) {
+	switch (mode) {
+	case 0:
+		return &(cpt->baseSub);
+	case 2:
+		return &(cpt->baseSub_off);
+	case 4:
+		return &(cpt->extCompact->actionSub);
+	case 6:
+		return &(cpt->extCompact->actionSub_off);
+	case 8:
+		return &(cpt->extCompact->getToSub);
+	case 10:
+		return &(cpt->extCompact->getToSub_off);
+	case 12:
+		return &(cpt->extCompact->extraSub);
+	case 14:
+		return &(cpt->extCompact->extraSub_off);
+	default:
+		error("Invalid Mode (%d)", mode);
+	}
+}
+
 static const uint32 compactOffsets[] = {
 	MK16(Compact, logic),
 	MK16(Compact, status),

Index: compact.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/compact.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- compact.h	29 Apr 2003 22:33:12 -0000	1.3
+++ compact.h	26 May 2003 19:25:24 -0000	1.4
@@ -27,6 +27,7 @@
 #include "sky/skydefs.h"
 
 namespace SkyCompact {
+	uint16 *getSub(Compact *cpt, uint16 mode);
 	void *getCompactElem(Compact *cpt, uint32 off);
 
 	extern uint16 slide2_seq[];





More information about the Scummvm-git-logs mailing list