DREAMWEB: Convert watchreel and remove global kReelpointer

This commit is contained in:
Willem Jan Palenstijn 2011-12-08 10:22:45 +01:00
parent 7e4a261609
commit e8ccbe3558
8 changed files with 91 additions and 122 deletions

View file

@ -202,6 +202,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'checkcoords', 'checkcoords',
'checkdest', 'checkdest',
'checkforemm', 'checkforemm',
'checkforshake',
'checkifex', 'checkifex',
'checkiffree', 'checkiffree',
'checkifpathison', 'checkifpathison',
@ -710,6 +711,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'walkintoroom', 'walkintoroom',
'walktotext', 'walktotext',
'watchcount', 'watchcount',
'watchreel',
'wearwatch', 'wearwatch',
'wearshades', 'wearshades',
'wheelsound', 'wheelsound',

View file

@ -74,10 +74,16 @@ public:
void cancelCh0(); void cancelCh0();
void cancelCh1(); void cancelCh1();
void loadRoomsSample(); void loadRoomsSample();
void playChannel0(uint8 index, uint8 repeat);
void playChannel1(uint8 index);
// from sprite.cpp // from sprite.cpp
Sprite *spriteTable(); Sprite *spriteTable();
Reel *getReelStart(); Reel *getReelStart(uint16 reelPointer);
const Frame *findSource(uint16 &frame);
void showReelFrame(Reel *reel);
const Frame *getReelFrameAX(uint16 frame);
void soundOnReels(uint16 reelPointer);
// from stubs.cpp // from stubs.cpp
void crosshair(); void crosshair();

View file

@ -6758,99 +6758,6 @@ void DreamGenContext::clearChanges() {
_stosw(cx, true); _stosw(cx, true);
} }
void DreamGenContext::watchReel() {
STACK_CHECK;
_cmp(data.word(kReeltowatch), -1);
if (flags.z())
goto notplayingreel;
al = data.byte(kManspath);
_cmp(al, data.byte(kFinaldest));
if (!flags.z())
return /* (waitstopwalk) */;
al = data.byte(kTurntoface);
_cmp(al, data.byte(kFacing));
if (flags.z())
goto notwatchpath;
return;
notwatchpath:
_dec(data.byte(kSpeedcount));
_cmp(data.byte(kSpeedcount), -1);
if (!flags.z())
goto showwatchreel;
al = data.byte(kWatchspeed);
data.byte(kSpeedcount) = al;
ax = data.word(kReeltowatch);
_cmp(ax, data.word(kEndwatchreel));
if (!flags.z())
goto ismorereel;
_cmp(data.word(kWatchingtime), 0);
if (!flags.z())
goto showwatchreel;
data.word(kReeltowatch) = -1;
data.byte(kWatchmode) = -1;
_cmp(data.word(kReeltohold), -1);
if (flags.z())
return /* (nomorereel) */;
data.byte(kWatchmode) = 1;
goto notplayingreel;
ismorereel:
_inc(data.word(kReeltowatch));
showwatchreel:
ax = data.word(kReeltowatch);
data.word(kReelpointer) = ax;
plotReel();
ax = data.word(kReelpointer);
data.word(kReeltowatch) = ax;
checkForShake();
return;
notplayingreel:
_cmp(data.byte(kWatchmode), 1);
if (!flags.z())
goto notholdingreel;
ax = data.word(kReeltohold);
data.word(kReelpointer) = ax;
plotReel();
return;
notholdingreel:
_cmp(data.byte(kWatchmode), 2);
if (!flags.z())
return /* (notreleasehold) */;
_dec(data.byte(kSpeedcount));
_cmp(data.byte(kSpeedcount), -1);
if (!flags.z())
goto notlastspeed2;
al = data.byte(kWatchspeed);
data.byte(kSpeedcount) = al;
_inc(data.word(kReeltohold));
notlastspeed2:
ax = data.word(kReeltohold);
_cmp(ax, data.word(kEndofholdreel));
if (!flags.z())
goto ismorereel2;
data.word(kReeltohold) = -1;
data.byte(kWatchmode) = -1;
al = data.byte(kDestafterhold);
data.byte(kDestination) = al;
data.byte(kFinaldest) = al;
autoSetWalk();
return;
ismorereel2:
ax = data.word(kReeltohold);
data.word(kReelpointer) = ax;
plotReel();
}
void DreamGenContext::checkForShake() {
STACK_CHECK;
_cmp(data.byte(kReallocation), 26);
if (!flags.z())
return /* (notstartshake) */;
_cmp(ax, 104);
if (!flags.z())
return /* (notstartshake) */;
data.byte(kShakecounter) = -1;
}
void DreamGenContext::madmanRun() { void DreamGenContext::madmanRun() {
STACK_CHECK; STACK_CHECK;
_cmp(data.byte(kLocation), 14); _cmp(data.byte(kLocation), 14);

View file

@ -554,10 +554,9 @@ public:
void checkInput(); void checkInput();
void putUnderCentre(); void putUnderCentre();
void checkObjectSize(); void checkObjectSize();
void watchReel();
void findText1(); void findText1();
void isRyanHolding(); void isRyanHolding();
void showSlots(); void quitSymbol();
void useCashCard(); void useCashCard();
void moneyPoke(); void moneyPoke();
void doSomeTalk(); void doSomeTalk();
@ -643,7 +642,7 @@ public:
void lookAtPlace(); void lookAtPlace();
void useAxe(); void useAxe();
void findAllOpen(); void findAllOpen();
void quitSymbol(); void showSlots();
void findSetObject(); void findSetObject();
void useDiary(); void useDiary();
void deleteExObject(); void deleteExObject();
@ -693,7 +692,6 @@ public:
void afterNewRoom(); void afterNewRoom();
void getExAd(); void getExAd();
void initialMonCols(); void initialMonCols();
void checkForShake();
void useButtonA(); void useButtonA();
void execCommand(); void execCommand();
void updateSymbolBot(); void updateSymbolBot();

View file

@ -53,7 +53,7 @@ void DreamBase::volumeAdjust() {
} }
} }
void DreamGenContext::playChannel0(uint8 index, uint8 repeat) { void DreamBase::playChannel0(uint8 index, uint8 repeat) {
if (data.byte(kSoundint) == 255) if (data.byte(kSoundint) == 255)
return; return;
@ -80,7 +80,7 @@ void DreamGenContext::playChannel0() {
playChannel0(al, ah); playChannel0(al, ah);
} }
void DreamGenContext::playChannel1(uint8 index) { void DreamBase::playChannel1(uint8 index) {
if (data.byte(kSoundint) == 255) if (data.byte(kSoundint) == 255)
return; return;
if (data.byte(kCh1playing) == 7) if (data.byte(kCh1playing) == 7)

View file

@ -482,8 +482,8 @@ Frame *DreamGenContext::findSource() {
} }
} }
Reel *DreamBase::getReelStart() { Reel *DreamBase::getReelStart(uint16 reelPointer) {
Reel *reel = (Reel *)getSegment(data.word(kReels)).ptr(kReellist + data.word(kReelpointer) * sizeof(Reel) * 8, sizeof(Reel)); Reel *reel = (Reel *)getSegment(data.word(kReels)).ptr(kReellist + reelPointer * sizeof(Reel) * 8, sizeof(Reel));
return reel; return reel;
} }
@ -504,9 +504,8 @@ void DreamGenContext::showGameReel(ReelRoutine *routine) {
uint16 reelPointer = routine->reelPointer(); uint16 reelPointer = routine->reelPointer();
if (reelPointer >= 512) if (reelPointer >= 512)
return; return;
data.word(kReelpointer) = reelPointer; plotReel(reelPointer);
plotReel(); routine->setReelPointer(reelPointer);
routine->setReelPointer(data.word(kReelpointer));
} }
const Frame *DreamGenContext::getReelFrameAX(uint16 frame) { const Frame *DreamGenContext::getReelFrameAX(uint16 frame) {
@ -1133,14 +1132,14 @@ static const ReelSound *g_roomByRoom[] = {
}; };
void DreamGenContext::soundOnReels() { void DreamBase::soundOnReels(uint16 reelPointer) {
const ReelSound *r = g_roomByRoom[data.byte(kReallocation)]; const ReelSound *r = g_roomByRoom[data.byte(kReallocation)];
if (engine->getLanguage() == Common::DE_DEU && r == g_roomSound29) if (engine->getLanguage() == Common::DE_DEU && r == g_roomSound29)
r = g_roomSound29_German; r = g_roomSound29_German;
for (; r->_sample != 255; ++r) { for (; r->_sample != 255; ++r) {
if (r->_reelPointer != data.word(kReelpointer)) if (r->_reelPointer != reelPointer)
continue; continue;
if (r->_reelPointer == data.word(kLastsoundreel)) if (r->_reelPointer == data.word(kLastsoundreel))
continue; continue;
@ -1156,7 +1155,7 @@ void DreamGenContext::soundOnReels() {
playChannel0(r->_sample & 63, 255); playChannel0(r->_sample & 63, 255);
} }
if (data.word(kReelpointer) != data.word(kLastsoundreel)) if (data.word(kLastsoundreel) != reelPointer)
data.word(kLastsoundreel) = (uint16)-1; data.word(kLastsoundreel) = (uint16)-1;
} }

View file

@ -1196,11 +1196,11 @@ void DreamGenContext::dealWithSpecial(uint8 firstParam, uint8 secondParam) {
} }
} }
void DreamGenContext::plotReel() { void DreamGenContext::plotReel(uint16 &reelPointer) {
Reel *reel = getReelStart(); Reel *reel = getReelStart(reelPointer);
while (reel->x >= 220 && reel->x != 255) { while (reel->x >= 220 && reel->x != 255) {
dealWithSpecial(reel->x, reel->y); dealWithSpecial(reel->x, reel->y);
++data.word(kReelpointer); ++reelPointer;
reel += 8; reel += 8;
} }
@ -1209,11 +1209,7 @@ void DreamGenContext::plotReel() {
showReelFrame(reel); showReelFrame(reel);
++reel; ++reel;
} }
push(es); soundOnReels(reelPointer);
push(bx);
soundOnReels();
bx = pop();
es = pop();
} }
void DreamBase::crosshair() { void DreamBase::crosshair() {
@ -1258,8 +1254,7 @@ bool DreamGenContext::checkIfPerson(uint8 x, uint8 y) {
for (size_t i = 0; i < 12; ++i, ++people) { for (size_t i = 0; i < 12; ++i, ++people) {
if (people->b4 == 255) if (people->b4 == 255)
continue; continue;
data.word(kReelpointer) = people->reelPointer(); Reel *reel = getReelStart(people->reelPointer());
Reel *reel = getReelStart();
if (reel->frame() == 0xffff) if (reel->frame() == 0xffff)
++reel; ++reel;
const Frame *frame = getReelFrameAX(reel->frame()); const Frame *frame = getReelFrameAX(reel->frame());
@ -3815,4 +3810,61 @@ void DreamBase::showDiary() {
showFrame(tempGraphics(), kDiaryx + 176, kDiaryy + 108, 2, 0); showFrame(tempGraphics(), kDiaryx + 176, kDiaryy + 108, 2, 0);
} }
void DreamGenContext::showWatchReel() {
uint16 reelPointer = data.word(kReeltowatch);
plotReel(reelPointer);
data.word(kReeltowatch) = reelPointer;
// check for shake
if (data.byte(kReallocation) == 26 && reelPointer == 104)
data.byte(kShakecounter) = 0xFF;
}
void DreamGenContext::watchReel() {
if (data.word(kReeltowatch) != 0xFFFF) {
if (data.byte(kManspath) != data.byte(kFinaldest))
return; // Wait until stopped walking
if (data.byte(kTurntoface) != data.byte(kFacing))
return;
if (--data.byte(kSpeedcount) != 0xFF) {
showWatchReel();
return;
}
data.byte(kSpeedcount) = data.byte(kWatchspeed);
if (data.word(kReeltowatch) != data.word(kEndwatchreel)) {
++data.word(kReeltowatch);
showWatchReel();
return;
}
if (data.word(kWatchingtime)) {
showWatchReel();
return;
}
data.word(kReeltowatch) = 0xFFFF;
data.byte(kWatchmode) = 0xFF;
if (data.word(kReeltohold) == 0xFFFF)
return; // No more reel
data.byte(kWatchmode) = 1;
} else if (data.byte(kWatchmode) != 1) {
if (data.byte(kWatchmode) != 2)
return; // "notreleasehold"
if (--data.byte(kSpeedcount) == 0xFF) {
data.byte(kSpeedcount) = data.byte(kWatchspeed);
++data.word(kReeltohold);
}
if (data.word(kReeltohold) == data.word(kEndofholdreel)) {
data.word(kReeltohold) = -1;
data.byte(kWatchmode) = -1;
data.byte(kDestination) = data.byte(kDestafterhold);
data.byte(kFinaldest) = data.byte(kDestafterhold);
autoSetWalk();
return;
}
}
uint16 reelPointer = data.word(kReeltohold);
plotReel(reelPointer);
}
} // End of namespace DreamGen } // End of namespace DreamGen

View file

@ -130,7 +130,6 @@
void turnAnyPathOff(); void turnAnyPathOff();
void makeBackOb(SetObject *objData); void makeBackOb(SetObject *objData);
void lockMon(); void lockMon();
void plotReel();
void dealWithSpecial(uint8 firstParam, uint8 secondParam); void dealWithSpecial(uint8 firstParam, uint8 secondParam);
void zoom(); void zoom();
void showRain(); void showRain();
@ -297,9 +296,13 @@
void powerLightOn(); void powerLightOn();
void powerLightOff(); void powerLightOff();
void playChannel0(); void playChannel0();
void playChannel0(uint8 index, uint8 repeat); void playChannel0(uint8 index, uint8 repeat) {
DreamBase::playChannel0(index, repeat);
}
void playChannel1(); void playChannel1();
void playChannel1(uint8 index); void playChannel1(uint8 index) {
DreamBase::playChannel1(index);
}
void showMainOps(); void showMainOps();
void showDiscOps(); void showDiscOps();
void findRoomInLoc(); void findRoomInLoc();
@ -471,7 +474,6 @@
void loadPersonal(); void loadPersonal();
void loadNews(); void loadNews();
void loadCart(); void loadCart();
void soundOnReels();
void readKey(); void readKey();
void hangOne(uint16 delay); void hangOne(uint16 delay);
void hangOne(); void hangOne();
@ -556,5 +558,8 @@
void examineInventory(); void examineInventory();
void showSaveOps(); void showSaveOps();
void showLoadOps(); void showLoadOps();
void watchReel();
void showWatchReel();
void plotReel(uint16 &reelPointer);
#endif #endif