aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorOliver Kiehl2003-05-26 19:25:24 +0000
committerOliver Kiehl2003-05-26 19:25:24 +0000
commitd08a06ea88d640acf2f8e7cbf6a92b7cbb25e19a (patch)
tree92c4ccc54d04181127518795ddbaabd415a02486 /sky
parentd95832d732821cdea215ab157cb666af40a3c2ec (diff)
downloadscummvm-rg350-d08a06ea88d640acf2f8e7cbf6a92b7cbb25e19a.tar.gz
scummvm-rg350-d08a06ea88d640acf2f8e7cbf6a92b7cbb25e19a.tar.bz2
scummvm-rg350-d08a06ea88d640acf2f8e7cbf6a92b7cbb25e19a.zip
cleanup (add supportive function getSub() )
svn-id: r8013
Diffstat (limited to 'sky')
-rw-r--r--sky/compact.cpp23
-rw-r--r--sky/compact.h1
-rw-r--r--sky/logic.cpp48
3 files changed, 42 insertions, 30 deletions
diff --git a/sky/compact.cpp b/sky/compact.cpp
index 10a4a6bca7..e11d6c5fdc 100644
--- a/sky/compact.cpp
+++ b/sky/compact.cpp
@@ -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),
diff --git a/sky/compact.h b/sky/compact.h
index 02a5911652..364731ec9c 100644
--- a/sky/compact.h
+++ b/sky/compact.h
@@ -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[];
diff --git a/sky/logic.cpp b/sky/logic.cpp
index 8753e7baa6..58c2292f98 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -109,8 +109,8 @@ void SkyLogic::logicScript() {
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 @@ void SkyLogic::arAnim() {
// 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 @@ void SkyLogic::arAnim() {
// 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::arTurn() {
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 @@ void SkyLogic::stopped() {
// 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::runGetOff() {
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 @@ uint32 SkyLogic::fnInteract(uint32 targetId, uint32 b, uint32 c) {
_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 @@ uint32 SkyLogic::fnGetTo(uint32 targetPlaceId, uint32 mode, uint32 c) {
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
}