Skip to content

Commit

Permalink
DREAMWEB: Move rest of saveload.cpp to DreamBase
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Dec 23, 2011
1 parent b6e139d commit b2fcdd6
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 63 deletions.
15 changes: 14 additions & 1 deletion engines/dreamweb/dreambase.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,22 @@ class DreamBase : public SegmentManager {
void delCurs();

// from saveload.cpp
void oldToNames();
void loadGame();
void doLoad(int slot);
void saveGame();
void namesToOld();
void oldToNames();
void saveLoad();
void doSaveLoad();
void showMainOps();
void showDiscOps();
void discOps();
void actualSave();
void actualLoad();
void loadPosition(unsigned int slot);
void savePosition(unsigned int slot, const char *descbuf);
uint scanForNames();
void loadOld();
void showDecisions();
void loadSaveBox();
void showNames();
Expand Down Expand Up @@ -469,6 +477,11 @@ class DreamBase : public SegmentManager {
template <class T> void checkCoords(const RectWithCallback<T> *rectWithCallbacks);
void newGame();
void deleteTaken();
void autoAppear();
void loadRoom();
void startLoading(const Room &room);
void startup();
void atmospheres();

// from use.cpp
void placeFreeObject(uint8 index);
Expand Down
25 changes: 24 additions & 1 deletion engines/dreamweb/newplace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,30 @@ void DreamBase::setLocation(uint8 index) {
data.byte(kRoomscango + index) = 1;
}

// TODO: Place resetLocation here
void DreamBase::resetLocation(uint8 index) {
if (index == 5) {
// delete hotel
purgeALocation(5);
purgeALocation(21);
purgeALocation(22);
purgeALocation(27);
} else if (index == 8) {
// delete TV studio
purgeALocation(8);
purgeALocation(28);
} else if (index == 6) {
// delete sarters
purgeALocation(6);
purgeALocation(20);
purgeALocation(25);
} else if (index == 13) {
// delete boathouse
purgeALocation(13);
purgeALocation(29);
}

data.byte(kRoomscango + index) = 0;
}

void DreamGenContext::readDestIcon() {
loadIntoTemp("DREAMWEB.G05");
Expand Down
25 changes: 0 additions & 25 deletions engines/dreamweb/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,31 +631,6 @@ void DreamGenContext::outOfInv() {
delPointer();
}

void DreamBase::resetLocation(uint8 index) {
if (index == 5) {
// delete hotel
purgeALocation(5);
purgeALocation(21);
purgeALocation(22);
purgeALocation(27);
} else if (index == 8) {
// delete TV studio
purgeALocation(8);
purgeALocation(28);
} else if (index == 6) {
// delete sarters
purgeALocation(6);
purgeALocation(20);
purgeALocation(25);
} else if (index == 13) {
// delete boathouse
purgeALocation(13);
purgeALocation(29);
}

data.byte(kRoomscango + index) = 0;
}

void DreamBase::purgeALocation(uint8 index) {
// index == al
for (uint8 i = 0; i < kNumexobjects; ++i) {
Expand Down
23 changes: 12 additions & 11 deletions engines/dreamweb/saveload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void syncReelRoutine(Common::Serializer &s, ReelRoutine *reel) {
s.syncAsByte(reel->b7);
}

void DreamGenContext::loadGame() {
void DreamBase::loadGame() {
if (data.byte(kCommandtype) != 246) {
data.byte(kCommandtype) = 246;
commandOnly(41);
Expand All @@ -57,7 +57,7 @@ void DreamGenContext::loadGame() {

// if -1, open menu to ask for slot to load
// if >= 0, directly load from that slot
void DreamGenContext::doLoad(int savegameId) {
void DreamBase::doLoad(int savegameId) {
data.byte(kLoadingorsave) = 1;

if (ConfMan.getBool("dreamweb_originalsaveload") && savegameId == -1) {
Expand Down Expand Up @@ -138,7 +138,7 @@ void DreamGenContext::doLoad(int savegameId) {
}


void DreamGenContext::saveGame() {
void DreamBase::saveGame() {
if (data.byte(kMandead) == 2) {
blank();
return;
Expand Down Expand Up @@ -239,7 +239,7 @@ void DreamBase::oldToNames() {
memcpy(_saveNames, _saveNamesOld, 17*7);
}

void DreamGenContext::saveLoad() {
void DreamBase::saveLoad() {
if (data.word(kWatchingtime) || (data.byte(kPointermode) == 2)) {
blank();
return;
Expand All @@ -252,7 +252,7 @@ void DreamGenContext::saveLoad() {
doSaveLoad();
}

void DreamGenContext::doSaveLoad() {
void DreamBase::doSaveLoad() {
data.byte(kPointerframe) = 0;
data.word(kTextaddressx) = 70;
data.word(kTextaddressy) = 182-8;
Expand Down Expand Up @@ -350,7 +350,7 @@ void DreamBase::showDiscOps() {
showFrame(tempGraphics(), kOpsx+176+2, kOpsy+60-4, 5, 0);
}

void DreamGenContext::discOps() {
void DreamBase::discOps() {
if (data.byte(kCommandtype) != 249) {
data.byte(kCommandtype) = 249;
commandOnly(43);
Expand All @@ -368,8 +368,8 @@ void DreamGenContext::discOps() {
data.byte(kGetback) = 0;

RectWithCallback<DreamGenContext> discOpsList[] = {
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::loadGame },
{ kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamGenContext::saveGame },
{ kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamBase::loadGame },
{ kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamBase::saveGame },
{ kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps },
{ 0,320,0,200,&DreamBase::blank },
{ 0xFFFF,0,0,0,0 }
Expand Down Expand Up @@ -589,7 +589,7 @@ void DreamBase::loadPosition(unsigned int slot) {
}

// Count number of save files, and load their descriptions into _saveNames
unsigned int DreamGenContext::scanForNames() {
uint DreamBase::scanForNames() {
// Initialize the first 7 slots (like the original code expects)
for (unsigned int slot = 0; slot < 7; ++slot) {
_saveNames[17 * slot + 0] = 2;
Expand Down Expand Up @@ -620,12 +620,13 @@ unsigned int DreamGenContext::scanForNames() {
Common::strlcpy(&_saveNames[17 * slotNum + 1], name, 16); // the first character is unused
}

al = saveList.size() <= 7 ? (uint8)saveList.size() : 7;
// FIXME: Can the following be safely removed?
// al = saveList.size() <= 7 ? (uint8)saveList.size() : 7;

return saveList.size();
}

void DreamGenContext::loadOld() {
void DreamBase::loadOld() {
if (data.byte(kCommandtype) != 252) {
data.byte(kCommandtype) = 252;
commandOnly(48);
Expand Down
20 changes: 8 additions & 12 deletions engines/dreamweb/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ void DreamGenContext::dreamweb() {

while (true) {

unsigned int count = scanForNames();
uint count = scanForNames();

bool startNewGame = true;

Expand Down Expand Up @@ -707,7 +707,7 @@ void DreamGenContext::screenUpdate() {
delPointer();
}

void DreamGenContext::startup() {
void DreamBase::startup() {
data.byte(kCurrentkey) = 0;
data.byte(kMainmode) = 0;
createPanel();
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void DreamBase::clearAndLoad(uint16 seg, uint8 c,
clearAndLoad(buf, c, size, maxSize);
}

void DreamGenContext::startLoading(const Room &room) {
void DreamBase::startLoading(const Room &room) {
data.byte(kCombatcount) = 0;
data.byte(kRoomssample) = room.roomsSample;
data.byte(kMapx) = room.mapX;
Expand Down Expand Up @@ -2092,7 +2092,7 @@ void DreamBase::zoomIcon() {
showFrame(engine->icons1(), kZoomx, kZoomy-1, 8, 0);
}

void DreamGenContext::loadRoom() {
void DreamBase::loadRoom() {
data.byte(kRoomloaded) = 1;
data.word(kTimecount) = 0;
data.word(kMaintimer) = 0;
Expand All @@ -2111,10 +2111,6 @@ void DreamGenContext::loadRoom() {
uint8 mapXstart, mapYstart;
uint8 mapXsize, mapYsize;
getDimension(&mapXstart, &mapYstart, &mapXsize, &mapYsize);
cl = mapXstart;
ch = mapYstart;
dl = mapXsize;
dh = mapYsize;
}

void DreamGenContext::readSetData() {
Expand Down Expand Up @@ -2627,7 +2623,7 @@ void DreamGenContext::useMenu() {
workToScreenM();
}

void DreamGenContext::atmospheres() {
void DreamBase::atmospheres() {

const Atmosphere *a = &g_atmosphereList[0];

Expand All @@ -2651,8 +2647,8 @@ void DreamGenContext::atmospheres() {
// I'm interpreting this as if the cmp reallocation is below the jz

if (data.byte(kMapy) == 0) {
data.byte(kVolume) = 0; // "fullvol"
return;
data.byte(kVolume) = 0; // "fullvol"
return;
}

if (data.byte(kReallocation) == 2 && data.byte(kMapx) == 22 && data.byte(kMapy) == 10)
Expand Down Expand Up @@ -3898,7 +3894,7 @@ void DreamGenContext::useButtonA() {
}
}

void DreamGenContext::autoAppear() {
void DreamBase::autoAppear() {
if (data.byte(kLocation) == 32) {
// In alley
resetLocation(5);
Expand Down
13 changes: 0 additions & 13 deletions engines/dreamweb/stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
#define DREAMWEB_STUBS_H

void screenUpdate();
void startup();
void startup1();
void saveLoad();
void workToScreen();
void multiGet();
void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height) {
Expand All @@ -52,7 +50,6 @@
uint8 printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered) {
return DreamBase::printDirect(string, x, y, maxWidth, centered);
}
void startLoading(const Room &room);
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);
Expand Down Expand Up @@ -131,7 +128,6 @@
void dumpWatch();
void transferText();
void watchCount();
void loadRoom();
void readSetData();
void useMenu();
void useMon();
Expand Down Expand Up @@ -219,15 +215,9 @@
uint8 nextSymbol(uint8 symbol);
void showSymbol();
void enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3);
unsigned int scanForNames();
void doLoad(int slot);
void loadOld();
void inventory();
void mainScreen();
void loadGame();
void saveGame();
void zoomOnOff();
void atmospheres();
void hangOne(uint16 delay);
void hangOne();
void bibleQuote();
Expand Down Expand Up @@ -287,8 +277,6 @@
void madmanRun();
void decide();
void talk();
void discOps();
void doSaveLoad();
void useDiary();
void hangOnPQ();
void showGun();
Expand All @@ -299,7 +287,6 @@
void monkSpeaking();
void rollEndCredits2();
void useButtonA();
void autoAppear();
void setupTimedUse();
void entryAnims();
void triggerMessage(uint16 index);
Expand Down

0 comments on commit b2fcdd6

Please sign in to comment.