Merge pull request #153 from fingolfin/dreamweb-cleanup

Dreamweb: Port rollEm() to C++, remove dead code
This commit is contained in:
Filippos Karapetis 2011-12-25 16:58:58 -08:00
commit 9a89f8884c
19 changed files with 120 additions and 236 deletions

View File

@ -749,6 +749,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'restoreems',
'restorereels',
'rockstar',
'rollem',
'rollendcredits',
'rollendcredits2',
'roomname',

View File

@ -564,6 +564,19 @@ public:
bool hangOnPQ();
void redes();
// from titles.cpp
void endGame();
void monkSpeaking();
void gettingShot();
void bibleQuote();
void hangOne(uint16 delay);
void intro();
void runIntroSeq();
void runEndSeq();
void loadIntroRoom();
void set16ColPalette();
void realCredits();
// from use.cpp
void placeFreeObject(uint8 index);
void removeFreeObject(uint8 index);
@ -653,6 +666,8 @@ public:
void useTrainer();
void useStereo();
void chewy();
void delEverything();
void afterIntroRoom();
// from vgafades.cpp
void clearStartPal();
@ -693,7 +708,7 @@ public:
void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height);
void multiPut(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height);
void multiDump(uint16 x, uint16 y, uint8 width, uint8 height);
void workToScreenCPP();
void workToScreen();
void printUnderMon();
void cls();
void frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y);
@ -711,6 +726,8 @@ public:
void createPanel();
void createPanel2();
void showPanel();
void rollEndCredits2();
void rollEm();
};

View File

@ -73,100 +73,6 @@ void DreamGenContext::transferMap() {
_add(data.word(kExframepos), cx);
}
void DreamGenContext::rollEm() {
STACK_CHECK;
cl = 160;
ch = 160;
di = 25;
bx = 20;
ds = data.word(kMapstore);
si = 0;
multiGet();
es = data.word(kTextfile1);
si = 49*2;
ax = es.word(si);
si = ax;
_add(si, (66*2));
cx = 80;
endcredits21:
push(cx);
bx = 10;
cx = data.word(kLinespacing);
endcredits22:
push(cx);
push(si);
push(di);
push(es);
push(bx);
vSync();
cl = 160;
ch = 160;
di = 25;
bx = 20;
ds = data.word(kMapstore);
si = 0;
multiPut();
vSync();
bx = pop();
es = pop();
di = pop();
si = pop();
push(si);
push(di);
push(es);
push(bx);
cx = 18;
onelot2:
push(cx);
di = 25;
dx = 161;
ax = 0;
printDirect();
_add(bx, data.word(kLinespacing));
cx = pop();
if (--cx)
goto onelot2;
vSync();
cl = 160;
ch = 160;
di = 25;
bx = 20;
multiDump();
bx = pop();
es = pop();
di = pop();
si = pop();
cx = pop();
_cmp(data.byte(kLasthardkey), 1);
if (flags.z())
goto endearly2;
_dec(bx);
if (--cx)
goto endcredits22;
cx = pop();
looknext2:
al = es.byte(si);
_inc(si);
_cmp(al, ':');
if (flags.z())
goto gotnext2;
_cmp(al, 0);
if (flags.z())
goto gotnext2;
goto looknext2;
gotnext2:
_cmp(data.byte(kLasthardkey), 1);
if (flags.z())
return /* (endearly) */;
if (--cx)
goto endcredits21;
cx = 120;
hangOne();
return;
endearly2:
cx = pop();
}
void DreamGenContext::fillOpen() {
STACK_CHECK;
delTextLine();

View File

@ -460,7 +460,6 @@ public:
void pickupConts();
void transferMap();
void getSetAd();
void rollEm();
void findAllOpen();
void fillOpen();
void dreamweb();

View File

@ -118,7 +118,7 @@ void DreamBase::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3
showKeypad();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
data.word(kPresspointer) = 0;
data.byte(kGetback) = 0;

View File

@ -61,7 +61,7 @@ void DreamGenContext::useMon() {
printOuterMon();
initialMonCols();
printLogo();
workToScreenCPP();
workToScreen();
turnOnPower();
fadeUpYellows();
fadeUpMonFirst();
@ -174,7 +174,7 @@ void DreamBase::monitorLogo() {
//fadeDownMon(); // FIXME: Commented out in ASM
printLogo();
printUnderMon();
workToScreenCPP();
workToScreen();
printLogo();
//fadeUpMon(); // FIXME: Commented out in ASM
printLogo();
@ -291,7 +291,7 @@ void DreamBase::delCurs() {
void DreamBase::scrollMonitor() {
printLogo();
printUnderMon();
workToScreenCPP();
workToScreen();
playChannel1(25);
}

View File

@ -54,7 +54,7 @@ void DreamBase::selectLocation() {
readMouse();
data.byte(kPointerframe) = 0;
showPointer();
workToScreenCPP();
workToScreen();
playChannel0(9, 255);
data.byte(kNewlocation) = 255;
@ -189,7 +189,7 @@ void DreamBase::nextDest() {
underTextLine();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -218,7 +218,7 @@ void DreamBase::lastDest() {
underTextLine();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}

View File

@ -58,10 +58,6 @@ void DreamBase::fillRyan() {
showRyanPage();
}
void DreamGenContext::isItWorn() {
flags._z = isItWorn((const DynObject *)es.ptr(bx, sizeof(DynObject)));
}
bool DreamBase::isItWorn(const DynObject *object) {
return (object->id[0] == 'W'-'A') && (object->id[1] == 'E'-'A');
}
@ -151,7 +147,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
data.byte(kCommandtype) = 255;
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
examineAgain = false;
}
@ -255,7 +251,7 @@ void DreamGenContext::inventory() {
openInv();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
data.byte(kOpenedob) = 255;
examineOb(false);
@ -754,10 +750,6 @@ void DreamBase::dropObject() {
object->currentLocation = data.byte(kReallocation);
}
void DreamGenContext::checkObjectSize() {
al = checkObjectSizeCPP() ? 0 : 1;
}
bool DreamGenContext::checkObjectSizeCPP() {
byte containerSize = getOpenedSlotSize();
DynObject *object = getEitherAdCPP();
@ -816,7 +808,7 @@ void DreamGenContext::selectOpenOb() {
underTextLine();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -867,7 +859,7 @@ void DreamGenContext::swapWithInv() {
fillRyan();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -934,7 +926,7 @@ void DreamGenContext::useOpened() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -992,7 +984,7 @@ void DreamGenContext::outOfOpen() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -1062,7 +1054,7 @@ void DreamGenContext::swapWithOpen() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}

View File

@ -921,7 +921,7 @@ void DreamBase::mugger(ReelRoutine &routine) {
const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
uint16 y = 104;
printDirect(&string, 33 + 20, &y, 241, 241 & 1);
workToScreenCPP();
workToScreen();
hangOn(300);
routine.setReelPointer(140);
data.byte(kManspath) = 2;

View File

@ -133,7 +133,7 @@ void DreamBase::doLoad(int savegameId) {
data.word(kTextaddressy) = 182;
data.byte(kTextlen) = 240;
startup();
workToScreenCPP();
workToScreen();
data.byte(kGetback) = 4;
}
@ -220,7 +220,7 @@ void DreamBase::saveGame() {
data.word(kTextaddressy) = 182;
data.byte(kTextlen) = 240;
redrawMainScrn();
workToScreenCPP(); // show the main screen without the mouse pointer
workToScreen(); // show the main screen without the mouse pointer
// We need to save after the scene has been redrawn, to capture the
// correct screen thumbnail
@ -265,7 +265,7 @@ void DreamBase::doSaveLoad() {
loadSaveBox();
showOpBox();
showMainOps();
workToScreenCPP();
workToScreen();
RectWithCallback<DreamGenContext> opsList[] = {
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamBase::getBackFromOps },
@ -745,7 +745,7 @@ void DreamBase::selectSlot() {
showSaveOps();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}

View File

@ -30,10 +30,6 @@
namespace DreamGen {
void DreamGenContext::loadSpeech() {
loadSpeech((uint8)dl, (uint8)dh, (uint8)cl, (uint16)ax);
}
bool DreamBase::loadSpeech(byte type1, int idx1, byte type2, int idx2) {
cancelCh1();
@ -87,10 +83,6 @@ void DreamBase::playChannel1(uint8 index) {
data.word(kCh1blockstocopy) = soundBank[index].blockCount();
}
void DreamGenContext::playChannel1() {
playChannel1(al);
}
void DreamBase::cancelCh0() {
data.byte(kCh0repeat) = 0;
data.word(kCh0blockstocopy) = 0;

View File

@ -706,6 +706,8 @@ void DreamBase::intro3Text(uint16 nextReelPointer) {
}
void DreamBase::rollEndCredits() {
// Note: This function is very similar to rollEm() in vgafades.cpp
playChannel0(16, 255);
data.byte(kVolume) = 7;
data.byte(kVolumeto) = 0;

View File

@ -508,7 +508,7 @@ void DreamGenContext::dreamweb() {
clearPalette();
doLoad(savegameId);
workToScreenCPP();
workToScreen();
fadeScreenUp();
startNewGame = false;
@ -728,7 +728,7 @@ void DreamGenContext::startup1() {
startup();
workToScreenCPP();
workToScreen();
fadeScreenUp();
}
@ -849,10 +849,10 @@ void DreamGenContext::triggerMessage(uint16 index) {
uint16 y = 156;
printDirect(&string, 174, &y, 141, true);
hangOn(140);
workToScreenCPP();
workToScreen();
hangOn(340);
multiPut(mapStore(), 174, 153, 200, 63);
workToScreenCPP();
workToScreen();
data.byte(kLasttrigger) = 0;
}
@ -1235,10 +1235,6 @@ void DreamBase::copyName(uint8 type, uint8 index, uint8 *dst) {
dst[i] = 0;
}
void DreamGenContext::commandWithOb() {
commandWithOb(al, bh, bl);
}
void DreamBase::commandWithOb(uint8 command, uint8 type, uint8 index) {
uint8 commandLine[64] = "OBJECT NAME ONE ";
delTextLine();
@ -1752,10 +1748,6 @@ bool DreamGenContext::checkIfSet(uint8 x, uint8 y) {
return false;
}
void DreamGenContext::hangOn() {
hangOn(cx);
}
void DreamBase::hangOn(uint16 frameCount) {
while (frameCount) {
vSync();
@ -2498,7 +2490,7 @@ void DreamBase::workToScreenM() {
readMouse();
showPointer();
vSync();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -2765,7 +2757,7 @@ void DreamGenContext::walkIntoRoom() {
}
}
void DreamGenContext::afterIntroRoom() {
void DreamBase::afterIntroRoom() {
if (data.byte(kNowinnewroom) == 0)
return; // notnewintro
@ -2776,7 +2768,7 @@ void DreamGenContext::afterIntroRoom() {
reelsOnScreen();
spriteUpdate();
printSprites();
workToScreenCPP();
workToScreen();
data.byte(kNowinnewroom) = 0;
}
@ -2869,7 +2861,7 @@ void DreamBase::describeOb() {
}
}
void DreamGenContext::delEverything() {
void DreamBase::delEverything() {
if (data.byte(kMapysize) + data.word(kMapoffsety) < 182) {
mapToPanel();
} else {
@ -2885,7 +2877,7 @@ void DreamGenContext::errorMessage1() {
printMessage(76, 21, 58, 240, (240 & 1));
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
hangOnP(50);
showPanel();
@ -2894,7 +2886,7 @@ void DreamGenContext::errorMessage1() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -2904,7 +2896,7 @@ void DreamGenContext::errorMessage2() {
printMessage(76, 21, 59, 240, (240 & 1));
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
hangOnP(50);
showPanel();
@ -2913,7 +2905,7 @@ void DreamGenContext::errorMessage2() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -2928,7 +2920,7 @@ void DreamGenContext::errorMessage3() {
readMouse();
useOpened();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -2948,7 +2940,7 @@ void DreamBase::putBackObStuff() {
data.byte(kCommandtype) = 255;
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}
@ -3133,7 +3125,7 @@ void DreamGenContext::decide() {
data.byte(kManisoffscreen) = 1;
loadSaveBox();
showDecisions();
workToScreenCPP();
workToScreen();
fadeScreenUp();
data.byte(kGetback) = 0;
@ -3192,7 +3184,7 @@ void DreamGenContext::showGun() {
createPanel2();
showFrame(tempGraphics(), 100, 4, 0, 0);
showFrame(tempGraphics(), 158, 106, 1, 0);
workToScreenCPP();
workToScreen();
getRidOfTemp();
fadeScreenUp();
hangOn(160);
@ -3696,7 +3688,7 @@ void DreamBase::incRyanPage() {
fillRyan();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}

View File

@ -24,7 +24,6 @@
void screenUpdate();
void startup1();
void workToScreen();
void multiGet();
void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height) {
DreamBase::multiGet(dst, x, y, width, height);
@ -48,21 +47,10 @@
uint8 printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered) {
return DreamBase::printDirect(string, x, y, maxWidth, centered);
}
void showFrame();
void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
DreamBase::showFrame(frameData, x, y, frameNumber, effectsFlag, width, height);
}
void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
DreamBase::showFrame(frameData, x, y, frameNumber, effectsFlag);
}
void width160();
bool checkIfPerson(uint8 x, uint8 y);
bool checkIfFree(uint8 x, uint8 y);
bool checkIfEx(uint8 x, uint8 y);
void commandWithOb();
void commandWithOb(uint8 command, uint8 type, uint8 index) {
DreamBase::commandWithOb(command, type, index);
}
DynObject *getFreeAd(uint8 index) {
return DreamBase::getFreeAd(index);
}
@ -80,19 +68,11 @@
void getExPos();
bool checkIfSet(uint8 x, uint8 y);
void isItWorn();
bool isItWorn(const DynObject *object) {
return DreamBase::isItWorn(object);
}
void obToInv();
void obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
DreamBase::obToInv(index, flag, x, y);
}
void useRoutine();
void hangOn();
void hangOn(uint16 frameCount) {
DreamBase::hangOn(frameCount);
}
void examineOb(bool examineAgain = true);
void dumpWatch();
void transferText();
@ -115,10 +95,6 @@
void monMessage(uint8 index) {
DreamBase::monMessage(index);
}
void playChannel1();
void playChannel1(uint8 index) {
DreamBase::playChannel1(index);
}
void look();
void autoLook();
void doLook();
@ -131,45 +107,25 @@
void inventory();
void mainScreen();
void zoomOnOff();
void hangOne(uint16 delay);
void hangOne();
void bibleQuote();
void realCredits();
void runIntroSeq();
void intro();
void pickupOb(uint8 command, uint8 pos);
void initialInv();
void walkIntoRoom();
void loadIntroRoom();
void afterIntroRoom();
void gettingShot();
void allPointer();
void delEverything();
void errorMessage1();
void errorMessage2();
void errorMessage3();
void loadSpeech();
bool loadSpeech(byte type1, int idx1, byte type2, int idx2) {
return DreamBase::loadSpeech(type1, idx1, type2, idx2);
}
void set16ColPalette();
void afterNewRoom();
void madmanRun();
void decide();
void showGun();
void endGame();
void monkSpeaking();
void rollEndCredits2();
void triggerMessage(uint16 index);
void processTrigger();
void updateSymbolTop();
void updateSymbolBot();
void runEndSeq();
bool execCommand();
void getOpenedSize();
byte getOpenedSlotSize();
byte getOpenedSlotCount();
void checkObjectSize();
bool checkObjectSizeCPP();
void openOb();
void identifyOb();

View File

@ -38,7 +38,7 @@ void DreamBase::talk() {
data.byte(kCommandtype) = 255;
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
RectWithCallback<DreamGenContext> talkList[] = {
{ 273,320,157,198,&DreamBase::getBack1 },
@ -259,7 +259,7 @@ void DreamBase::redes() {
startTalk();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
}

View File

@ -25,7 +25,7 @@
namespace DreamGen {
void DreamGenContext::endGame() {
void DreamBase::endGame() {
loadTempText("DREAMWEB.T83");
monkSpeaking();
gettingShot();
@ -35,7 +35,7 @@ void DreamGenContext::endGame() {
hangOn(200);
}
void DreamGenContext::monkSpeaking() {
void DreamBase::monkSpeaking() {
// FIXME: This is the CD version only.
data.byte(kRoomssample) = 35;
@ -68,7 +68,7 @@ void DreamGenContext::monkSpeaking() {
getRidOfTemp();
}
void DreamGenContext::gettingShot() {
void DreamBase::gettingShot() {
data.byte(kNewlocation) = 55;
clearPalette();
loadIntroRoom();
@ -79,7 +79,7 @@ void DreamGenContext::gettingShot() {
clearBeforeLoad();
}
void DreamGenContext::bibleQuote() {
void DreamBase::bibleQuote() {
initGraphics(640, 480, true);
showPCX("DREAMWEB.I00");
@ -110,7 +110,7 @@ void DreamGenContext::bibleQuote() {
data.byte(kLasthardkey) = 0;
}
void DreamGenContext::hangOne(uint16 delay) {
void DreamBase::hangOne(uint16 delay) {
do {
vSync();
if (data.byte(kLasthardkey) == 1)
@ -118,11 +118,7 @@ void DreamGenContext::hangOne(uint16 delay) {
} while (--delay);
}
void DreamGenContext::hangOne() {
hangOne(cx);
}
void DreamGenContext::intro() {
void DreamBase::intro() {
loadTempText("DREAMWEB.T82");
loadPalFromIFF();
setMode();
@ -178,7 +174,7 @@ void DreamGenContext::intro() {
data.byte(kLasthardkey) = 0;
}
void DreamGenContext::runIntroSeq() {
void DreamBase::runIntroSeq() {
data.byte(kGetback) = 0;
do {
@ -224,7 +220,7 @@ void DreamGenContext::runIntroSeq() {
//clearBeforeLoad();
}
void DreamGenContext::runEndSeq() {
void DreamBase::runEndSeq() {
atmospheres();
data.byte(kGetback) = 0;
@ -244,7 +240,7 @@ void DreamGenContext::runEndSeq() {
} while (data.byte(kGetback) != 1);
}
void DreamGenContext::loadIntroRoom() {
void DreamBase::loadIntroRoom() {
data.byte(kIntrocount) = 0;
data.byte(kLocation) = 255;
loadRoom();
@ -260,13 +256,13 @@ void DreamGenContext::loadIntroRoom() {
reelsOnScreen();
spriteUpdate();
printSprites();
workToScreenCPP();
workToScreen();
}
void DreamGenContext::set16ColPalette() {
void DreamBase::set16ColPalette() {
}
void DreamGenContext::realCredits() {
void DreamBase::realCredits() {
data.byte(kRoomssample) = 33;
loadRoomsSample();
data.byte(kVolume) = 0;

View File

@ -1267,7 +1267,7 @@ void DreamBase::useDiary() {
showDiaryPage();
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
data.byte(kGetback) = 0;
@ -1586,7 +1586,7 @@ void DreamBase::withWhat() {
data.byte(kCommandtype) = 255;
readMouse();
showPointer();
workToScreenCPP();
workToScreen();
delPointer();
data.byte(kInvopen) = 2;
}

View File

@ -281,8 +281,53 @@ void DreamBase::dumpCurrent() {
engine->setPalette(pal, 128, 128);
}
void DreamGenContext::rollEndCredits2() {
void DreamBase::rollEndCredits2() {
rollEm();
}
void DreamBase::rollEm() {
// Note: This function is very similar to rollEndCredits() in sprite.cpp
multiGet(mapStore(), 25, 20, 160, 160);
const uint8 *string = getTextInFile1(49);
const int linespacing = data.word(kLinespacing);
for (int i = 0; i < 80; ++i) {
// Output the text, initially with an offset of 10 pixels,
// then move it up one pixel until we shifted it by a complete
// line of text.
for (int j = 0; j < linespacing; ++j) {
vSync();
multiPut(mapStore(), 25, 20, 160, 160);
vSync();
// Output up to 18 lines of text
uint16 y = 10 - j;
const uint8 *tmp_str = string;
for (int k = 0; k < 18; ++k) {
DreamBase::printDirect(&tmp_str, 25, &y, 160 + 1, true);
y += linespacing;
}
vSync();
multiDump(25, 20, 160, 160);
if (data.byte(kLasthardkey) == 1)
return;
}
// Skip to the next text line
byte c;
do {
c = *string++;
} while (c != ':' && c != 0);
if (data.byte(kLasthardkey) == 1)
return;
}
hangOne(120);
}
} // End of namespace DreamGen

View File

@ -86,17 +86,10 @@ void DreamBase::multiDump(uint16 x, uint16 y, uint8 width, uint8 height) {
engine->blit(workspace() + offset, kScreenwidth, x, y, width, height);
}
void DreamBase::workToScreenCPP() {
void DreamBase::workToScreen() {
engine->blit(workspace(), 320, 0, 0, 320, 200);
}
void DreamGenContext::workToScreen() {
workToScreenCPP();
uint size = 320 * 200;
di = si = size;
cx = 0;
}
void DreamBase::printUnderMon() {
engine->printUnderMonitor();
}
@ -360,13 +353,6 @@ void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 fra
return;
}
void DreamGenContext::showFrame() {
uint8 width, height;
showFrame((Frame *)ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height);
cl = width;
ch = height;
}
void DreamBase::clearWork() {
memset(workspace(), 0, 320*200);
}