aboutsummaryrefslogtreecommitdiff
path: root/sky
diff options
context:
space:
mode:
authorRobert Göffringmann2003-08-03 17:17:24 +0000
committerRobert Göffringmann2003-08-03 17:17:24 +0000
commit31a143dcd48601509e11806c00c443edd1f26b6f (patch)
treebaea15434499cd9bd3592cbe6078194d3884fcf6 /sky
parentd6937ec256d3bc0457e83bf40889f65463a52b81 (diff)
downloadscummvm-rg350-31a143dcd48601509e11806c00c443edd1f26b6f.tar.gz
scummvm-rg350-31a143dcd48601509e11806c00c443edd1f26b6f.tar.bz2
scummvm-rg350-31a143dcd48601509e11806c00c443edd1f26b6f.zip
new compacts, new loading + saving code (not compatible to old one)
svn-id: r9439
Diffstat (limited to 'sky')
-rw-r--r--sky/compact.cpp36
-rw-r--r--sky/compact.h38
-rw-r--r--sky/control.cpp144
-rw-r--r--sky/control.h12
-rw-r--r--sky/logic.cpp112
-rw-r--r--sky/mouse.h2
-rw-r--r--sky/skydefs.h8
-rw-r--r--sky/struc.h10
8 files changed, 213 insertions, 149 deletions
diff --git a/sky/compact.cpp b/sky/compact.cpp
index 981e722d02..15bace2f5b 100644
--- a/sky/compact.cpp
+++ b/sky/compact.cpp
@@ -47,8 +47,44 @@
#define MK32_A5(type, item) MK32(type, item[0]), MK32(type, item[1]), \
MK32(type, item[2]), MK32(type, item[3]), MK32(type, item[4])
+namespace SkyTalkAnims {
+ extern bool animTalkTableIsPointer[];
+ extern uint16 animTalkTableVal[];
+ extern void *animTalkTablePtr[];
+};
+
namespace SkyCompact {
+uint16 *getGrafixPtr(Compact *cpt) {
+ uint16 *buf;
+ switch (cpt->grafixProg.ptrType) {
+ case PTR_NULL:
+ return NULL;
+ case AUTOROUTE:
+ if (!cpt->extCompact)
+ error("::getGrafixPtr: request for AR pointer, extCompact is NULL, though.");
+ return (cpt->extCompact->animScratch + cpt->grafixProg.pos);
+ case COMPACT:
+ buf = (uint16*)SkyState::fetchCompact(cpt->grafixProg.ptrTarget);
+ if (buf == NULL)
+ error("::getGrafixPtr: request for cpt %d pointer. It's NULL.", cpt->grafixProg.ptrTarget);
+ return (buf + cpt->grafixProg.pos);
+ case COMPACTELEM:
+ buf = *(uint16 **)SkyCompact::getCompactElem(cpt, cpt->grafixProg.ptrTarget);
+ if (buf == NULL)
+ error("::getGrafixPtr: request for elem ptr %d. It's NULL.", cpt->grafixProg.ptrTarget);
+ return buf + cpt->grafixProg.pos;
+ case TALKTABLE:
+ buf = (uint16 *)SkyTalkAnims::animTalkTablePtr[cpt->grafixProg.ptrTarget];
+ if (buf == NULL)
+ warning("::getGrafixPtr: request for TT ptr %d -> NULL", cpt->grafixProg.ptrTarget);
+ return buf + cpt->grafixProg.pos;
+ default:
+ error("::getGrafixPtr: unknown grafixProg type for Compact cpt");
+ }
+ return NULL; // never reached
+}
+
/**
* Returns the n'th mega set specified by \a megaSet from Compact \a cpt.
*/
diff --git a/sky/compact.h b/sky/compact.h
index 17eb1d4830..aabad83fef 100644
--- a/sky/compact.h
+++ b/sky/compact.h
@@ -30,6 +30,7 @@ namespace SkyCompact {
MegaSet *getMegaSet(Compact *cpt, uint16 megaSet);
uint16 **getTurnTable(Compact *cpt, uint16 megaSet, uint16 dir);
uint16 *getSub(Compact *cpt, uint16 mode);
+ uint16 *getGrafixPtr(Compact *cpt);
void *getCompactElem(Compact *cpt, uint32 off);
void patchFor288(void);
@@ -3232,24 +3233,25 @@ namespace SkyCompact {
extern uint16 retina_scan_cdt[];
extern Compact forklift_cpt;
extern void *data_0[];
- extern uint8 babs_auto[];
- extern uint8 burke_auto[];
- extern uint8 dan_auto[];
- extern uint8 foreman_auto[];
- extern uint8 full_ss_auto[];
- extern uint8 gal_auto[];
- extern uint8 jobs_auto[];
- extern uint8 joey_auto[];
- extern uint8 ken_auto[];
- extern uint8 lamb_auto[];
- extern uint8 loader_auto[];
- extern uint8 medi_auto[];
- extern uint8 monitor_auto[];
- extern uint8 radman_auto[];
- extern uint8 shades_auto[];
- extern uint8 spu_auto[];
- extern uint8 ss_auto[];
- extern uint8 wit_auto[];
+ extern uint16 babs_auto[];
+ extern uint16 burke_auto[];
+ extern uint16 dan_auto[];
+ extern uint16 foreman_auto[];
+ extern uint16 full_ss_auto[];
+ extern uint16 gal_auto[];
+ extern uint16 jobs_auto[];
+ extern uint16 joey_auto[];
+ extern uint16 ken_auto[];
+ extern uint16 lamb_auto[];
+ extern uint16 loader_auto[];
+ extern uint16 medi_auto[];
+ extern uint16 monitor_auto[];
+ extern uint16 radman_auto[];
+ extern uint16 shades_auto[];
+ extern uint16 spu_auto[];
+ extern uint16 ss_auto[];
+ extern uint16 wit_auto[];
+ extern uint16 minif_auto[];
};
#endif
diff --git a/sky/control.cpp b/sky/control.cpp
index a161066b3e..a48ffd655d 100644
--- a/sky/control.cpp
+++ b/sky/control.cpp
@@ -1128,37 +1128,13 @@ void SkyControl::stosMegaSet(uint8 **destPos, MegaSet *mega) {
// anims, stands, turnTable
}
-void SkyControl::stosGrafStr(uint8 **destPos, Compact *cpt) {
- uint16 strLen = 0;
- uint16 *src = cpt->grafixProg;
- if ((cpt->logic == L_AR_ANIM) || (cpt->logic == L_TURNING)) {
- if ((!src[0]) && (!src[2])) {
- strLen = 3;
- } else {
- if (!src[0])
- strLen += 2;
- while (src[strLen])
- strLen += 2;
- }
- } else if ((cpt->logic == L_MOD_ANIMATE) || (cpt->logic == L_TALK) ||
- (cpt->logic == L_LISTEN) || (cpt->logic == L_FRAMES)) {
- while (src[strLen])
- strLen += 3; // start fx, sendsync and coordinates are all 3 words each.
- } else {
- while (src[strLen]) // this *could* lead to problems... but I can't think
- strLen++; // of a way to find the end of the graphics data if
- } // the compact isn't in any special graphic mode.
- strLen++;
- STOSW(*destPos, strLen);
- for (uint16 cnt = 0; cnt < strLen; cnt++) {
- STOSW(*destPos, src[cnt]);
- }
-}
-
void SkyControl::stosStr(uint8 **destPos, Compact *cpt, uint16 type) {
uint16 strLen = 0;
- if (type & SAVE_GRAFX)
- stosGrafStr(destPos, cpt);
+ if (type & SAVE_GRAFX) {
+ STOSW(*destPos, cpt->grafixProg.ptrType);
+ STOSW(*destPos, cpt->grafixProg.ptrTarget);
+ STOSW(*destPos, cpt->grafixProg.pos);
+ }
if (type & SAVE_TURNP) {
uint16 *src = cpt->extCompact->turnProg;
@@ -1169,7 +1145,7 @@ void SkyControl::stosStr(uint8 **destPos, Compact *cpt, uint16 type) {
for (uint16 cnt = 0; cnt < strLen; cnt++) {
STOSW(*destPos, src[cnt]);
}
- }
+ }
}
void SkyControl::stosCompact(uint8 **destPos, Compact *cpt) {
@@ -1182,7 +1158,8 @@ void SkyControl::stosCompact(uint8 **destPos, Compact *cpt) {
if (cpt->extCompact->megaSet3) saveType |= SAVE_MEGA3;
if (cpt->extCompact->turnProg) saveType |= SAVE_TURNP;
}
- if (cpt->grafixProg) saveType |= SAVE_GRAFX;
+ if (cpt->grafixProg.ptrType != PTR_NULL)
+ saveType |= SAVE_GRAFX;
STOSW(*destPos, saveType);
@@ -1279,6 +1256,11 @@ uint32 SkyControl::prepareSaveData(uint8 *destBuf) {
for (cnt = 0; cnt < ARRAYSIZE(_saveLoadCpts); cnt++)
stosCompact(&destPos, _saveLoadCpts[cnt]);
+ for (cnt = 0; cnt < ARRAYSIZE(_saveLoadARs); cnt++)
+ for (uint8 elemCnt = 0; elemCnt < 32; elemCnt++) {
+ STOSW(destPos, _saveLoadARs[cnt][elemCnt]);
+ }
+
for (cnt = 0; cnt < 3; cnt++)
STOSW(destPos, SkyCompact::park_table[cnt]);
@@ -1339,23 +1321,16 @@ void SkyControl::lodsCompact(uint8 **srcPos, Compact *cpt) {
error("Can't restore! SaveData is SAVE_MEGA3 for Compact");
if (saveType & SAVE_GRAFX) {
- uint16 grafxLen;
- LODSW(*srcPos, grafxLen);
- //cpt->grafixProg = (uint16 *)malloc(grafxLen << 1);
- /* hack: there's a theoretical possibility that the saving routine detected the
- end of the string incorrectly and forgot the end of the data.
- By adding 10 zero-words, the data should at least be correctly terminated
- (as all grafixProg data is 0-terminated), so if this condition really can
- occur, it should only lead to small graphic glitches, not to crashes.*/
-
- cpt->grafixProg = (uint16 *)malloc((grafxLen << 1) + 20);
- memset(cpt->grafixProg + grafxLen, 0, 20);
- appendMemList(cpt->grafixProg);
- for (cnt = 0; cnt < grafxLen; cnt++) {
- LODSW(*srcPos, cpt->grafixProg[cnt]);
- }
- } else
- cpt->grafixProg = NULL;
+ uint16 tmp;
+ LODSW(*srcPos, tmp);
+ cpt->grafixProg.ptrType = (uint8)tmp;
+ LODSW(*srcPos, cpt->grafixProg.ptrTarget);
+ LODSW(*srcPos, cpt->grafixProg.pos);
+ } else {
+ cpt->grafixProg.ptrType = PTR_NULL;
+ cpt->grafixProg.ptrTarget = 0;
+ cpt->grafixProg.pos = 0;
+ }
if (saveType & SAVE_TURNP) {
uint16 turnLen;
@@ -1435,7 +1410,6 @@ void SkyControl::lodsCompact(uint8 **srcPos, Compact *cpt) {
uint16 SkyControl::parseSaveData(uint8 *srcBuf) {
- char loadText[] = "Savegame has an old version. Loading it can lead to errors.";
uint32 reloadList[60];
uint32 oldSection = SkyLogic::_scriptVariables[CUR_SECTION];
@@ -1451,24 +1425,24 @@ uint16 SkyControl::parseSaveData(uint8 *srcBuf) {
return RESTORE_FAILED;
}
+ if (saveRev <= OLD_SAVEGAME_TYPE) {
+ warning("This savegame version is unsupported.");
+ return RESTORE_FAILED;
+ }
uint32 music, mouseType, palette, gameVersion;
- if (saveRev >= 3) {
- LODSD(srcPos, gameVersion);
- if (gameVersion != SkyState::_systemVars.gameVersion) {
- if ((!SkyState::isCDVersion()) || (gameVersion < 365)) { // cd versions are compatible
- printf("This savegame was created by Beneath a Steel Sky v0.0%03d\n", gameVersion);
- printf("It cannot be loaded by this version (v0.0%3d)\n", SkyState::_systemVars.gameVersion);
- return RESTORE_FAILED;
- }
- }
- LODSW(srcPos, _skySound->_saveSounds[0]);
- LODSW(srcPos, _skySound->_saveSounds[1]);
- _skySound->restoreSfx();
- } else {
- if(!getYesNo(loadText))
+ LODSD(srcPos, gameVersion);
+ if (gameVersion != SkyState::_systemVars.gameVersion) {
+ if ((!SkyState::isCDVersion()) || (gameVersion < 365)) { // cd versions are compatible
+ printf("This savegame was created by Beneath a Steel Sky v0.0%03d\n", gameVersion);
+ printf("It cannot be loaded by this version (v0.0%3d)\n", SkyState::_systemVars.gameVersion);
return RESTORE_FAILED;
+ }
}
+ LODSW(srcPos, _skySound->_saveSounds[0]);
+ LODSW(srcPos, _skySound->_saveSounds[1]);
+ _skySound->restoreSfx();
+
freeMemList(); // memory from last restore isn't needed anymore
LODSD(srcPos, music);
LODSD(srcPos, _savedCharSet);
@@ -1484,6 +1458,11 @@ uint16 SkyControl::parseSaveData(uint8 *srcBuf) {
for (cnt = 0; cnt < ARRAYSIZE(_saveLoadCpts); cnt++)
lodsCompact(&srcPos, _saveLoadCpts[cnt]);
+ for (cnt = 0; cnt < ARRAYSIZE(_saveLoadARs); cnt++)
+ for (uint8 elemCnt = 0; elemCnt < 32; elemCnt++) {
+ LODSW(srcPos, _saveLoadARs[cnt][elemCnt]);
+ }
+
for (cnt = 0; cnt < 3; cnt++)
LODSW(srcPos, SkyCompact::park_table[cnt]);
@@ -1630,8 +1609,8 @@ uint16 *SkyControl::lz77decode(uint16 *data) {
return outBuf;
}
-void SkyControl::applyDiff(uint16 *data, uint16 *diffData) {
- for (uint16 cnt = 0; cnt < 206; cnt++) {
+void SkyControl::applyDiff(uint16 *data, uint16 *diffData, uint16 len) {
+ for (uint16 cnt = 0; cnt < len; cnt++) {
data += READ_LE_UINT16(diffData);
diffData++;
*data = *diffData;
@@ -1644,24 +1623,23 @@ void SkyControl::restartGame(void) {
if (SkyState::_systemVars.gameVersion <= 267)
return; // no restart for floppy demo
- uint16 *resetData;
- if (SkyState::isCDVersion())
- resetData = lz77decode((uint16 *)_resetDataCd);
- else {
- resetData = lz77decode((uint16 *)_resetData288);
- switch (SkyState::_systemVars.gameVersion) {
- case 303:
- applyDiff(resetData, (uint16*)_resetDiff303);
- break;
- case 331:
- applyDiff(resetData, (uint16*)_resetDiff331);
- break;
- case 348:
- applyDiff(resetData, (uint16*)_resetDiff348);
- break;
- default:
- break;
- }
+ uint16 *resetData = lz77decode((uint16 *)_resetData288);
+ switch (SkyState::_systemVars.gameVersion) {
+ case 303:
+ applyDiff(resetData, (uint16*)_resetDiff303, 206);
+ break;
+ case 331:
+ applyDiff(resetData, (uint16*)_resetDiff331, 206);
+ break;
+ case 348:
+ applyDiff(resetData, (uint16*)_resetDiff348, 206);
+ break;
+ case 365:
+ case 368:
+ case 372:
+ applyDiff(resetData, (uint16*)_resetDiffCd, 214);
+ default:
+ break;
}
// ok, we finally have our savedata
diff --git a/sky/control.h b/sky/control.h
index 0d8696f0fd..1afd982f7c 100644
--- a/sky/control.h
+++ b/sky/control.h
@@ -112,7 +112,9 @@ class SkyMouse;
#define SAVE_GRAFX 32
#define SAVE_TURNP 64
-#define SAVE_FILE_REVISION 3
+#define SAVE_FILE_REVISION 5
+// skipping revision 4, that one will be used for messy downward compatibility in 0.5.0 branch
+#define OLD_SAVEGAME_TYPE 3
struct AllocedMem {
uint16 *mem;
@@ -210,7 +212,6 @@ private:
uint16 saveGameToFile(void);
void stosMegaSet(uint8 **destPos, MegaSet *mega);
void stosCompact(uint8 **destPos, Compact *cpt);
- void stosGrafStr(uint8 **destPos, Compact *cpt);
void stosStr(uint8 **destPos, Compact *cpt, uint16 type);
uint32 prepareSaveData(uint8 *destBuf);
@@ -223,13 +224,14 @@ private:
const char *_savePath;
uint16 *lz77decode(uint16 *data);
- void applyDiff(uint16 *data, uint16 *diffData);
+ void applyDiff(uint16 *data, uint16 *diffData, uint16 len);
static Compact *_saveLoadCpts[833]; //-----------------
- static uint8 _resetData288[0x39F2];
+ static uint16 *_saveLoadARs[19];
+ static uint8 _resetData288[0x39B8];
static uint8 _resetDiff303[824]; // moved to sky/compacts/savedata.cpp
static uint8 _resetDiff331[824];
static uint8 _resetDiff348[824];
- static uint8 _resetDataCd[0x3FDC]; //-----------------
+ static uint8 _resetDiffCd[856]; //-----------------
AllocedMem *_memListRoot;
void appendMemList(uint16 *pMem);
diff --git a/sky/logic.cpp b/sky/logic.cpp
index f9d8b30f3b..3083b2c8af 100644
--- a/sky/logic.cpp
+++ b/sky/logic.cpp
@@ -146,8 +146,12 @@ void SkyLogic::logicScript() {
void SkyLogic::autoRoute() {
_compact->downFlag = _skyAutoRoute->autoRoute(_compact);
- if (!_compact->downFlag) // route ok
- _compact->grafixProg = (uint16*)_compact->extCompact->animScratch;
+ if (!_compact->downFlag) { // route ok
+ _compact->grafixProg.pos = 0;
+ _compact->grafixProg.ptrTarget = 0;
+ _compact->grafixProg.ptrType = AUTOROUTE;
+ //_compact->grafixProg = (uint16*)_compact->extCompact->animScratch;
+ }
_compact->logic = L_SCRIPT; // continue the script
@@ -289,10 +293,12 @@ void SkyLogic::mainAnim() {
/// Extension of arAnim()
_compact->extCompact->waitingFor = 0; // clear possible zero-zero skip
- uint16 *sequence = _compact->grafixProg;
+ //uint16 *sequence = _compact->grafixProg;
+ uint16 *sequence = SkyCompact::getGrafixPtr(_compact);
if (!*sequence) {
// ok, move to new anim segment
sequence += 2;
+ _compact->grafixProg.pos += 2;
if (!*sequence) { // end of route?
// ok, sequence has finished
@@ -305,7 +311,6 @@ void SkyLogic::mainAnim() {
return;
}
- _compact->grafixProg = sequence;
_compact->extCompact->arAnimIndex = 0; // reset position
}
@@ -361,9 +366,11 @@ void SkyLogic::alt() {
void SkyLogic::anim() {
/// Follow an animation sequence
- uint16 *grafixProg = _compact->grafixProg;
+ //uint16 *grafixProg = _compact->grafixProg;
+ uint16 *grafixProg = SkyCompact::getGrafixPtr(_compact);
while (*grafixProg) {
+ _compact->grafixProg.pos += 3; // all types are 3 words.
if (*grafixProg == LF_START_FX) { // do fx
grafixProg++;
uint16 sound = *grafixProg++;
@@ -382,7 +389,6 @@ void SkyLogic::anim() {
_compact->ycood = *grafixProg++;
_compact->frame = *grafixProg++ | _compact->offset;
- _compact->grafixProg = grafixProg;
return;
}
}
@@ -486,9 +492,9 @@ void SkyLogic::talk() {
SkyState::fetchCompact(_compact->extCompact->spTextId)->status = 0;
}
- if (_compact->grafixProg) {
+ if (SkyCompact::getGrafixPtr(_compact)) {
_compact->frame = _compact->getToFlag; // set character to stand
- _compact->grafixProg = NULL;
+ _compact->grafixProg.ptrType = PTR_NULL;
}
_compact->logic = L_SCRIPT;
@@ -503,16 +509,17 @@ void SkyLogic::talk() {
_compact->logic = L_SCRIPT; // restart character control
- if (_compact->grafixProg) {
+ if (SkyCompact::getGrafixPtr(_compact)) {
_compact->frame = _compact->getToFlag; // set character to stand
- _compact->grafixProg = 0;
+ _compact->grafixProg.ptrType = PTR_NULL;
}
logicScript();
return;
}
- uint16 *graphixProg = _compact->grafixProg; // no anim file?
+ //uint16 *graphixProg = _compact->grafixProg; // no anim file?
+ uint16 *graphixProg = SkyCompact::getGrafixPtr(_compact);
if (graphixProg) {
if ((*graphixProg) && ((_compact->extCompact->spTime != 3) || (!_skySound->speechFinished()))) {
// we will force the animation to finish 3 game cycles
@@ -520,11 +527,11 @@ void SkyLogic::talk() {
_compact->frame = *(graphixProg + 2) + _compact->offset;
graphixProg += 3;
- _compact->grafixProg = graphixProg;
+ _compact->grafixProg.pos += 3;
} else {
// we ran out of frames or finished speech, let actor stand still.
_compact->frame = _compact->getToFlag;
- _compact->grafixProg = 0;
+ _compact->grafixProg.ptrType = PTR_NULL;
}
}
@@ -626,10 +633,11 @@ void SkyLogic::waitSync() {
void SkyLogic::simpleAnim() {
/// follow an animation sequence module whilst ignoring the coordinate data
- uint16 *grafixProg = _compact->grafixProg;
+ uint16 *grafixProg = SkyCompact::getGrafixPtr(_compact);
// *grafix_prog: command
while (*grafixProg) {
+ _compact->grafixProg.pos += 3;
if (*grafixProg != SEND_SYNC) {
grafixProg++;
grafixProg++; // skip coordinates
@@ -640,8 +648,6 @@ void SkyLogic::simpleAnim() {
else
_compact->frame = *grafixProg + _compact->offset;
- grafixProg++;
- _compact->grafixProg = grafixProg;
return;
}
@@ -1489,12 +1495,16 @@ bool SkyLogic::fnGetTo(uint32 targetPlaceId, uint32 mode, uint32 c) {
bool SkyLogic::fnSetToStand(uint32 a, uint32 b, uint32 c) {
_compact->mood = 1; // high level stood still
- uint16 *standList = *(uint16 **)SkyCompact::getCompactElem(_compact, C_STAND_UP
- + _compact->extCompact->megaSet + _compact->extCompact->dir * 4);
+ _compact->grafixProg.ptrType = COMPACTELEM;
+ _compact->grafixProg.pos = 0;
+ _compact->grafixProg.ptrTarget =
+ C_STAND_UP + _compact->extCompact->megaSet + _compact->extCompact->dir * 4;
- _compact->offset = *standList++; // get frames offset
- _compact->grafixProg = standList;
+ uint16 *standList = SkyCompact::getGrafixPtr(_compact);
+
+ _compact->offset = *standList; // get frames offset
_compact->logic = L_SIMPLE_MOD;
+ _compact->grafixProg.pos++;
simpleAnim();
return false; // drop out of script
}
@@ -1981,32 +1991,48 @@ bool SkyLogic::fnPause(uint32 cycles, uint32 b, uint32 c) {
}
bool SkyLogic::fnRunAnimMod(uint32 animNo, uint32 b, uint32 c) {
- uint16 *animation = (uint16 *)SkyState::fetchCompact(animNo);
- uint16 sprite = *animation++; // get sprite set
- _compact->offset = sprite;
- _compact->grafixProg = animation;
+ _compact->grafixProg.ptrType = COMPACT;
+ _compact->grafixProg.ptrTarget = animNo;
+ _compact->grafixProg.pos = 0;
+
+ //uint16 *animation = (uint16 *)SkyState::fetchCompact(animNo);
+ //uint16 sprite = *animation++; // get sprite set
+ //_compact->offset = sprite;
+ _compact->offset = *SkyCompact::getGrafixPtr(_compact);
+ //_compact->grafixProg = animation;
+ _compact->grafixProg.pos++;
_compact->logic = L_MOD_ANIMATE;
anim();
return false; // drop from script
}
bool SkyLogic::fnSimpleMod(uint32 animSeqNo, uint32 b, uint32 c) {
- uint16 *animSeq = (uint16 *)SkyState::fetchCompact(animSeqNo);
- _compact->offset = *animSeq++;
- assert(*animSeq != 0);
- _compact->grafixProg = animSeq;
+ _compact->grafixProg.ptrType = COMPACT;
+ _compact->grafixProg.ptrTarget = animSeqNo;
+ _compact->grafixProg.pos = 0;
+ //uint16 *animSeq = (uint16 *)SkyState::fetchCompact(animSeqNo);
+ //_compact->offset = *animSeq++;
+ //assert(*animSeq != 0);
+ _compact->offset = *SkyCompact::getGrafixPtr(_compact);
+ //_compact->grafixProg = animSeq;
+ _compact->grafixProg.pos++;
_compact->logic = L_SIMPLE_MOD;
simpleAnim();
return false;
}
bool SkyLogic::fnRunFrames(uint32 sequenceNo, uint32 b, uint32 c) {
- uint16 *sequence = (uint16 *)SkyState::fetchCompact(sequenceNo);
+ _compact->grafixProg.ptrType = COMPACT;
+ _compact->grafixProg.ptrTarget = sequenceNo;
+ _compact->grafixProg.pos = 0;
+ //uint16 *sequence = (uint16 *)SkyState::fetchCompact(sequenceNo);
_compact->logic = L_FRAMES;
- _compact->offset = *sequence++;
- _compact->grafixProg = sequence;
+ //_compact->offset = *sequence++;
+ _compact->offset = *SkyCompact::getGrafixPtr(_compact);
+ _compact->grafixProg.pos++;
+ //_compact->grafixProg = sequence;
simpleAnim();
return false;
}
@@ -2417,17 +2443,25 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
animNum += target->extCompact->megaSet / NEXT_MEGA_SET;
animNum &= 0xFF;
- if (SkyTalkAnims::animTalkTableIsPointer[animNum]) //is it a pointer?
- animPtr = (uint16 *)SkyTalkAnims::animTalkTablePtr[animNum];
- else //then it must be a value
- animPtr = (uint16 *)SkyState::fetchCompact(SkyTalkAnims::animTalkTableVal[animNum]);
+ if (SkyTalkAnims::animTalkTableIsPointer[animNum]) { //is it a pointer?
+ //animPtr = (uint16 *)SkyTalkAnims::animTalkTablePtr[animNum];
+ target->grafixProg.ptrType = TALKTABLE;
+ target->grafixProg.ptrTarget = animNum;
+ } else { //then it must be a value
+ //animPtr = (uint16 *)SkyState::fetchCompact(SkyTalkAnims::animTalkTableVal[animNum]);
+ target->grafixProg.ptrType = COMPACT;
+ target->grafixProg.ptrTarget = SkyTalkAnims::animTalkTableVal[animNum];
+ }
+ target->grafixProg.pos = 0;
+ animPtr = SkyCompact::getGrafixPtr(target);
if (animPtr) {
target->offset = *animPtr++;
target->getToFlag = *animPtr++;
- target->grafixProg = animPtr;
- } else
- target->grafixProg = 0;
+ target->grafixProg.pos += 2;
+ } else {
+ target->grafixProg.ptrType = PTR_NULL;
+ }
bool speechUsed = false;
// startSpeech returns false if no speech file exists for that text
@@ -2477,13 +2511,11 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32
yPos = TOP_LEFT_Y;
textCompact->ycood = yPos;
- //_logicTalkButtonRelease = 1;
} else {
//talking off-screen
target->extCompact->spTextId = 0; //don't kill any text 'cos none was made
textCompact->status = 0; //don't display text
- //_logicTalkButtonRelease = 1;
}
// In CD version, we're doing the timing by checking when the VOC has stopped playing.
// Setting spTime to 10 thus means that we're doing a pause of 10 gamecycles between
diff --git a/sky/mouse.h b/sky/mouse.h
index c333c9ec76..0f86e166ab 100644
--- a/sky/mouse.h
+++ b/sky/mouse.h
@@ -53,7 +53,7 @@ public:
uint16 giveMouseX(void) { return _mouseX; };
uint16 giveMouseY(void) { return _mouseY; };
uint16 giveCurrentMouseType(void) { return _currentCursor; };
- bool wasClicked(void) { return _logicClick; };
+ bool wasClicked(void) { return _logicClick; _logicClick = false; };
void logicClick(void) { _logicClick = true; };
protected:
diff --git a/sky/skydefs.h b/sky/skydefs.h
index 33d58de5e2..369ce317f8 100644
--- a/sky/skydefs.h
+++ b/sky/skydefs.h
@@ -26,6 +26,14 @@
//This file is incomplete, several flags still missing.
+// grafixProg pointer types:
+#define PTR_NULL 0
+#define AUTOROUTE 1
+#define COMPACT 2
+#define COMPACTELEM 3 // needed by fnSetToStand
+#define TALKTABLE 4
+
+// language codes:
#define SKY_ENGLISH 0
#define SKY_GERMAN 1
#define SKY_FRENCH 2
diff --git a/sky/struc.h b/sky/struc.h
index 85ae3b685a..c348bf5562 100644
--- a/sky/struc.h
+++ b/sky/struc.h
@@ -48,6 +48,12 @@ struct dataFileHeader {
uint16 s_compressed_size;
};
+struct GrafixPtr { // replacement for old grafixProg pointer. More savegame compatible.
+ uint8 ptrType; // ptr to autoroute / to compact / to turntable
+ uint16 ptrTarget; // compact / turntable number
+ uint16 pos; // position
+};
+
struct TurnTable {
uint16 *turnTableUp[5];
uint16 *turnTableDown[5];
@@ -106,7 +112,7 @@ struct ExtCompact {
uint16 arTargetX;
uint16 arTargetY;
- void *animScratch; // data area for AR
+ uint16 *animScratch; // data area for AR
uint16 megaSet;
MegaSet *megaSet0;
@@ -147,7 +153,7 @@ struct Compact {
uint16 flag; // a use any time flag
uint16 mood; // high level - stood or not
- uint16 *grafixProg;
+ GrafixPtr grafixProg;
uint16 offset;
uint16 mode; // which mcode block