diff options
54 files changed, 5662 insertions, 4142 deletions
@@ -1346,7 +1346,7 @@ The platforms that currently have a different default directory are: 6.1) Autosaves: ---- ---------- -For some games, (namely "Beneath a Steel Sky", "Flight of the Amazon +For some games (namely "Beneath a Steel Sky", "Flight of the Amazon Queen", all AGI games, and all SCUMM games), ScummVM will by default automatically save the current state every five minutes (adjustable via the "autosave_period" config setting). For the AGI and SCUMM engines, it @@ -1356,8 +1356,8 @@ loaded again via Ctrl-0, or the F5 menu. 6.2) Converting Savegames: ---- --------------------- -Using savegames from original versions, isn't supported by all game -engines. Only the following games, can use savegames from their original +Using savegames from original versions isn't supported by all game +engines. Only the following games can use savegames from their original versions. Elvira 1 @@ -1879,7 +1879,7 @@ the original frequency. ---- ------------------- By default, the configuration file is saved in, and loaded from: - Windows Vista: + Windows Vista/7: \Users\username\AppData\Roaming\ScummVM\scummvm.ini, Windows 2000/XP: diff --git a/audio/decoders/mac_snd.h b/audio/decoders/mac_snd.h index 7e960058ae..4380808eae 100644 --- a/audio/decoders/mac_snd.h +++ b/audio/decoders/mac_snd.h @@ -23,6 +23,7 @@ /** * @file * Sound decoder used in engines: + * - saga * - sci */ diff --git a/audio/decoders/voc.cpp b/audio/decoders/voc.cpp index 06a0b845a0..2cd5b23d09 100644 --- a/audio/decoders/voc.cpp +++ b/audio/decoders/voc.cpp @@ -54,7 +54,7 @@ bool checkVOCHeader(Common::ReadStream &stream) { if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0) return false; //if (fileHeader.desc[19] != 0x1A) - // debug(3, "loadVOCFromStream: Partially invalid header"); + // debug(3, "checkVOCHeader: Partially invalid header"); int32 offset = FROM_LE_16(fileHeader.datablock_offset); int16 version = FROM_LE_16(fileHeader.version); @@ -511,128 +511,6 @@ int getSampleRateFromVOCRate(int vocSR) { } } -byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate) { - VocFileHeader fileHeader; - - debug(2, "loadVOCFromStream"); - - if (stream.read(&fileHeader, 8) != 8) - goto invalid; - - if (!memcmp(&fileHeader, "VTLK", 4)) { - if (stream.read(&fileHeader, sizeof(VocFileHeader)) != sizeof(VocFileHeader)) - goto invalid; - } else if (!memcmp(&fileHeader, "Creative", 8)) { - if (stream.read(((byte *)&fileHeader) + 8, sizeof(VocFileHeader) - 8) != sizeof(VocFileHeader) - 8) - goto invalid; - } else { - invalid:; - warning("loadVOCFromStream: Invalid header"); - return NULL; - } - - if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0) - error("loadVOCFromStream: Invalid header"); - if (fileHeader.desc[19] != 0x1A) - debug(3, "loadVOCFromStream: Partially invalid header"); - - int32 offset = FROM_LE_16(fileHeader.datablock_offset); - int16 version = FROM_LE_16(fileHeader.version); - int16 code = FROM_LE_16(fileHeader.id); - assert(offset == sizeof(VocFileHeader)); - // 0x100 is an invalid VOC version used by German version of DOTT (Disk) and - // French version of Simon the Sorcerer 2 (CD) - assert(version == 0x010A || version == 0x0114 || version == 0x0100); - assert(code == ~version + 0x1234); - - int len; - byte *ret_sound = 0; - size = 0; - - while ((code = stream.readByte())) { - len = stream.readByte(); - len |= stream.readByte() << 8; - len |= stream.readByte() << 16; - - debug(2, "Block code %d, len %d", code, len); - - switch (code) { - case 1: - case 9: { - int packing; - if (code == 1) { - int time_constant = stream.readByte(); - packing = stream.readByte(); - len -= 2; - rate = getSampleRateFromVOCRate(time_constant); - } else { - rate = stream.readUint32LE(); - int bits = stream.readByte(); - int channels = stream.readByte(); - if (bits != 8 || channels != 1) { - warning("Unsupported VOC file format (%d bits per sample, %d channels)", bits, channels); - break; - } - packing = stream.readUint16LE(); - stream.readUint32LE(); - len -= 12; - } - debug(9, "VOC Data Block: %d, %d, %d", rate, packing, len); - if (packing == 0) { - if (size) { - byte *tmp = (byte *)realloc(ret_sound, size + len); - if (!tmp) - error("Cannot reallocate memory for VOC Data Block"); - - ret_sound = tmp; - } else { - ret_sound = (byte *)malloc(len); - } - stream.read(ret_sound + size, len); - size += len; - } else { - warning("VOC file packing %d unsupported", packing); - } - } break; - case 3: // silence - // occur with a few Igor sounds, voc file starts with a silence block with a - // frequency different from the data block. Just ignore fow now (implementing - // it wouldn't make a big difference anyway...) - assert(len == 3); - stream.readUint16LE(); - stream.readByte(); - break; - case 6: // begin of loop - assert(len == 2); - stream.readUint16LE(); - break; - case 7: // end of loop - assert(len == 0); - break; - case 8: { // "Extended" - // This occures in the LoL Intro demo. - // This block overwrites the next parameters of a block 1 "Sound data". - // To assure we never get any bad data here, we will assert in case - // this tries to define a stereo sound block or tries to use something - // different than 8bit unsigned sound data. - // TODO: Actually we would need to check the frequency divisor (the - // first word) here too. It is used in the following equation: - // sampleRate = 256000000/(channels * (65536 - frequencyDivisor)) - assert(len == 4); - stream.readUint16LE(); - uint8 codec = stream.readByte(); - uint8 channels = stream.readByte() + 1; - assert(codec == 0 && channels == 1); - } break; - default: - warning("Unhandled code %d in VOC file (len %d)", code, len); - return ret_sound; - } - } - debug(4, "VOC Data Size : %d", size); - return ret_sound; -} - SeekableAudioStream *makeVOCStream(Common::SeekableReadStream *stream, byte flags, DisposeAfterUse::Flag disposeAfterUse) { if (!checkVOCHeader(*stream)) { if (disposeAfterUse == DisposeAfterUse::YES) diff --git a/audio/decoders/voc.h b/audio/decoders/voc.h index 7d96d261b5..e16ffce42f 100644 --- a/audio/decoders/voc.h +++ b/audio/decoders/voc.h @@ -78,14 +78,6 @@ struct VocBlockHeader { extern int getSampleRateFromVOCRate(int vocSR); /** - * Try to load a VOC from the given stream. Returns a pointer to memory - * containing the PCM sample data (allocated with malloc). It is the callers - * responsibility to dellocate that data again later on! Currently this - * function only supports uncompressed raw PCM data. - */ -extern byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate); - -/** * Try to load a VOC from the given seekable stream and create an AudioStream * from that data. Currently this function only supports uncompressed raw PCM * data. diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 1682879385..cd0a352c84 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -632,7 +632,7 @@ pajama Pajama Sam 1: No Need to Hide When It's Dark Outside f237bf8a5ef9af78b2a6a4f3901da341 18354 en All - Demo - khalek, sev 7f945525abcd48015adf1632637a44a1 -1 fr All - Demo - Kirben - 0305e850382b812fec6e5998ef88a966 -1 nl Windows - Demo - adutchguy + 0305e850382b812fec6e5998ef88a966 -1 nl All - Demo - adutchguy 87df3e0074624040407764b7c5e710b9 18354 nl Windows - Demo - George Kormendi d7ab7cd6105546016e6a0d46fb36b964 -1 en All HE 100 Demo - khalek diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index e7716acb34..e7c7cf20a1 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -50,6 +50,7 @@ p = parser(skip_binary_data = [ 'volumetabname', 'commandline', 'openchangesize', + 'roompics', # keypad.asm 'keypadlist', 'symbollist', @@ -171,6 +172,17 @@ p = parser(skip_binary_data = [ 'lastflagex', 'keynum', 'newlogonum', + 'currentex', + 'currentfree', + 'frsegment', + 'dataad', + 'framesad', + 'objectx', + 'objecty', + 'savesize', + 'savesource', + 'savex', + 'savey', # vgagrafx.asm 'cityname', 'extragraphics1', @@ -304,6 +316,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'checkifset', 'checkinput', 'checkinside', + 'checkobjectsize', 'checkone', 'checksoundint', 'checkspeed', @@ -367,6 +380,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'dontloadseg', 'doorway', 'dosaveload', + 'dosometalk', 'dosreturn', 'doshake', 'drawflags', @@ -374,6 +388,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'drawitall', 'drinker', 'droperror', + 'dropobject', 'drunk', 'dumpblink', 'dumpcurrent', @@ -392,6 +407,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'eden', 'edeninbath', 'edenscdplayer', + 'emergencypurge', 'enablesoundint', 'endgame', 'endgameseq', @@ -413,6 +429,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'facerightway', 'fadecalculation', 'fadedos', + 'fadedownmon', 'fadefromwhite', 'fadescreenup', 'fadescreenups', @@ -421,6 +438,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'fadescreendowns', 'fadescreendownhalf', 'fadetowhite', + 'fadeupmon', 'fadeupmonfirst', 'fadeupyellows', 'femalefan', @@ -429,11 +447,14 @@ generator = cpp(context, "DreamGen", blacklist = [ 'finalframe', 'findallryan', 'findexobject', + 'findfirstpath', 'findinvpos', 'findlen', 'findnextcolon', 'findobname', + 'findopenpos', 'findormake', + 'findpathofpoint', 'findpuztext', 'findroominloc', 'findsetobject', @@ -457,7 +478,9 @@ generator = cpp(context, "DreamGen", blacklist = [ 'getbackfromops', 'getbacktoops', 'getblockofpixel', + 'getdestinfo', 'getdimension', + 'geteitherad', 'getexpos', 'getflagunderp', 'getkeyandlogo', @@ -466,8 +489,10 @@ generator = cpp(context, "DreamGen", blacklist = [ 'getnamepos', 'getnextword', 'getnumber', + 'getobtextstart', 'getopenedsize', 'getpersframe', + 'getpersontext', 'getreelframeax', 'getreelstart', 'getridofall', @@ -503,7 +528,9 @@ generator = cpp(context, "DreamGen", blacklist = [ 'hotelbell', 'hotelcontrol', 'identifyob', + 'incryanpage', 'initialinv', + 'initialmoncols', 'initman', 'initrain', 'input', @@ -557,6 +584,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'loadtempcharset', 'loadtemptext', 'loadtraveltext', + 'locationpic', 'lockeddoorway', 'locklightoff', 'locklighton', @@ -640,6 +668,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'othersmoker', 'out22c', 'outofinv', + 'outofopen', 'paltoendpal', 'paltostartpal', 'panelicons1', @@ -673,6 +702,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'printsprites', 'printundermon', 'processtrigger', + 'purgealocation', + 'purgeanitem', 'putbackobstuff', 'putundercentre', 'putundermenu', @@ -706,16 +737,20 @@ generator = cpp(context, "DreamGen", blacklist = [ 'redes', 'redrawmainscrn', 'reelsonscreen', + 'reexfrominv', 'reexfromopen', + 'reminders', 'removeemm', 'removefreeobject', 'removesetobject', 'removeobfrominv', 'resetkeyboard', + 'resetlocation', 'restoreall', 'restoreems', 'restorereels', 'rockstar', + 'rollem', 'rollendcredits', 'rollendcredits2', 'roomname', @@ -732,10 +767,13 @@ generator = cpp(context, "DreamGen", blacklist = [ 'scanfornames', 'screenupdate', 'scrollmonitor', + 'searchforfiles', + 'searchforsame', 'security', 'seecommandtail', 'selectlocation', 'selectob', + 'selectopenob', 'selectslot', 'selectslot2', 'set16colpalette', @@ -827,10 +865,13 @@ generator = cpp(context, "DreamGen", blacklist = [ 'startdmablock', 'startloading', 'startpaltoend', + 'starttalk', 'startup', 'startup1', 'steady', 'storeit', + 'swapwithinv', + 'swapwithopen', 'switchryanoff', 'switchryanon', 'talk', @@ -891,6 +932,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'usemon', 'useobject', 'useopenbox', + 'useopened', 'usepipe', 'useplate', 'useplinth', @@ -1550,12 +1592,12 @@ generator = cpp(context, "DreamGen", blacklist = [ 'signon' : 'signOn', 'singlekey' : 'singleKey', 'sitdowninbar' : 'sitDownInBar', - 'slabdoora' : 'sLabDoorA', - 'slabdoorb' : 'sLabDoorB', - 'slabdoorc' : 'sLabDoorC', - 'slabdoord' : 'sLabDoorD', - 'slabdoore' : 'sLabDoorE', - 'slabdoorf' : 'sLabDoorF', + 'slabdoora' : 'slabDoorA', + 'slabdoorb' : 'slabDoorB', + 'slabdoorc' : 'slabDoorC', + 'slabdoord' : 'slabDoorD', + 'slabdoore' : 'slabDoorE', + 'slabdoorf' : 'slabDoorF', 'smallcandle' : 'smallCandle', 'smokebloke' : 'smokeBloke', 'soldier1' : 'soldier1', @@ -1647,7 +1689,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'userailing' : 'useRailing', 'useroutine' : 'useRoutine', 'useshield' : 'useShield', - 'useslab' : 'useSLab', + 'useslab' : 'useSlab', 'usestereo' : 'useStereo', 'usetempcharset' : 'useTempCharset', 'usetext' : 'useText', diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index 38ccb0296c..875e16805e 100644 --- a/engines/dreamweb/backdrop.cpp +++ b/engines/dreamweb/backdrop.cpp @@ -89,46 +89,39 @@ uint8 DreamBase::getYAd(const uint8 *setData, uint8 *result) { return 1; } -uint8 DreamBase::getMapAd(const uint8 *setData) { +uint8 DreamBase::getMapAd(const uint8 *setData, uint16 *x, uint16 *y) { uint8 xad, yad; if (getXAd(setData, &xad) == 0) return 0; - data.word(kObjectx) = xad; + *x = xad; if (getYAd(setData, &yad) == 0) return 0; - data.word(kObjecty) = yad; + *y = yad; return 1; } -void DreamBase::calcFrFrame(uint16 frameNum, uint8* width, uint8* height) { - const Frame *frame = (const Frame *)getSegment(data.word(kFrsegment)).ptr(frameNum * sizeof(Frame), sizeof(Frame)); - data.word(kSavesource) = data.word(kFramesad) + frame->ptr(); - data.byte(kSavesize+0) = frame->width; - data.byte(kSavesize+1) = frame->height; - data.word(kOffsetx) = frame->x; - data.word(kOffsety) = frame->y; +void DreamBase::calcFrFrame(const Frame *frameBase, uint16 frameNum, uint8 *width, uint8 *height, uint16 x, uint16 y, ObjPos *objPos) { + const Frame *frame = frameBase + frameNum; *width = frame->width; *height = frame->height; -} -void DreamBase::finalFrame(uint16 *x, uint16 *y) { - data.byte(kSavex) = (data.word(kObjectx) + data.word(kOffsetx)) & 0xff; - data.byte(kSavey) = (data.word(kObjecty) + data.word(kOffsety)) & 0xff; - *x = data.word(kObjectx); - *y = data.word(kObjecty); + objPos->xMin = (x + frame->x) & 0xff; + objPos->yMin = (y + frame->y) & 0xff; + objPos->xMax = objPos->xMin + frame->width; + objPos->yMax = objPos->yMin + frame->height; } -void DreamBase::makeBackOb(SetObject *objData) { +void DreamBase::makeBackOb(SetObject *objData, uint16 x, uint16 y) { if (data.byte(kNewobs) == 0) return; uint8 priority = objData->priority; uint8 type = objData->type; - Sprite *sprite = makeSprite(data.word(kObjectx), data.word(kObjecty), addr_backobject, data.word(kSetframes), 0); + Sprite *sprite = makeSprite(x, y, addr_backobject, data.word(kSetframes), 0); uint16 objDataOffset = (uint8 *)objData - getSegment(data.word(kSetdat)).ptr(0, 0); assert(objDataOffset % sizeof(SetObject) == 0); assert(objDataOffset < 128 * sizeof(SetObject)); - sprite->setObjData(objDataOffset); + sprite->_objData = objDataOffset; if (priority == 255) priority = 0; sprite->priority = priority; @@ -139,40 +132,33 @@ void DreamBase::makeBackOb(SetObject *objData) { } void DreamBase::showAllObs() { - data.word(kListpos) = kSetlist; - memset(getSegment(data.word(kBuffers)).ptr(kSetlist, 0), 0xff, 128 * 5); - data.word(kFrsegment) = data.word(kSetframes); - data.word(kDataad) = kFramedata; - data.word(kFramesad) = kFrames; - - const Frame *frames = (const Frame *)getSegment(data.word(kFrsegment)).ptr(0, 0); - SetObject *setEntries = (SetObject *)getSegment(data.word(kSetdat)).ptr(0, 128 * sizeof(SetObject)); - for (size_t i = 0; i < 128; ++i) { + const unsigned int count = 128; + + _setList.clear(); + + const Frame *frameBase = (const Frame *)getSegment(data.word(kSetframes)).ptr(0, 0); + SetObject *setEntries = (SetObject *)getSegment(data.word(kSetdat)).ptr(0, count * sizeof(SetObject)); + for (size_t i = 0; i < count; ++i) { SetObject *setEntry = setEntries + i; - if (getMapAd(setEntry->mapad) == 0) + uint16 x, y; + if (getMapAd(setEntry->mapad, &x, &y) == 0) continue; uint8 currentFrame = setEntry->frames[0]; if (currentFrame == 0xff) continue; uint8 width, height; - calcFrFrame(currentFrame, &width, &height); - uint16 x, y; - finalFrame(&x, &y); + ObjPos objPos; + calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos); setEntry->index = setEntry->frames[0]; if ((setEntry->type == 0) && (setEntry->priority != 5) && (setEntry->priority != 6)) { x += data.word(kMapadx); y += data.word(kMapady); - showFrame(frames, x, y, currentFrame, 0); + showFrame(frameBase, x, y, currentFrame, 0); } else - makeBackOb(setEntry); - - ObjPos *objPos = (ObjPos *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(ObjPos)); - objPos->xMin = data.byte(kSavex); - objPos->yMin = data.byte(kSavey); - objPos->xMax = data.byte(kSavex) + data.byte(kSavesize+0); - objPos->yMax = data.byte(kSavey) + data.byte(kSavesize+1); - objPos->index = i; - data.word(kListpos) += sizeof(ObjPos); + makeBackOb(setEntry, x, y); + + objPos.index = i; + _setList.push_back(objPos); } } @@ -193,22 +179,20 @@ bool DreamBase::addLength(const uint8 *mapFlags) { } void DreamBase::getDimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize) { - const uint8 *mapFlags = getSegment(data.word(kBuffers)).ptr(kMapflags, 0); - uint8 yStart = 0; - while (! addAlong(mapFlags + 3 * 11 * yStart)) + while (! addAlong(_mapFlags + 3 * 11 * yStart)) ++yStart; uint8 xStart = 0; - while (! addLength(mapFlags + 3 * xStart)) + while (! addLength(_mapFlags + 3 * xStart)) ++xStart; uint8 yEnd = 10; - while (! addAlong(mapFlags + 3 * 11 * (yEnd - 1))) + while (! addAlong(_mapFlags + 3 * 11 * (yEnd - 1))) --yEnd; uint8 xEnd = 11; - while (! addLength(mapFlags + 3 * (xEnd - 1))) + while (! addLength(_mapFlags + 3 * (xEnd - 1))) --xEnd; *mapXstart = xStart; @@ -230,44 +214,34 @@ void DreamBase::calcMapAd() { } void DreamBase::showAllFree() { - data.word(kListpos) = kFreelist; - ObjPos *listPos = (ObjPos *)getSegment(data.word(kBuffers)).ptr(kFreelist, 80 * sizeof(ObjPos)); - memset(listPos, 0xff, 80 * sizeof(ObjPos)); - - data.word(kFrsegment) = data.word(kFreeframes); - data.word(kDataad) = kFrframedata; - data.word(kFramesad) = kFrframes; - data.byte(kCurrentfree) = 0; + const unsigned int count = 80; + + _freeList.clear(); + const DynObject *freeObjects = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0); - for (size_t i = 0; i < 80; ++i) { - uint8 mapAd = getMapAd(freeObjects[i].mapad); + const Frame *frameBase = (const Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0); + for (size_t i = 0; i < count; ++i) { + uint16 x, y; + uint8 mapAd = getMapAd(freeObjects[i].mapad, &x, &y); if (mapAd != 0) { uint8 width, height; - uint16 currentFrame = 3 * data.byte(kCurrentfree); - calcFrFrame(currentFrame, &width, &height); - uint16 x, y; - finalFrame(&x, &y); + ObjPos objPos; + uint16 currentFrame = 3 * i; + calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos); if ((width != 0) || (height != 0)) { x += data.word(kMapadx); y += data.word(kMapady); assert(currentFrame < 256); - showFrame((Frame *)getSegment(data.word(kFrsegment)).ptr(0, 0), x, y, currentFrame, 0); - ObjPos *objPos = (ObjPos *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(ObjPos)); - objPos->xMin = data.byte(kSavex); - objPos->yMin = data.byte(kSavey); - objPos->xMax = data.byte(kSavex) + data.byte(kSavesize+0); - objPos->yMax = data.byte(kSavey) + data.byte(kSavesize+1); - objPos->index = i; - data.word(kListpos) += sizeof(ObjPos); + showFrame(frameBase, x, y, currentFrame, 0); + objPos.index = i; + _freeList.push_back(objPos); } } - - ++data.byte(kCurrentfree); } } void DreamBase::drawFlags() { - uint8 *mapFlags = getSegment(data.word(kBuffers)).ptr(kMapflags, 0); + uint8 *mapFlags = _mapFlags; const uint8 *mapData = getSegment(data.word(kMapdata)).ptr(kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx), 0); const uint8 *backdropFlags = getSegment(data.word(kBackdrop)).ptr(kFlags, 0); @@ -283,37 +257,30 @@ void DreamBase::drawFlags() { } void DreamBase::showAllEx() { - data.word(kListpos) = kExlist; - memset(getSegment(data.word(kBuffers)).ptr(kExlist, 100 * 5), 0xff, 100 * 5); + const unsigned int count = 100; + + _exList.clear(); - data.word(kFrsegment) = data.word(kExtras); - data.word(kDataad) = kExframedata; - data.word(kFramesad) = kExframes; - data.byte(kCurrentex) = 0; DynObject *objects = (DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, sizeof(DynObject)); - for (size_t i = 0; i < 100; ++i, ++data.byte(kCurrentex)) { + const Frame *frameBase = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0); + for (size_t i = 0; i < count; ++i) { DynObject *object = objects + i; if (object->mapad[0] == 0xff) continue; if (object->currentLocation != data.byte(kReallocation)) continue; - if (getMapAd(object->mapad) == 0) + uint16 x, y; + if (getMapAd(object->mapad, &x, &y) == 0) continue; uint8 width, height; - uint16 currentFrame = 3 * data.byte(kCurrentex); - calcFrFrame(currentFrame, &width, &height); - uint16 x, y; - finalFrame(&x, &y); + ObjPos objPos; + uint16 currentFrame = 3 * i; + calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos); if ((width != 0) || (height != 0)) { assert(currentFrame < 256); - showFrame((Frame *)getSegment(data.word(kFrsegment)).ptr(0, 0), x + data.word(kMapadx), y + data.word(kMapady), currentFrame, 0); - ObjPos *objPos = (ObjPos *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(ObjPos)); - objPos->xMin = data.byte(kSavex); - objPos->yMin = data.byte(kSavey); - objPos->xMax = data.byte(kSavesize + 0) + data.byte(kSavex); - objPos->yMax = data.byte(kSavesize + 1) + data.byte(kSavey); - objPos->index = i; - data.word(kListpos) += sizeof(ObjPos); + showFrame(frameBase, x + data.word(kMapadx), y + data.word(kMapady), currentFrame, 0); + objPos.index = i; + _exList.push_back(objPos); } } } diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index 6de854f452..cbcfa1e46f 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -24,6 +24,7 @@ #define DREAMBASE_H #include "common/scummsys.h" +#include "common/list.h" #include "dreamweb/segment.h" @@ -34,8 +35,18 @@ namespace DreamWeb { namespace DreamGen { - + // Note: duplication from dreamgen.h const unsigned int kNumReelRoutines = 57; +const unsigned int kUnderTextSizeX = 180; +const unsigned int kUnderTextSizeY = 10; +const unsigned int kUnderTimedTextSizeY = 24; +const unsigned int kUnderTextSizeX_f = 228; // foreign version +const unsigned int kUnderTextSizeY_f = 13; // foreign version +const unsigned int kUnderTimedTextSizeY_f = 30; +const unsigned int kUnderTextBufSize = kUnderTextSizeX_f * kUnderTextSizeY_f; +const unsigned int kUnderTimedTextBufSize = 256 * kUnderTimedTextSizeY_f; +const unsigned int kLengthOfVars = 68; +const unsigned int kNumChanges = 250; /** * This class is one of the parent classes of DreamGenContext. Its sole purpose @@ -65,6 +76,28 @@ protected: // from people.cpp ReelRoutine _reelRoutines[kNumReelRoutines+1]; + ReelRoutine *_personData; + + // from Buffers + uint8 _textUnder[kUnderTextBufSize]; + // _openInvList (see fillOpen/findOpenPos) + // _ryanInvList (see findInvPos/findInvPosCPP) + uint8 _pointerBack[32*32]; + uint8 _mapFlags[11*10*3]; + uint8 _startPal[3*256]; + uint8 _endPal[3*256]; + uint8 _mainPal[3*256]; + Common::List<Sprite> _spriteTable; + Common::List<ObjPos> _setList; + Common::List<ObjPos> _freeList; + Common::List<ObjPos> _exList; + Common::List<People> _peopleList; + uint8 _zoomSpace[46*40]; + // _printedList (unused?) + Change _listOfChanges[kNumChanges]; // Note: this array is saved + uint8 _underTimedText[kUnderTimedTextBufSize]; + Common::List<Rain> _rainList; + uint8 _initialVars[kLengthOfVars]; // TODO: This shouldn't be necessary public: DreamBase(DreamWeb::DreamWebEngine *en); @@ -74,10 +107,9 @@ public: void doBlocks(); uint8 getXAd(const uint8 *setData, uint8 *result); uint8 getYAd(const uint8 *setData, uint8 *result); - uint8 getMapAd(const uint8 *setData); - void calcFrFrame(uint16 frame, uint8* width, uint8* height); - void finalFrame(uint16 *x, uint16 *y); - void makeBackOb(SetObject *objData); + uint8 getMapAd(const uint8 *setData, uint16 *x, uint16 *y); + void calcFrFrame(const Frame *frameBase, uint16 frameNum, uint8* width, uint8* height, uint16 x, uint16 y, ObjPos *objPos); + void makeBackOb(SetObject *objData, uint16 x, uint16 y); void showAllObs(); bool addAlong(const uint8 *mapFlags); bool addLength(const uint8 *mapFlags); @@ -112,6 +144,7 @@ public: void dumpSymbol(); void dumpSymBox(); void quitSymbol(); + void enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3); // from monitor.cpp void input(); @@ -136,6 +169,25 @@ public: void loadPersonal(); void loadNews(); void loadCart(); + void showKeys(); + + // from newplace.cpp + void getUnderCentre(); + void putUnderCentre(); + void showArrows(); + uint8 getLocation(uint8 index); + void setLocation(uint8 index); + void resetLocation(uint8 index); + void readCityPic(); + void readDestIcon(); + void showCity(); + void locationPic(); + void selectLocation(); + void newPlace(); + void nextDest(); + void lastDest(); + void destSelect(); + void lookAtPlace(); // from object.cpp void obIcons(); @@ -147,6 +199,12 @@ public: void deleteExObject(uint8 index); void deleteExFrame(uint8 frameNum); void deleteExText(uint8 textNum); + void purgeALocation(uint8 index); + const uint8 *getObTextStart(); + void wornError(); + void makeWorn(DynObject *object); + void dropObject(); + uint16 findOpenPos(); // from pathfind.cpp void turnPathOn(uint8 param); @@ -162,6 +220,8 @@ public: bool checkIfPathIsOn(uint8 index); void bresenhams(); void workoutFrames(); + byte findFirstPath(byte x, byte y); + byte findPathOfPoint(byte x, byte y); // from people.cpp void setupInitialReelRoutines(); @@ -232,15 +292,35 @@ public: uint16 waitFrames(); void printCurs(); void delCurs(); + void rollEndCreditsGameWon(); + void rollEndCreditsGameLost(); // 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 showNames(); + 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(); + void checkInput(); + void selectSlot(); + void showSlots(); + void showOpBox(); + void showSaveOps(); + void showLoadOps(); // from sound.cpp bool loadSpeech(byte type1, int idx1, byte type2, int idx2); @@ -252,7 +332,6 @@ public: void playChannel1(uint8 index); // from sprite.cpp - Sprite *spriteTable(); void printSprites(); void printASprite(const Sprite *sprite); void clearSprites(); @@ -279,14 +358,13 @@ public: void checkOne(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uint8 *type, uint8 *flagX, uint8 *flagY); uint8 getBlockOfPixel(uint8 x, uint8 y); - Rain *splitIntoLines(uint8 x, uint8 y, Rain *rain); + void splitIntoLines(uint8 x, uint8 y); void initRain(); void intro1Text(); void intro2Text(uint16 nextReelPointer); void intro3Text(uint16 nextReelPointer); - void rollEndCredits(); void monks2text(); void textForEnd(); void textForMonkHelper(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8 y, uint16 countToTimed, uint16 timeCount); @@ -319,8 +397,6 @@ public: Frame *tempGraphics(); Frame *tempGraphics2(); Frame *tempGraphics3(); - void showArrows(); - void showOpBox(); void middlePanel(); void showDiary(); void readMouse(); @@ -341,7 +417,7 @@ public: void showMan(); void panelIcons1(); SetObject *getSetAd(uint8 index); - void *getAnyAd(uint8 *value1, uint8 *value2); + void *getAnyAd(uint8 *slotSize, uint8 *slotCount); const uint8 *getTextInFile1(uint16 index); uint8 findNextColon(const uint8 **string); void allocateBuffers(); @@ -440,6 +516,68 @@ public: void makeMainScreen(); void showWatchReel(); void watchReel(); + void commandWithOb(uint8 command, uint8 type, uint8 index); + void examineObText(); + void blockNameText(); + void personNameText(); + void walkToText(); + void entryTexts(); + void setAllChanges(); + void restoreAll(); + void redrawMainScrn(); + 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(); + bool objectMatches(void *object, const char *id); + void checkFolderCoords(); + void nextFolder(); + void lastFolder(); + void lookAtCard(); + void obsThatDoThings(); + void describeOb(); + void putBackObStuff(); + void reExFromOpen(); + void showDiaryPage(); + void showDiaryKeys(); + void dumpDiaryKeys(); + void useMenu(); + void incRyanPage(); + void edensFlatReminders(); + void dropError(); + void cantDrop(); + void entryAnims(); + bool finishedWalking(); + void emergencyPurge(); + void purgeAnItem(); + + // from talk.cpp + void talk(); + void convIcons(); + uint16 getPersFrame(uint8 index); + const uint8 *getPersonText(uint8 index, uint8 talkPos); + void startTalk(); + void moreTalk(); + void doSomeTalk(); + 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); @@ -448,11 +586,92 @@ public: void withWhat(); uint16 checkInside(uint16 command, uint16 type); void showPuzText(uint16 command, uint16 count); + void useText(const uint8 *string); + void showFirstUse(); + void showSecondUse(); + void viewFolder(); + void edensCDPlayer(); + void hotelBell(); + void playGuitar(); + void useElevator1(); + void useElevator2(); + void useElevator3(); + void useElevator4(); + void useElevator5(); + void useHatch(); + void wheelSound(); + void callHotelLift(); + void useShield(); + void useCoveredBox(); + void useRailing(); + void useChurchHole(); + void sitDownInBar(); + void useBalcony(); + void useWindow(); + void trapDoor(); + void useDryer(); + void callEdensDLift(); + void callEdensLift(); + void openYourNeighbour(); + void openRyan(); + void openPoolBoss(); + void openEden(); + void openSarters(); + void openLouis(); + void useWall(); + void useChurchGate(); + void useLadder(); + void useLadderB(); + bool defaultUseHandler(const char *id); + void slabDoorA(); + void slabDoorB(); + void slabDoorC(); + void slabDoorE(); + void slabDoorD(); + void slabDoorF(); + void useGun(); + void useFullCart(); + void useClearBox(); + void openTVDoor(); + void usePlate(); + void usePlinth(); + void useElvDoor(); + void useWinch(); + void useCart(); + void useHole(); + void openHotelDoor(); + void openHotelDoor2(); + void grafittiDoor(); + void useCardReader1(); + void useCardReader2(); + void useCardReader3(); + void usePoolReader(); + void useLighter(); + void useWire(); + void openTomb(); + void hotelControl(); + void useCooker(); + void useDiary(); + void useControl(); + void useSlab(); + void usePipe(); + void useOpenBox(); + void runTap(); + void useAxe(); + void useHandle(); + void useAltar(); + void notHeldError(); + void useCashCard(); + void useButtonA(); + void wearWatch(); + void wearShades(); + void useTrainer(); + void useStereo(); + void chewy(); + void delEverything(); + void afterIntroRoom(); // from vgafades.cpp - uint8 *mainPalette(); - uint8 *startPalette(); - uint8 *endPalette(); void clearStartPal(); void clearEndPal(); void palToStartPal(); @@ -462,8 +681,11 @@ public: void fadeDOS(); void doFade(); void fadeCalculation(); - void fadeupYellows(); - void fadeupMonFirst(); + void fadeUpYellows(); + void fadeUpMonFirst(); + void fadeUpMon(); + void fadeDownMon(); + void initialMonCols(); void fadeScreenUp(); void fadeScreenUps(); void fadeScreenUpHalf(); @@ -479,21 +701,16 @@ public: inline uint8 *workspace() { return _workspace; } void clearWork(); - uint8 getLocation(uint8 index); - void setLocation(uint8 index); - void getUnderCentre(); - void putUnderCentre(); uint8 *mapStore(); void panelToMap(); void mapToPanel(); void dumpMap(); - void transferInv(); - + void zoom(); 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); @@ -506,11 +723,11 @@ public: void showPCX(const Common::String &name); void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag); + bool pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y); void loadPalFromIFF(); void createPanel(); void createPanel2(); void showPanel(); - void entryTexts(); }; diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index a0ce29d416..66885d7623 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -26,59 +26,6 @@ namespace DreamGen { -void DreamGenContext::reminders() { - STACK_CHECK; - _cmp(data.byte(kReallocation), 24); - if (!flags.z()) - return /* (notinedenslift) */; - _cmp(data.byte(kMapx), 44); - if (!flags.z()) - return /* (notinedenslift) */; - _cmp(data.byte(kProgresspoints), 0); - if (!flags.z()) - return /* (notfirst) */; - al = 'D'; - ah = 'K'; - cl = 'E'; - ch = 'Y'; - isRyanHolding(); - if (flags.z()) - goto forgotone; - al = 'C'; - ah = 'S'; - cl = 'H'; - ch = 'R'; - findExObject(); - _cmp(al, (114)); - if (flags.z()) - goto forgotone; - ax = es.word(bx+2); - _cmp(al, 4); - if (!flags.z()) - goto forgotone; - _cmp(ah, 255); - if (flags.z()) - goto havegotcard; - cl = 'P'; - ch = 'U'; - dl = 'R'; - dh = 'S'; - _xchg(al, ah); - compare(); - if (!flags.z()) - goto forgotone; -havegotcard: - _inc(data.byte(kProgresspoints)); - return; -forgotone: - al = 50; - bl = 54; - bh = 70; - cx = 48; - dx = 8; - setupTimedUse(); -} - void DreamGenContext::transferMap() { STACK_CHECK; di = data.word(kExframepos); @@ -126,158 +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::fadeDownMon() { - STACK_CHECK; - palToStartPal(); - palToEndPal(); - es = data.word(kBuffers); - di = (0+(228*13)+32+60+(32*32)+(11*10*3)+768)+(231*3); - cx = 3*8; - ax = 0; - _stosb(cx, true); - di = (0+(228*13)+32+60+(32*32)+(11*10*3)+768)+(246*3); - _stosb(); - _stosw(); - data.byte(kFadedirection) = 1; - data.byte(kFadecount) = 63; - data.byte(kColourpos) = 0; - data.byte(kNumtofade) = 128; - cx = 64; - hangOn(); -} - -void DreamGenContext::fadeUpMon() { - STACK_CHECK; - palToStartPal(); - palToEndPal(); - es = data.word(kBuffers); - di = (0+(228*13)+32+60+(32*32)+(11*10*3))+(231*3); - cx = 3*8; - ax = 0; - _stosb(cx, true); - di = (0+(228*13)+32+60+(32*32)+(11*10*3))+(246*3); - _stosb(); - _stosw(); - data.byte(kFadedirection) = 1; - data.byte(kFadecount) = 63; - data.byte(kColourpos) = 0; - data.byte(kNumtofade) = 128; - cx = 128; - hangOn(); -} - -void DreamGenContext::initialMonCols() { - STACK_CHECK; - palToStartPal(); - es = data.word(kBuffers); - di = (0+(228*13)+32+60+(32*32)+(11*10*3))+(230*3); - cx = 3*9; - ax = 0; - _stosb(cx, true); - di = (0+(228*13)+32+60+(32*32)+(11*10*3))+(246*3); - _stosb(); - _stosw(); - ds = data.word(kBuffers); - si = (0+(228*13)+32+60+(32*32)+(11*10*3))+(230*3); - al = 230; - cx = 18; - showGroup(); -} - void DreamGenContext::fillOpen() { STACK_CHECK; delTextLine(); @@ -395,302 +190,6 @@ findopen2a: goto findopen1a; } -void DreamGenContext::incRyanPage() { - STACK_CHECK; - _cmp(data.byte(kCommandtype), 222); - if (flags.z()) - goto alreadyincryan; - data.byte(kCommandtype) = 222; - al = 31; - commandOnly(); -alreadyincryan: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (noincryan) */; - _and(ax, 1); - if (!flags.z()) - goto doincryan; - return; -doincryan: - ax = data.word(kMousex); - _sub(ax, (80)+167); - data.byte(kRyanpage) = -1; -findnewpage: - _inc(data.byte(kRyanpage)); - _sub(ax, 18); - if (!flags.c()) - goto findnewpage; - delPointer(); - fillRyan(); - readMouse(); - showPointer(); - workToScreen(); - delPointer(); -} - -void DreamGenContext::getObTextStart() { - STACK_CHECK; - es = data.word(kFreedesc); - si = (0); - cx = (0+(82*2)); - _cmp(data.byte(kObjecttype), 2); - if (flags.z()) - goto describe; - es = data.word(kSetdesc); - si = (0); - cx = (0+(130*2)); - _cmp(data.byte(kObjecttype), 1); - if (flags.z()) - goto describe; - es = data.word(kExtras); - si = (0+2080+30000+(16*114)); - cx = (0+2080+30000+(16*114)+((114+2)*2)); -describe: - al = data.byte(kCommand); - ah = 0; - _add(ax, ax); - _add(si, ax); - ax = es.word(si); - _add(ax, cx); - si = ax; - bx = ax; -tryagain: - push(si); - findNextColon(); - al = es.byte(si); - cx = si; - si = pop(); - _cmp(data.byte(kObjecttype), 1); - if (!flags.z()) - return /* (cantmakeoneup) */; - _cmp(al, 0); - if (flags.z()) - goto findsometext; - _cmp(al, ':'); - if (flags.z()) - goto findsometext; - return; -findsometext: - searchForSame(); - goto tryagain; -} - -void DreamGenContext::searchForSame() { - STACK_CHECK; - si = cx; -searchagain: - _inc(si); - al = es.byte(bx); -search: - _cmp(es.byte(si), al); - if (flags.z()) - goto gotstartletter; - _inc(cx); - _inc(si); - _cmp(si, 8000); - if (flags.c()) - goto search; - si = bx; - ax = pop(); - return; -gotstartletter: - push(bx); - push(si); -keepchecking: - _inc(si); - _inc(bx); - al = es.byte(bx); - ah = es.byte(si); - _cmp(al, ':'); - if (flags.z()) - goto foundmatch; - _cmp(al, 0); - if (flags.z()) - goto foundmatch; - _cmp(al, ah); - if (flags.z()) - goto keepchecking; - si = pop(); - bx = pop(); - goto searchagain; -foundmatch: - si = pop(); - bx = pop(); -} - -void DreamGenContext::reExFromInv() { - STACK_CHECK; - findInvPos(); - ax = es.word(bx); - data.byte(kCommandtype) = ah; - data.byte(kCommand) = al; - data.byte(kExamagain) = 1; - data.byte(kPointermode) = 0; -} - -void DreamGenContext::swapWithInv() { - STACK_CHECK; - al = data.byte(kItemframe); - ah = data.byte(kObjecttype); - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub7; - _cmp(data.byte(kCommandtype), 243); - if (flags.z()) - goto alreadyswap1; - data.byte(kCommandtype) = 243; -difsub7: - data.word(kOldsubject) = ax; - bx = ax; - al = 34; - commandWithOb(); -alreadyswap1: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (cantswap1) */; - _and(ax, 1); - if (!flags.z()) - goto doswap1; - return; -doswap1: - ah = data.byte(kObjecttype); - al = data.byte(kItemframe); - push(ax); - findInvPos(); - ax = es.word(bx); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = ah; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; - bl = data.byte(kItemframe); - bh = data.byte(kObjecttype); - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - push(bx); - findInvPos(); - delPointer(); - al = data.byte(kItemframe); - getEitherAd(); - es.byte(bx+2) = 4; - es.byte(bx+3) = 255; - al = data.byte(kLastinvpos); - es.byte(bx+4) = al; - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - fillRyan(); - readMouse(); - showPointer(); - workToScreen(); - delPointer(); -} - -void DreamGenContext::swapWithOpen() { - STACK_CHECK; - al = data.byte(kItemframe); - ah = data.byte(kObjecttype); - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub8; - _cmp(data.byte(kCommandtype), 242); - if (flags.z()) - goto alreadyswap2; - data.byte(kCommandtype) = 242; -difsub8: - data.word(kOldsubject) = ax; - bx = ax; - al = 34; - commandWithOb(); -alreadyswap2: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (cantswap2) */; - _and(ax, 1); - if (!flags.z()) - goto doswap2; - return; -doswap2: - getEitherAd(); - isItWorn(); - if (!flags.z()) - goto notwornswap; - wornError(); - return; -notwornswap: - delPointer(); - al = data.byte(kItemframe); - _cmp(al, data.byte(kOpenedob)); - if (!flags.z()) - goto isntsame2; - al = data.byte(kObjecttype); - _cmp(al, data.byte(kOpenedtype)); - if (!flags.z()) - goto isntsame2; - errorMessage1(); - return; -isntsame2: - checkObjectSize(); - _cmp(al, 0); - if (flags.z()) - goto sizeok2; - return; -sizeok2: - ah = data.byte(kObjecttype); - al = data.byte(kItemframe); - push(ax); - findOpenPos(); - ax = es.word(bx); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = ah; - _cmp(ah, 4); - if (!flags.z()) - goto makeswapex; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; - goto actuallyswap; -makeswapex: - transferToEx(); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = 4; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; -actuallyswap: - bl = data.byte(kItemframe); - bh = data.byte(kObjecttype); - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - push(bx); - findOpenPos(); - getEitherAd(); - al = data.byte(kOpenedtype); - es.byte(bx+2) = al; - al = data.byte(kOpenedob); - es.byte(bx+3) = al; - al = data.byte(kLastinvpos); - es.byte(bx+4) = al; - al = data.byte(kReallocation); - es.byte(bx+5) = al; - ax = pop(); - data.byte(kObjecttype) = ah; - data.byte(kItemframe) = al; - fillOpen(); - fillRyan(); - underTextLine(); - readMouse(); - useOpened(); - showPointer(); - workToScreen(); - delPointer(); -} - void DreamGenContext::getFreeAd() { STACK_CHECK; ah = 0; @@ -710,19 +209,6 @@ void DreamGenContext::getExAd() { _add(bx, (0+2080+30000)); } -void DreamGenContext::getEitherAd() { - STACK_CHECK; - _cmp(data.byte(kObjecttype), 4); - if (flags.z()) - goto isinexlist; - al = data.byte(kItemframe); - getFreeAd(); - return; -isinexlist: - al = data.byte(kItemframe); - getExAd(); -} - void DreamGenContext::getAnyAd() { STACK_CHECK; _cmp(data.byte(kObjecttype), 4); @@ -755,382 +241,6 @@ void DreamGenContext::getSetAd() { es = data.word(kSetdat); } -void DreamGenContext::findOpenPos() { - STACK_CHECK; - cx = data.word(kMousex); - _sub(cx, (80)); - bx = -1; -findopenp1: - _inc(bx); - _sub(cx, (44)); - if (!flags.c()) - goto findopenp1; - al = bl; - data.byte(kLastinvpos) = al; - _add(bx, bx); - es = data.word(kBuffers); - _add(bx, (0+(228*13))); -} - -void DreamGenContext::dropObject() { - STACK_CHECK; - _cmp(data.byte(kCommandtype), 223); - if (flags.z()) - goto alreadydrop; - data.byte(kCommandtype) = 223; - _cmp(data.byte(kPickup), 0); - if (flags.z()) - { blank(); return; }; - bl = data.byte(kItemframe); - bh = data.byte(kObjecttype); - al = 37; - commandWithOb(); -alreadydrop: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (nodrop) */; - _and(ax, 1); - if (!flags.z()) - goto dodrop; - return; -dodrop: - getEitherAd(); - isItWorn(); - if (!flags.z()) - goto nowornerror; - wornError(); - return; -nowornerror: - _cmp(data.byte(kReallocation), 47); - if (flags.z()) - goto nodrop2; - cl = data.byte(kRyanx); - _add(cl, 12); - ch = data.byte(kRyany); - _add(ch, 12); - checkOne(); - _cmp(cl, 2); - if (flags.c()) - goto nodroperror; -nodrop2: - dropError(); - return; -nodroperror: - _cmp(data.byte(kMapxsize), 64); - if (!flags.z()) - goto notinlift; - _cmp(data.byte(kMapysize), 64); - if (!flags.z()) - goto notinlift; - dropError(); - return; -notinlift: - al = data.byte(kItemframe); - ah = 4; - cl = 'G'; - ch = 'U'; - dl = 'N'; - dh = 'A'; - compare(); - if (flags.z()) - { cantDrop(); return; }; - al = data.byte(kItemframe); - ah = 4; - cl = 'S'; - ch = 'H'; - dl = 'L'; - dh = 'D'; - compare(); - if (flags.z()) - { cantDrop(); return; }; - data.byte(kObjecttype) = 4; - al = data.byte(kItemframe); - getExAd(); - es.byte(bx+2) = 0; - al = data.byte(kRyanx); - _add(al, 4); - cl = 4; - _shr(al, cl); - _add(al, data.byte(kMapx)); - ah = data.byte(kRyany); - _add(ah, 8); - cl = 4; - _shr(ah, cl); - _add(ah, data.byte(kMapy)); - es.byte(bx+3) = al; - es.byte(bx+5) = ah; - al = data.byte(kRyanx); - _add(al, 4); - _and(al, 15); - ah = data.byte(kRyany); - _add(ah, 8); - _and(ah, 15); - es.byte(bx+4) = al; - es.byte(bx+6) = ah; - data.byte(kPickup) = 0; - al = data.byte(kReallocation); - es.byte(bx) = al; -} - -void DreamGenContext::selectOpenOb() { - STACK_CHECK; - al = data.byte(kCommand); - getAnyAd(); - _cmp(al, 255); - if (!flags.z()) - goto canopenit1; - blank(); - return; -canopenit1: - _cmp(data.byte(kCommandtype), 224); - if (flags.z()) - goto alreadyopob; - data.byte(kCommandtype) = 224; - bl = data.byte(kCommand); - bh = data.byte(kObjecttype); - al = 38; - commandWithOb(); -alreadyopob: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (noopenob) */; - _and(ax, 1); - if (!flags.z()) - goto doopenob; - return; -doopenob: - al = data.byte(kCommand); - data.byte(kOpenedob) = al; - al = data.byte(kObjecttype); - data.byte(kOpenedtype) = al; - createPanel(); - showPanel(); - showMan(); - examIcon(); - showExit(); - openInv(); - openOb(); - underTextLine(); - readMouse(); - showPointer(); - workToScreen(); - delPointer(); -} - -void DreamGenContext::useOpened() { - STACK_CHECK; - _cmp(data.byte(kOpenedob), 255); - if (flags.z()) - return /* (cannotuseopen) */; - _cmp(data.byte(kPickup), 0); - if (!flags.z()) - goto notout2; - outOfOpen(); - return; -notout2: - findOpenPos(); - ax = es.word(bx); - _cmp(al, 255); - if (flags.z()) - goto canplace3; - swapWithOpen(); - return; -canplace3: - _cmp(data.byte(kPickup), 1); - if (flags.z()) - goto intoopen; - blank(); - return; -intoopen: - al = data.byte(kItemframe); - ah = data.byte(kObjecttype); - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub2; - _cmp(data.byte(kCommandtype), 227); - if (flags.z()) - goto alreadyplc2; - data.byte(kCommandtype) = 227; -difsub2: - data.word(kOldsubject) = ax; - bx = ax; - al = 35; - commandWithOb(); -alreadyplc2: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (notletgo3) */; - _cmp(ax, 1); - if (flags.z()) - goto doplace2; - return; -doplace2: - getEitherAd(); - isItWorn(); - if (!flags.z()) - goto notworntoopen; - wornError(); - return; -notworntoopen: - delPointer(); - al = data.byte(kItemframe); - _cmp(al, data.byte(kOpenedob)); - if (!flags.z()) - goto isntsame; - al = data.byte(kObjecttype); - _cmp(al, data.byte(kOpenedtype)); - if (!flags.z()) - goto isntsame; - errorMessage1(); - return; -isntsame: - checkObjectSize(); - _cmp(al, 0); - if (flags.z()) - goto sizeok1; - return; -sizeok1: - data.byte(kPickup) = 0; - al = data.byte(kItemframe); - getEitherAd(); - al = data.byte(kOpenedtype); - es.byte(bx+2) = al; - al = data.byte(kOpenedob); - es.byte(bx+3) = al; - al = data.byte(kLastinvpos); - es.byte(bx+4) = al; - al = data.byte(kReallocation); - es.byte(bx+5) = al; - fillOpen(); - underTextLine(); - readMouse(); - useOpened(); - showPointer(); - workToScreen(); - delPointer(); -} - -void DreamGenContext::checkObjectSize() { - STACK_CHECK; - getOpenedSize(); - push(ax); - al = data.byte(kItemframe); - getEitherAd(); - al = es.byte(bx+9); - cx = pop(); - _cmp(al, 255); - if (!flags.z()) - goto notunsized; - al = 6; -notunsized: - _cmp(al, 100); - if (!flags.c()) - goto specialcase; - _cmp(cl, 100); - if (flags.c()) - goto isntspecial; - errorMessage3(); - goto sizewrong; -isntspecial: - _cmp(cl, al); - if (!flags.c()) - goto sizeok; -specialcase: - _sub(al, 100); - _cmp(cl, 100); - if (!flags.c()) - goto bothspecial; - _cmp(cl, al); - if (!flags.c()) - goto sizeok; - errorMessage2(); - goto sizewrong; -bothspecial: - _sub(cl, 100); - _cmp(al, cl); - if (flags.z()) - goto sizeok; - errorMessage3(); -sizewrong: - al = 1; - return; -sizeok: - al = 0; -} - -void DreamGenContext::outOfOpen() { - STACK_CHECK; - _cmp(data.byte(kOpenedob), 255); - if (flags.z()) - goto cantuseopen; - findOpenPos(); - ax = es.word(bx); - _cmp(al, 255); - if (!flags.z()) - goto canpick4; -cantuseopen: - blank(); - return; -canpick4: - _cmp(ax, data.word(kOldsubject)); - if (!flags.z()) - goto difsub4; - _cmp(data.byte(kCommandtype), 228); - if (flags.z()) - goto alreadygrb; - data.byte(kCommandtype) = 228; -difsub4: - data.word(kOldsubject) = ax; - bx = ax; - al = 36; - commandWithOb(); -alreadygrb: - ax = data.word(kMousebutton); - _cmp(ax, data.word(kOldbutton)); - if (flags.z()) - return /* (notletgo4) */; - _cmp(ax, 1); - if (flags.z()) - goto dogrb; - _cmp(ax, 2); - if (!flags.z()) - return /* (notletgo4) */; - reExFromOpen(); - return; -dogrb: - delPointer(); - data.byte(kPickup) = 1; - findOpenPos(); - ax = es.word(bx); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = ah; - _cmp(ah, 4); - if (!flags.z()) - goto makeintoex; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; - goto actuallyout; -makeintoex: - transferToEx(); - data.byte(kItemframe) = al; - data.byte(kObjecttype) = 4; - getEitherAd(); - es.byte(bx+2) = 20; - es.byte(bx+3) = 255; -actuallyout: - fillOpen(); - underTextLine(); - readMouse(); - useOpened(); - showPointer(); - workToScreen(); - delPointer(); -} - void DreamGenContext::transferToEx() { STACK_CHECK; emergencyPurge(); @@ -1241,418 +351,6 @@ void DreamGenContext::transferConToEx() { ds.byte(si+2) = 255; } -void DreamGenContext::purgeALocation() { - STACK_CHECK; - push(ax); - es = data.word(kExtras); - di = (0+2080+30000); - bx = pop(); - cx = 0; -purgeloc: - _cmp(bl, es.byte(di+0)); - if (!flags.z()) - goto dontpurge; - _cmp(es.byte(di+2), 0); - if (!flags.z()) - goto dontpurge; - push(di); - push(es); - push(bx); - push(cx); - deleteExObject(); - cx = pop(); - bx = pop(); - es = pop(); - di = pop(); -dontpurge: - _add(di, 16); - _inc(cx); - _cmp(cx, (114)); - if (!flags.z()) - goto purgeloc; -} - -void DreamGenContext::emergencyPurge() { - STACK_CHECK; -checkpurgeagain: - ax = data.word(kExframepos); - _add(ax, 4000); - _cmp(ax, (30000)); - if (flags.c()) - goto notnearframeend; - purgeAnItem(); - goto checkpurgeagain; -notnearframeend: - ax = data.word(kExtextpos); - _add(ax, 400); - _cmp(ax, (18000)); - if (flags.c()) - return /* (notneartextend) */; - purgeAnItem(); - goto checkpurgeagain; -} - -void DreamGenContext::purgeAnItem() { - STACK_CHECK; - es = data.word(kExtras); - di = (0+2080+30000); - bl = data.byte(kReallocation); - cx = 0; -lookforpurge: - al = es.byte(di+2); - _cmp(al, 0); - if (!flags.z()) - goto cantpurge; - _cmp(es.byte(di+12), 2); - if (flags.z()) - goto iscup; - _cmp(es.byte(di+12), 255); - if (!flags.z()) - goto cantpurge; -iscup: - _cmp(es.byte(di+11), bl); - if (flags.z()) - goto cantpurge; - deleteExObject(); - return; -cantpurge: - _add(di, 16); - _inc(cx); - _cmp(cx, (114)); - if (!flags.z()) - goto lookforpurge; - di = (0+2080+30000); - bl = data.byte(kReallocation); - cx = 0; -lookforpurge2: - al = es.byte(di+2); - _cmp(al, 0); - if (!flags.z()) - goto cantpurge2; - _cmp(es.byte(di+12), 255); - if (!flags.z()) - goto cantpurge2; - deleteExObject(); - return; -cantpurge2: - _add(di, 16); - _inc(cx); - _cmp(cx, (114)); - if (!flags.z()) - goto lookforpurge2; -} - -void DreamGenContext::startTalk() { - STACK_CHECK; - data.byte(kTalkmode) = 0; - al = data.byte(kCharacter); - _and(al, 127); - getPersonText(); - data.word(kCharshift) = 91+91; - di = 66; - bx = 64; - dl = 241; - al = 0; - ah = 79; - printDirect(); - data.word(kCharshift) = 0; - di = 66; - bx = 80; - dl = 241; - al = 0; - ah = 0; - printDirect(); - data.byte(kSpeechloaded) = 0; - al = data.byte(kCharacter); - _and(al, 127); - ah = 0; - cx = 64; - _mul(cx); - cl = 'C'; - dl = 'R'; - dh = data.byte(kReallocation); - loadSpeech(); - _cmp(data.byte(kSpeechloaded), 1); - if (!flags.z()) - return /* (nospeech1) */; - data.byte(kVolumedirection) = 1; - data.byte(kVolumeto) = 6; - al = 50+12; - playChannel1(); -} - -void DreamGenContext::getPersonText() { - STACK_CHECK; - ah = 0; - cx = 64*2; - _mul(cx); - si = ax; - es = data.word(kPeople); - _add(si, (0+24)); - cx = (0+24+(1026*2)); - ax = es.word(si); - _add(ax, cx); - si = ax; -} - -void DreamGenContext::doSomeTalk() { - STACK_CHECK; -dospeech: - al = data.byte(kTalkpos); - al = data.byte(kCharacter); - _and(al, 127); - ah = 0; - cx = 64; - _mul(cx); - cx = ax; - al = data.byte(kTalkpos); - ah = 0; - _add(ax, cx); - _add(ax, ax); - si = ax; - es = data.word(kPeople); - _add(si, (0+24)); - cx = (0+24+(1026*2)); - ax = es.word(si); - _add(ax, cx); - si = ax; - _cmp(es.byte(si), 0); - if (flags.z()) - goto endheartalk; - push(es); - push(si); - createPanel(); - showPanel(); - showMan(); - showExit(); - convIcons(); - si = pop(); - es = pop(); - di = 164; - bx = 64; - dl = 144; - al = 0; - ah = 0; - printDirect(); - al = data.byte(kCharacter); - _and(al, 127); - ah = 0; - cx = 64; - _mul(cx); - cl = data.byte(kTalkpos); - ch = 0; - _add(ax, cx); - cl = 'C'; - dl = 'R'; - dh = data.byte(kReallocation); - loadSpeech(); - _cmp(data.byte(kSpeechloaded), 0); - if (flags.z()) - goto noplay1; - al = 62; - playChannel1(); -noplay1: - data.byte(kPointermode) = 3; - workToScreenM(); - cx = 180; - hangOnPQ(); - if (!flags.c()) - goto _tmp1; - return; -_tmp1: - _inc(data.byte(kTalkpos)); - al = data.byte(kTalkpos); - al = data.byte(kCharacter); - _and(al, 127); - ah = 0; - cx = 64; - _mul(cx); - cx = ax; - al = data.byte(kTalkpos); - ah = 0; - _add(ax, cx); - _add(ax, ax); - si = ax; - es = data.word(kPeople); - _add(si, (0+24)); - cx = (0+24+(1026*2)); - ax = es.word(si); - _add(ax, cx); - si = ax; - _cmp(es.byte(si), 0); - if (flags.z()) - goto endheartalk; - _cmp(es.byte(si), ':'); - if (flags.z()) - goto skiptalk2; - _cmp(es.byte(si), 32); - if (flags.z()) - goto skiptalk2; - push(es); - push(si); - createPanel(); - showPanel(); - showMan(); - showExit(); - convIcons(); - si = pop(); - es = pop(); - di = 48; - bx = 128; - dl = 144; - al = 0; - ah = 0; - printDirect(); - al = data.byte(kCharacter); - _and(al, 127); - ah = 0; - cx = 64; - _mul(cx); - cl = data.byte(kTalkpos); - ch = 0; - _add(ax, cx); - cl = 'C'; - dl = 'R'; - dh = data.byte(kReallocation); - loadSpeech(); - _cmp(data.byte(kSpeechloaded), 0); - if (flags.z()) - goto noplay2; - al = 62; - playChannel1(); -noplay2: - data.byte(kPointermode) = 3; - workToScreenM(); - cx = 180; - hangOnPQ(); - if (!flags.c()) - goto skiptalk2; - return; -skiptalk2: - _inc(data.byte(kTalkpos)); - goto dospeech; -endheartalk: - data.byte(kPointermode) = 0; -} - -void DreamGenContext::locationPic() { - STACK_CHECK; - getDestInfo(); - al = es.byte(si); - push(es); - push(si); - di = 0; - _cmp(al, 6); - if (!flags.c()) - goto secondlot; - ds = data.word(kTempgraphics); - _add(al, 4); - goto gotgraphic; -secondlot: - _sub(al, 6); - ds = data.word(kTempgraphics2); -gotgraphic: - _add(di, 104); - bx = 138+14; - ah = 0; - showFrame(); - si = pop(); - es = pop(); - al = data.byte(kDestpos); - _cmp(al, data.byte(kReallocation)); - if (!flags.z()) - goto notinthisone; - al = 3; - di = 104; - bx = 140+14; - ds = data.word(kTempgraphics); - ah = 0; - showFrame(); -notinthisone: - bl = data.byte(kDestpos); - bh = 0; - _add(bx, bx); - es = data.word(kTraveltext); - si = es.word(bx); - _add(si, (66*2)); - di = 50; - bx = 20; - dl = 241; - al = 0; - ah = 0; - printDirect(); -} - -void DreamGenContext::getDestInfo() { - STACK_CHECK; - al = data.byte(kDestpos); - ah = 0; - push(ax); - dx = data; - es = dx; - si = 555; - _add(si, ax); - cl = es.byte(si); - ax = pop(); - push(cx); - dx = data; - es = dx; - si = 571; - _add(si, ax); - ax = pop(); -} - -void DreamGenContext::resetLocation() { - STACK_CHECK; - push(ax); - _cmp(al, 5); - if (!flags.z()) - goto notdelhotel; - purgeALocation(); - al = 21; - purgeALocation(); - al = 22; - purgeALocation(); - al = 27; - purgeALocation(); - goto clearedlocations; -notdelhotel: - _cmp(al, 8); - if (!flags.z()) - goto notdeltvstud; - purgeALocation(); - al = 28; - purgeALocation(); - goto clearedlocations; -notdeltvstud: - _cmp(al, 6); - if (!flags.z()) - goto notdelsarters; - purgeALocation(); - al = 20; - purgeALocation(); - al = 25; - purgeALocation(); - goto clearedlocations; -notdelsarters: - _cmp(al, 13); - if (!flags.z()) - goto notdelboathouse; - purgeALocation(); - al = 29; - purgeALocation(); - goto clearedlocations; -notdelboathouse: -clearedlocations: - ax = pop(); - ah = 0; - bx = ax; - dx = data; - es = dx; - _add(bx, 555); - es.byte(bx) = 0; -} - void DreamGenContext::dirCom() { STACK_CHECK; cx = 30; @@ -1669,7 +367,7 @@ dirroot: si = offset_rootdir; _inc(si); es = cs; - di = 480; + di = 462; _inc(di); cx = 12; _movsb(cx, true); @@ -1686,22 +384,6 @@ dirroot: scrollMonitor(); } -void DreamGenContext::searchForFiles() { - STACK_CHECK; - bx = (66*2); -directloop1: - al = es.byte(bx); - _inc(bx); - _cmp(al, '*'); - if (flags.z()) - return /* (endofdir) */; - _cmp(al, 34); - if (!flags.z()) - goto directloop1; - monPrint(); - goto directloop1; -} - void DreamGenContext::read() { STACK_CHECK; cx = 40; @@ -1714,7 +396,7 @@ void DreamGenContext::read() { return; okcom: es = cs; - di = 480; + di = 462; ax = data.word(kTextfile1); data.word(kMonsource) = ax; ds = ax; @@ -1844,7 +526,7 @@ keyok2: ds = cs; si = offset_operand1+1; es = cs; - di = 480+1; + di = 462+1; cx = 12; _movsb(cx, true); monitorLogo(); @@ -1926,7 +608,7 @@ void DreamGenContext::parser() { al = '='; _stosb(); ds = cs; - si = 589; + si = 556; notspace1: _lodsw(); _cmp(al, 32); @@ -1954,93 +636,6 @@ finishpars: di = offset_operand1; } -void DreamGenContext::findPathOfPoint() { - STACK_CHECK; - push(ax); - bx = (0); - es = data.word(kReels); - al = data.byte(kRoomnum); - ah = 0; - cx = 144; - _mul(cx); - _add(bx, ax); - cx = pop(); - dl = 0; -pathloop: - al = es.byte(bx+6); - _cmp(al, 255); - if (!flags.z()) - goto flunkedit; - ax = es.word(bx+2); - _cmp(ax, 0x0ffff); - if (flags.z()) - goto flunkedit; - _cmp(cl, al); - if (flags.c()) - goto flunkedit; - _cmp(ch, ah); - if (flags.c()) - goto flunkedit; - ax = es.word(bx+4); - _cmp(cl, al); - if (!flags.c()) - goto flunkedit; - _cmp(ch, ah); - if (!flags.c()) - goto flunkedit; - return /* (gotvalidpath) */; -flunkedit: - _add(bx, 8); - _inc(dl); - _cmp(dl, 12); - if (!flags.z()) - goto pathloop; - dl = 255; -} - -void DreamGenContext::findFirstPath() { - STACK_CHECK; - push(ax); - bx = (0); - es = data.word(kReels); - al = data.byte(kRoomnum); - ah = 0; - cx = 144; - _mul(cx); - _add(bx, ax); - cx = pop(); - dl = 0; -fpathloop: - ax = es.word(bx+2); - _cmp(ax, 0x0ffff); - if (flags.z()) - goto nofirst; - _cmp(cl, al); - if (flags.c()) - goto nofirst; - _cmp(ch, ah); - if (flags.c()) - goto nofirst; - ax = es.word(bx+4); - _cmp(cl, al); - if (!flags.c()) - goto nofirst; - _cmp(ch, ah); - if (!flags.c()) - goto nofirst; - goto gotfirst; -nofirst: - _add(bx, 8); - _inc(dl); - _cmp(dl, 12); - if (!flags.z()) - goto fpathloop; - al = 0; - return; -gotfirst: - al = es.byte(bx+6); -} - void DreamGenContext::__start() { static const uint8 src[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -2063,14 +658,14 @@ void DreamGenContext::__start() { //0x0080: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0090: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00a0: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00b0: .... .... .... .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, + //0x00c0: .... .... ... ... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x00c0: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, - //0x00d0: .... .... .... . . + //0x00d0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00e0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -2085,37 +680,37 @@ void DreamGenContext::__start() { //0x0130: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0140: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, //0x0150: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0160: .... .... .... .... 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0170: .... .... .... .... - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0180: .... .... .... .... - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, //0x0190: .... .... .... .... + 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, 0x57, 0x45, 0x42, 0x2e, 0x56, 0x39, + //0x01a0: .... .DRE AMWE B.V9 + 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, + //0x01b0: 9. . + 0x22, 0x52, 0x4f, 0x4f, 0x54, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x22, 0x20, + //0x01c0: "ROO T ." + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x0d, 0x0a, 0x0d, 0x0a, + //0x01d0: . .... + 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + //0x01e0: $... .... .... .... + 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x01f0: .... .... .D:. .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x01a0: .... .... .... .... - 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, 0x57, 0x45, 0x42, 0x2e, - //0x01b0: .... ...D REAM WEB. - 0x56, 0x39, 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - //0x01c0: V99. - 0x20, 0x00, 0x22, 0x52, 0x4f, 0x4f, 0x54, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, - //0x01d0: ."R OOT . - 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x0d, 0x0a, - //0x01e0: " ... - 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - //0x01f0: ..$. .... .... .... - 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, 0x3a, 0x00, 0x00, 0x00, - //0x0200: .... .... ...D :... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x0200: .... .... .... .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, //0x0210: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0220: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x02, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0230: .... .... .... .... - 0x01, 0x0a, 0x09, 0x08, 0x06, 0x0b, 0x04, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0240: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0250: .... .... .... .... @@ -2127,13 +722,9 @@ void DreamGenContext::__start() { //0x0280: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0290: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, //0x02a0: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x02b0: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, - //0x02c0: .... .... .... .... - 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, }; + 0xff, 0xff, 0x00, 0x00, 0x00, }; ds.assign(src, src + sizeof(src)); dreamweb(); } diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index b13d150ad4..3d98f294ce 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -32,8 +32,8 @@ namespace DreamGen { -static const uint16 offset_operand1 = 0x01c4; -static const uint16 offset_rootdir = 0x01d2; +static const uint16 offset_operand1 = 0x01b2; +static const uint16 offset_rootdir = 0x01c0; static const uint16 kStartvars = 0; static const uint16 kProgresspoints = 1; static const uint16 kWatchon = 2; @@ -156,214 +156,202 @@ static const uint16 kNewscreen = 149; static const uint16 kRyanx = 150; static const uint16 kRyany = 151; static const uint16 kLastflag = 152; -static const uint16 kCurrentex = 153; -static const uint16 kCurrentfree = 154; -static const uint16 kFramesad = 155; -static const uint16 kDataad = 157; -static const uint16 kFrsegment = 159; -static const uint16 kObjectx = 161; -static const uint16 kObjecty = 163; -static const uint16 kOffsetx = 165; -static const uint16 kOffsety = 167; -static const uint16 kSavesize = 169; -static const uint16 kSavesource = 171; -static const uint16 kSavex = 173; -static const uint16 kSavey = 174; -static const uint16 kCurrentob = 175; -static const uint16 kPrioritydep = 176; -static const uint16 kDestpos = 177; -static const uint16 kReallocation = 178; -static const uint16 kRoomnum = 179; -static const uint16 kNowinnewroom = 180; -static const uint16 kResetmanxy = 181; -static const uint16 kNewlocation = 182; -static const uint16 kAutolocation = 183; -static const uint16 kMustload = 184; -static const uint16 kAnswered = 185; -static const uint16 kSaidno = 186; -static const uint16 kDoorcheck1 = 187; -static const uint16 kDoorcheck2 = 188; -static const uint16 kDoorcheck3 = 189; -static const uint16 kDoorcheck4 = 190; -static const uint16 kMousex = 191; -static const uint16 kMousey = 193; -static const uint16 kMousebutton = 195; -static const uint16 kMousebutton1 = 197; -static const uint16 kMousebutton2 = 199; -static const uint16 kMousebutton3 = 201; -static const uint16 kMousebutton4 = 203; -static const uint16 kOldbutton = 205; -static const uint16 kOldx = 207; -static const uint16 kOldy = 209; -static const uint16 kLastbutton = 211; -static const uint16 kOldpointerx = 213; -static const uint16 kOldpointery = 215; -static const uint16 kDelherex = 217; -static const uint16 kDelherey = 219; -static const uint16 kPointerxs = 221; -static const uint16 kPointerys = 222; -static const uint16 kDelxs = 223; -static const uint16 kDelys = 224; -static const uint16 kPointerframe = 225; -static const uint16 kPointerpower = 226; -static const uint16 kAuxpointerframe = 227; -static const uint16 kPointermode = 228; -static const uint16 kPointerspeed = 229; -static const uint16 kPointercount = 230; -static const uint16 kInmaparea = 231; -static const uint16 kSlotdata = 232; -static const uint16 kThisslot = 233; -static const uint16 kSlotflags = 234; -static const uint16 kTalkmode = 235; -static const uint16 kTalkpos = 236; -static const uint16 kCharacter = 237; -static const uint16 kPersondata = 238; -static const uint16 kTalknum = 240; -static const uint16 kNumberinroom = 241; -static const uint16 kCurrentcel = 242; -static const uint16 kOldselection = 243; -static const uint16 kStopwalking = 244; -static const uint16 kMouseon = 245; -static const uint16 kPlayed = 246; -static const uint16 kTimer1 = 248; -static const uint16 kTimer2 = 249; -static const uint16 kTimer3 = 250; -static const uint16 kWholetimer = 251; -static const uint16 kTimer1to = 253; -static const uint16 kTimer2to = 254; -static const uint16 kTimer3to = 255; -static const uint16 kWatchdump = 256; -static const uint16 kLogonum = 257; -static const uint16 kOldlogonum = 258; -static const uint16 kNetseg = 259; -static const uint16 kNetpoint = 261; -static const uint16 kCursorstate = 263; -static const uint16 kPressed = 264; -static const uint16 kPresspointer = 265; -static const uint16 kGraphicpress = 267; -static const uint16 kPresscount = 268; -static const uint16 kLightcount = 269; -static const uint16 kFolderpage = 270; -static const uint16 kDiarypage = 271; -static const uint16 kMenucount = 272; -static const uint16 kSymboltopx = 273; -static const uint16 kSymboltopnum = 274; -static const uint16 kSymboltopdir = 275; -static const uint16 kSymbolbotx = 276; -static const uint16 kSymbolbotnum = 277; -static const uint16 kSymbolbotdir = 278; -static const uint16 kSymboltolight = 279; -static const uint16 kSymbol1 = 280; -static const uint16 kSymbol2 = 281; -static const uint16 kSymbol3 = 282; -static const uint16 kSymbolnum = 283; -static const uint16 kDumpx = 284; -static const uint16 kDumpy = 286; -static const uint16 kWalkandexam = 288; -static const uint16 kWalkexamtype = 289; -static const uint16 kWalkexamnum = 290; -static const uint16 kCurslocx = 291; -static const uint16 kCurslocy = 293; -static const uint16 kCurpos = 295; -static const uint16 kMonadx = 297; -static const uint16 kMonady = 299; -static const uint16 kMonsource = 301; -static const uint16 kNumtodo = 303; -static const uint16 kTimecount = 305; -static const uint16 kCounttotimed = 307; -static const uint16 kTimedseg = 309; -static const uint16 kTimedoffset = 311; -static const uint16 kTimedy = 313; -static const uint16 kTimedx = 314; -static const uint16 kNeedtodumptimed = 315; -static const uint16 kLoadingorsave = 316; -static const uint16 kCurrentslot = 317; -static const uint16 kCursorpos = 318; -static const uint16 kColourpos = 319; -static const uint16 kFadedirection = 320; -static const uint16 kNumtofade = 321; -static const uint16 kFadecount = 322; -static const uint16 kAddtogreen = 323; -static const uint16 kAddtored = 324; -static const uint16 kAddtoblue = 325; -static const uint16 kLastsoundreel = 326; -static const uint16 kSpeechloaded = 328; -static const uint16 kSpeechlength = 329; -static const uint16 kVolume = 331; -static const uint16 kVolumeto = 332; -static const uint16 kVolumedirection = 333; -static const uint16 kVolumecount = 334; -static const uint16 kWongame = 335; -static const uint16 kLasthardkey = 336; -static const uint16 kBufferin = 337; -static const uint16 kBufferout = 339; -static const uint16 kExtras = 341; -static const uint16 kWorkspace = 343; -static const uint16 kMapstore = 345; -static const uint16 kCharset1 = 347; -static const uint16 kBuffers = 349; -static const uint16 kMainsprites = 351; -static const uint16 kBackdrop = 353; -static const uint16 kMapdata = 355; -static const uint16 kSounddata = 357; -static const uint16 kSounddata2 = 359; -static const uint16 kRecordspace = 361; -static const uint16 kFreedat = 363; -static const uint16 kSetdat = 365; -static const uint16 kReel1 = 367; -static const uint16 kReel2 = 369; -static const uint16 kReel3 = 371; -static const uint16 kRoomdesc = 373; -static const uint16 kFreedesc = 375; -static const uint16 kSetdesc = 377; -static const uint16 kBlockdesc = 379; -static const uint16 kSetframes = 381; -static const uint16 kFreeframes = 383; -static const uint16 kPeople = 385; -static const uint16 kReels = 387; -static const uint16 kCommandtext = 389; -static const uint16 kPuzzletext = 391; -static const uint16 kTraveltext = 393; -static const uint16 kTempgraphics = 395; -static const uint16 kTempgraphics2 = 397; -static const uint16 kTempgraphics3 = 399; -static const uint16 kTempsprites = 401; -static const uint16 kTextfile1 = 403; -static const uint16 kTextfile2 = 405; -static const uint16 kTextfile3 = 407; -static const uint16 kBlinkframe = 409; -static const uint16 kBlinkcount = 410; -static const uint16 kReasseschanges = 411; -static const uint16 kPointerspath = 412; -static const uint16 kManspath = 413; -static const uint16 kPointerfirstpath = 414; -static const uint16 kFinaldest = 415; -static const uint16 kDestination = 416; -static const uint16 kLinestartx = 417; -static const uint16 kLinestarty = 419; -static const uint16 kLineendx = 421; -static const uint16 kLineendy = 423; -static const uint16 kLinepointer = 425; -static const uint16 kLinedirection = 426; -static const uint16 kLinelength = 427; -static const uint16 kCh0blockstocopy = 428; -static const uint16 kCh0playing = 430; -static const uint16 kCh0repeat = 431; -static const uint16 kCh1playing = 432; -static const uint16 kCh1blockstocopy = 433; -static const uint16 kSoundbufferwrite = 435; -static const uint16 kCurrentsample = 437; -static const uint16 kRoomssample = 438; -static const uint16 kBasicsample = 439; -static const uint16 kCurrentfile = 480; -static const uint16 kRoomscango = 555; -static const uint16 kRoompics = 571; -static const uint16 kOplist = 586; -static const uint16 kInputline = 589; -static const uint16 kPresslist = 717; -static const uint16 kQuitrequested = 723; -static const uint16 kSubtitles = 724; -static const uint16 kForeignrelease = 725; +static const uint16 kOffsetx = 153; +static const uint16 kOffsety = 155; +static const uint16 kCurrentob = 157; +static const uint16 kPrioritydep = 158; +static const uint16 kDestpos = 159; +static const uint16 kReallocation = 160; +static const uint16 kRoomnum = 161; +static const uint16 kNowinnewroom = 162; +static const uint16 kResetmanxy = 163; +static const uint16 kNewlocation = 164; +static const uint16 kAutolocation = 165; +static const uint16 kMustload = 166; +static const uint16 kAnswered = 167; +static const uint16 kSaidno = 168; +static const uint16 kDoorcheck1 = 169; +static const uint16 kDoorcheck2 = 170; +static const uint16 kDoorcheck3 = 171; +static const uint16 kDoorcheck4 = 172; +static const uint16 kMousex = 173; +static const uint16 kMousey = 175; +static const uint16 kMousebutton = 177; +static const uint16 kMousebutton1 = 179; +static const uint16 kMousebutton2 = 181; +static const uint16 kMousebutton3 = 183; +static const uint16 kMousebutton4 = 185; +static const uint16 kOldbutton = 187; +static const uint16 kOldx = 189; +static const uint16 kOldy = 191; +static const uint16 kLastbutton = 193; +static const uint16 kOldpointerx = 195; +static const uint16 kOldpointery = 197; +static const uint16 kDelherex = 199; +static const uint16 kDelherey = 201; +static const uint16 kPointerxs = 203; +static const uint16 kPointerys = 204; +static const uint16 kDelxs = 205; +static const uint16 kDelys = 206; +static const uint16 kPointerframe = 207; +static const uint16 kPointerpower = 208; +static const uint16 kAuxpointerframe = 209; +static const uint16 kPointermode = 210; +static const uint16 kPointerspeed = 211; +static const uint16 kPointercount = 212; +static const uint16 kInmaparea = 213; +static const uint16 kSlotdata = 214; +static const uint16 kThisslot = 215; +static const uint16 kSlotflags = 216; +static const uint16 kTalkmode = 217; +static const uint16 kTalkpos = 218; +static const uint16 kCharacter = 219; +static const uint16 kPersondata = 220; +static const uint16 kTalknum = 222; +static const uint16 kNumberinroom = 223; +static const uint16 kCurrentcel = 224; +static const uint16 kOldselection = 225; +static const uint16 kStopwalking = 226; +static const uint16 kMouseon = 227; +static const uint16 kPlayed = 228; +static const uint16 kTimer1 = 230; +static const uint16 kTimer2 = 231; +static const uint16 kTimer3 = 232; +static const uint16 kWholetimer = 233; +static const uint16 kTimer1to = 235; +static const uint16 kTimer2to = 236; +static const uint16 kTimer3to = 237; +static const uint16 kWatchdump = 238; +static const uint16 kLogonum = 239; +static const uint16 kOldlogonum = 240; +static const uint16 kNetseg = 241; +static const uint16 kNetpoint = 243; +static const uint16 kCursorstate = 245; +static const uint16 kPressed = 246; +static const uint16 kPresspointer = 247; +static const uint16 kGraphicpress = 249; +static const uint16 kPresscount = 250; +static const uint16 kLightcount = 251; +static const uint16 kFolderpage = 252; +static const uint16 kDiarypage = 253; +static const uint16 kMenucount = 254; +static const uint16 kSymboltopx = 255; +static const uint16 kSymboltopnum = 256; +static const uint16 kSymboltopdir = 257; +static const uint16 kSymbolbotx = 258; +static const uint16 kSymbolbotnum = 259; +static const uint16 kSymbolbotdir = 260; +static const uint16 kSymboltolight = 261; +static const uint16 kSymbol1 = 262; +static const uint16 kSymbol2 = 263; +static const uint16 kSymbol3 = 264; +static const uint16 kSymbolnum = 265; +static const uint16 kDumpx = 266; +static const uint16 kDumpy = 268; +static const uint16 kWalkandexam = 270; +static const uint16 kWalkexamtype = 271; +static const uint16 kWalkexamnum = 272; +static const uint16 kCurslocx = 273; +static const uint16 kCurslocy = 275; +static const uint16 kCurpos = 277; +static const uint16 kMonadx = 279; +static const uint16 kMonady = 281; +static const uint16 kMonsource = 283; +static const uint16 kNumtodo = 285; +static const uint16 kTimecount = 287; +static const uint16 kCounttotimed = 289; +static const uint16 kTimedseg = 291; +static const uint16 kTimedoffset = 293; +static const uint16 kTimedy = 295; +static const uint16 kTimedx = 296; +static const uint16 kNeedtodumptimed = 297; +static const uint16 kLoadingorsave = 298; +static const uint16 kCurrentslot = 299; +static const uint16 kCursorpos = 300; +static const uint16 kColourpos = 301; +static const uint16 kFadedirection = 302; +static const uint16 kNumtofade = 303; +static const uint16 kFadecount = 304; +static const uint16 kAddtogreen = 305; +static const uint16 kAddtored = 306; +static const uint16 kAddtoblue = 307; +static const uint16 kLastsoundreel = 308; +static const uint16 kSpeechloaded = 310; +static const uint16 kSpeechlength = 311; +static const uint16 kVolume = 313; +static const uint16 kVolumeto = 314; +static const uint16 kVolumedirection = 315; +static const uint16 kVolumecount = 316; +static const uint16 kWongame = 317; +static const uint16 kLasthardkey = 318; +static const uint16 kBufferin = 319; +static const uint16 kBufferout = 321; +static const uint16 kExtras = 323; +static const uint16 kWorkspace = 325; +static const uint16 kMapstore = 327; +static const uint16 kCharset1 = 329; +static const uint16 kBuffers = 331; +static const uint16 kMainsprites = 333; +static const uint16 kBackdrop = 335; +static const uint16 kMapdata = 337; +static const uint16 kSounddata = 339; +static const uint16 kSounddata2 = 341; +static const uint16 kRecordspace = 343; +static const uint16 kFreedat = 345; +static const uint16 kSetdat = 347; +static const uint16 kReel1 = 349; +static const uint16 kReel2 = 351; +static const uint16 kReel3 = 353; +static const uint16 kRoomdesc = 355; +static const uint16 kFreedesc = 357; +static const uint16 kSetdesc = 359; +static const uint16 kBlockdesc = 361; +static const uint16 kSetframes = 363; +static const uint16 kFreeframes = 365; +static const uint16 kPeople = 367; +static const uint16 kReels = 369; +static const uint16 kCommandtext = 371; +static const uint16 kPuzzletext = 373; +static const uint16 kTraveltext = 375; +static const uint16 kTempgraphics = 377; +static const uint16 kTempgraphics2 = 379; +static const uint16 kTempgraphics3 = 381; +static const uint16 kTempsprites = 383; +static const uint16 kTextfile1 = 385; +static const uint16 kTextfile2 = 387; +static const uint16 kTextfile3 = 389; +static const uint16 kBlinkframe = 391; +static const uint16 kBlinkcount = 392; +static const uint16 kReasseschanges = 393; +static const uint16 kPointerspath = 394; +static const uint16 kManspath = 395; +static const uint16 kPointerfirstpath = 396; +static const uint16 kFinaldest = 397; +static const uint16 kDestination = 398; +static const uint16 kLinestartx = 399; +static const uint16 kLinestarty = 401; +static const uint16 kLineendx = 403; +static const uint16 kLineendy = 405; +static const uint16 kLinepointer = 407; +static const uint16 kLinedirection = 408; +static const uint16 kLinelength = 409; +static const uint16 kCh0blockstocopy = 410; +static const uint16 kCh0playing = 412; +static const uint16 kCh0repeat = 413; +static const uint16 kCh1playing = 414; +static const uint16 kCh1blockstocopy = 415; +static const uint16 kSoundbufferwrite = 417; +static const uint16 kCurrentsample = 419; +static const uint16 kRoomssample = 420; +static const uint16 kBasicsample = 421; +static const uint16 kCurrentfile = 462; +static const uint16 kRoomscango = 537; +static const uint16 kOplist = 553; +static const uint16 kInputline = 556; +static const uint16 kPresslist = 684; +static const uint16 kQuitrequested = 690; +static const uint16 kSubtitles = 691; +static const uint16 kForeignrelease = 692; static const uint16 kBlocktextdat = (0); static const uint16 kPersonframes = (0); static const uint16 kDebuglevel1 = (0); @@ -465,51 +453,21 @@ public: void __start(); #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f() - void fadeDownMon(); - void getPersonText(); - void getObTextStart(); - void checkObjectSize(); - void doSomeTalk(); - void resetLocation(); - void outOfOpen(); void dirCom(); - void findFirstPath(); - void startTalk(); void getAnyAd(); - void reminders(); void getFreeAd(); void dirFile(); void pickupConts(); - void fadeUpMon(); - void reExFromInv(); void transferMap(); - void purgeAnItem(); - void purgeALocation(); void getSetAd(); - void findOpenPos(); - void searchForSame(); - void rollEm(); void findAllOpen(); void fillOpen(); - void getEitherAd(); - void dropObject(); - void useOpened(); - void locationPic(); - void swapWithOpen(); void dreamweb(); - void findPathOfPoint(); - void getDestInfo(); void read(); void searchForString(); - void selectOpenOb(); - void incRyanPage(); - void searchForFiles(); void getExAd(); - void initialMonCols(); - void swapWithInv(); void transferToEx(); void parser(); - void emergencyPurge(); void transferConToEx(); }; diff --git a/engines/dreamweb/keypad.cpp b/engines/dreamweb/keypad.cpp index 43f6749cad..878fbda5bf 100644 --- a/engines/dreamweb/keypad.cpp +++ b/engines/dreamweb/keypad.cpp @@ -25,11 +25,11 @@ namespace DreamGen { void DreamBase::getUnderMenu() { - multiGet(getSegment(data.word(kBuffers)).ptr(kUndertimedtext, 0), kMenux, kMenuy, 48, 48); + multiGet(_underTimedText, kMenux, kMenuy, 48, 48); } void DreamBase::putUnderMenu() { - multiPut(getSegment(data.word(kBuffers)).ptr(kUndertimedtext, 0), kMenux, kMenuy, 48, 48); + multiPut(_underTimedText, kMenux, kMenuy, 48, 48); } void DreamBase::singleKey(uint8 key, uint16 x, uint16 y) { @@ -92,8 +92,8 @@ void DreamBase::addToPressList() { ++data.word(kPresspointer); } -void DreamGenContext::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3) { - RectWithCallback keypadList[] = { +void DreamBase::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 digit3) { + RectWithCallback<DreamBase> keypadList[] = { { kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamBase::buttonOne }, { kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamBase::buttonTwo }, { kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamBase::buttonThree }, @@ -118,7 +118,7 @@ void DreamGenContext::enterCode(uint8 digit0, uint8 digit1, uint8 digit2, uint8 showKeypad(); readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); data.word(kPresspointer) = 0; data.byte(kGetback) = 0; diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index 398f0b8db0..88dfdeea53 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \ dreamgen.o \ keypad.o \ monitor.o \ + newplace.o \ object.o \ pathfind.o \ people.o \ @@ -17,6 +18,7 @@ MODULE_OBJS := \ sprite.o \ stubs.o \ talk.o \ + titles.o \ use.o \ vgafades.o \ vgagrafx.o diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp index 26caeb29ec..f3aad7a496 100644 --- a/engines/dreamweb/monitor.cpp +++ b/engines/dreamweb/monitor.cpp @@ -61,10 +61,10 @@ void DreamGenContext::useMon() { printOuterMon(); initialMonCols(); printLogo(); - workToScreenCPP(); + workToScreen(); turnOnPower(); - fadeupYellows(); - fadeupMonFirst(); + fadeUpYellows(); + fadeUpMonFirst(); data.word(kMonadx) = 76; data.word(kMonady) = 141; monMessage(1); @@ -171,10 +171,12 @@ bool DreamGenContext::execCommand() { void DreamBase::monitorLogo() { if (data.byte(kLogonum) != data.byte(kOldlogonum)) { data.byte(kOldlogonum) = data.byte(kLogonum); + //fadeDownMon(); // FIXME: Commented out in ASM printLogo(); printUnderMon(); - workToScreenCPP(); + workToScreen(); printLogo(); + //fadeUpMon(); // FIXME: Commented out in ASM printLogo(); playChannel1(26); randomAccess(20); @@ -265,7 +267,7 @@ void DreamBase::printCurs() { height = 11; } else height = 8; - multiGet(textUnder(), x, y, 6, height); + multiGet(_textUnder, x, y, 6, height); ++data.word(kMaintimer); if ((data.word(kMaintimer) & 16) == 0) showFrame(engine->tempCharset(), x, y, '/' - 32, 0); @@ -282,14 +284,14 @@ void DreamBase::delCurs() { height = 11; } else height = 8; - multiPut(textUnder(), x, y, width, height); + multiPut(_textUnder, x, y, width, height); multiDump(x, y, width, height); } void DreamBase::scrollMonitor() { printLogo(); printUnderMon(); - workToScreenCPP(); + workToScreen(); playChannel1(25); } @@ -424,7 +426,7 @@ void DreamBase::loadCart() { data.word(kTextfile3) = standardLoad("DREAMWEB.T24"); // monitor file 24 } -void DreamGenContext::showKeys() { +void DreamBase::showKeys() { randomAccess(10); scrollMonitor(); monMessage(18); @@ -512,4 +514,17 @@ void DreamGenContext::signOn() { } } +void DreamGenContext::searchForFiles() { + bx = kTextstart; + + while (true) { + al = es.byte(bx); + bx++; + if (al == '*') + return; // "endofdir" + if (al == 34) + monPrint(); + } +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp new file mode 100644 index 0000000000..03824aa706 --- /dev/null +++ b/engines/dreamweb/newplace.cpp @@ -0,0 +1,280 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" + +namespace DreamGen { + +void DreamBase::newPlace() { + if (data.byte(kNeedtotravel) == 1) { + data.byte(kNeedtotravel) = 0; + selectLocation(); + } else if (data.byte(kAutolocation) != 0xFF) { + data.byte(kNewlocation) = data.byte(kAutolocation); + data.byte(kAutolocation) = 0xFF; + } +} + +void DreamBase::selectLocation() { + data.byte(kInmaparea) = 0; + clearBeforeLoad(); + data.byte(kGetback) = 0; + data.byte(kPointerframe) = 22; + readCityPic(); + showCity(); + getRidOfTemp(); + readDestIcon(); + loadTravelText(); + showPanel(); + showMan(); + showArrows(); + showExit(); + locationPic(); + underTextLine(); + data.byte(kCommandtype) = 255; + readMouse(); + data.byte(kPointerframe) = 0; + showPointer(); + workToScreen(); + playChannel0(9, 255); + data.byte(kNewlocation) = 255; + + while (data.byte(kNewlocation) == 255) { + if (quitRequested()) + break; + + delPointer(); + readMouse(); + showPointer(); + vSync(); + dumpPointer(); + dumpTextLine(); + + if (data.byte(kGetback) == 1) + break; + + RectWithCallback<DreamBase> destList[] = { + { 238,258,4,44,&DreamBase::nextDest }, + { 104,124,4,44,&DreamBase::lastDest }, + { 280,308,4,44,&DreamBase::lookAtPlace }, + { 104,216,138,192,&DreamBase::destSelect }, + { 273,320,157,198,&DreamBase::getBack1 }, + { 0,320,0,200,&DreamBase::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkCoords(destList); + } + + if (quitRequested() || data.byte(kGetback) == 1 || data.byte(kNewlocation) == data.byte(kLocation)) { + data.byte(kNewlocation) = data.byte(kReallocation); + data.byte(kGetback) = 0; + } + + getRidOfTemp(); + getRidOfTemp2(); + getRidOfTemp3(); + deallocateMem(data.word(kTraveltext)); +} + +void DreamBase::showCity() { + clearWork(); + showFrame(tempGraphics(), 57, 32, 0, 0); + showFrame(tempGraphics(), 120+57, 32, 1, 0); +} + +void DreamBase::lookAtPlace() { + if (data.byte(kCommandtype) != 224) { + data.byte(kCommandtype) = 224; + commandOnly(27); + } + + if (!(data.word(kMousebutton) & 1) || + data.word(kMousebutton) == data.word(kOldbutton) || + data.byte(kDestpos) >= 15) + return; // noinfo + + delPointer(); + delTextLine(); + getUnderCentre(); + showFrame(tempGraphics3(), 60, 72, 0, 0); + showFrame(tempGraphics3(), 60, 72 + 55, 4, 0); + if (data.byte(kForeignrelease)) + showFrame(tempGraphics3(), 60, 72+55+21, 4, 0); + + uint16 offset = kTextstart + getSegment(data.word(kTraveltext)).word(data.byte(kDestpos) * 2); + const uint8 *string = getSegment(data.word(kTraveltext)).ptr(offset, 0); + findNextColon(&string); + uint16 y = (data.byte(kForeignrelease)) ? 84 + 4 : 84; + printDirect(&string, 63, &y, 191, 191 & 1); + workToScreenM(); + hangOnP(500); + data.byte(kPointermode) = 0; + data.byte(kPointerframe) = 0; + putUnderCentre(); + workToScreenM(); +} + +void DreamBase::getUnderCentre() { + multiGet(mapStore(), 58, 72, 254, 110); +} + +void DreamBase::putUnderCentre() { + multiPut(mapStore(), 58, 72, 254, 110); +} + +void DreamBase::locationPic() { + const int roomPics[] = { 5, 0, 3, 2, 4, 1, 10, 9, 8, 6, 11, 4, 7, 7, 0 }; + byte picture = roomPics[data.byte(kDestpos)]; + + if (picture >= 6) + showFrame(tempGraphics2(), 104, 138 + 14, picture - 6, 0); // Second slot + else + showFrame(tempGraphics(), 104, 138 + 14, picture + 4, 0); + + if (data.byte(kDestpos) == data.byte(kReallocation)) + showFrame(tempGraphics(), 104, 140 + 14, 3, 0); // Currently in this location + + uint16 offset = kTextstart + getSegment(data.word(kTraveltext)).word(data.byte(kDestpos) * 2); + const uint8 *string = getSegment(data.word(kTraveltext)).ptr(offset, 0); + DreamBase::printDirect(string, 50, 20, 241, 241 & 1); +} + +void DreamBase::showArrows() { + showFrame(tempGraphics(), 116 - 12, 16, 0, 0); + showFrame(tempGraphics(), 226 + 12, 16, 1, 0); + showFrame(tempGraphics(), 280, 14, 2, 0); +} + +void DreamBase::nextDest() { + if (data.byte(kCommandtype) != 218) { + data.byte(kCommandtype) = 218; + commandOnly(28); + } + + if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) + return; // nodu + + do { + data.byte(kDestpos)++; + if (data.byte(kDestpos) == 15) + data.byte(kDestpos) = 0; // last destination + } while (!data.byte(kRoomscango + data.byte(kDestpos))); + + data.byte(kNewtextline) = 1; + delTextLine(); + delPointer(); + showPanel(); + showMan(); + showArrows(); + locationPic(); + underTextLine(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamBase::lastDest() { + if (data.byte(kCommandtype) != 219) { + data.byte(kCommandtype) = 219; + commandOnly(29); + } + + if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) + return; // nodd + + do { + data.byte(kDestpos)--; + if (data.byte(kDestpos) == 0xFF) + data.byte(kDestpos) = 15; // first destination + } while (!data.byte(kRoomscango + data.byte(kDestpos))); + + data.byte(kNewtextline) = 1; + delTextLine(); + delPointer(); + showPanel(); + showMan(); + showArrows(); + locationPic(); + underTextLine(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamBase::destSelect() { + if (data.byte(kCommandtype) != 222) { + data.byte(kCommandtype) = 222; + commandOnly(30); + } + + if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) + return; // notrav + + data.byte(kNewlocation) = data.byte(kDestpos); +} + +uint8 DreamBase::getLocation(uint8 index) { + return data.byte(kRoomscango + index); +} + +void DreamBase::setLocation(uint8 index) { + data.byte(kRoomscango + index) = 1; +} + +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::readDestIcon() { + loadIntoTemp("DREAMWEB.G05"); + loadIntoTemp2("DREAMWEB.G06"); + loadIntoTemp3("DREAMWEB.G08"); +} + +void DreamBase::readCityPic() { + loadIntoTemp("DREAMWEB.G04"); +} + +} // End of namespace DreamGen diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index 54979309f4..9d5ea15fa3 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -58,15 +58,11 @@ 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'); } -void DreamGenContext::wornError() { +void DreamBase::wornError() { data.byte(kCommandtype) = 255; delPointer(); printMessage(76, 21, 57, 240, false); @@ -79,11 +75,7 @@ void DreamGenContext::wornError() { workToScreenM(); } -void DreamGenContext::makeWorn() { - makeWorn((DynObject *)es.ptr(bx, sizeof(DynObject))); -} - -void DreamGenContext::makeWorn(DynObject *object) { +void DreamBase::makeWorn(DynObject *object) { object->id[0] = 'W'-'A'; object->id[1] = 'E'-'A'; } @@ -155,7 +147,7 @@ void DreamGenContext::examineOb(bool examineAgain) { data.byte(kCommandtype) = 255; readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); examineAgain = false; } @@ -170,8 +162,8 @@ void DreamGenContext::examineOb(bool examineAgain) { switch (data.byte(kInvopen)) { case 0: { - RectWithCallback examList[] = { - { 273,320,157,198,&DreamGenContext::getBackFromOb }, + RectWithCallback<DreamGenContext> examList[] = { + { 273,320,157,198,&DreamBase::getBackFromOb }, { 260,300,0,44,&DreamGenContext::useObject }, { 210,254,0,44,&DreamGenContext::selectOpenOb }, { 144,176,64,96,&DreamGenContext::setPickup }, @@ -184,8 +176,8 @@ void DreamGenContext::examineOb(bool examineAgain) { } case 1: { // Note: This table contains the non-constant _openChangeSize! - RectWithCallback invList1[] = { - { 273,320,157,198,&DreamGenContext::getBackFromOb }, + RectWithCallback<DreamGenContext> invList1[] = { + { 273,320,157,198,&DreamBase::getBackFromOb }, { 255,294,0,24,&DreamGenContext::dropObject }, { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incRyanPage }, { kInventx,_openChangeSize,kInventy+100,kInventy+100+kItempicsize,&DreamGenContext::useOpened }, @@ -197,8 +189,8 @@ void DreamGenContext::examineOb(bool examineAgain) { break; } default: { - RectWithCallback withList1[] = { - { 273,320,157,198,&DreamGenContext::getBackFromOb }, + RectWithCallback<DreamGenContext> withList1[] = { + { 273,320,157,198,&DreamBase::getBackFromOb }, { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incRyanPage }, { kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamGenContext::selectOb }, { 0,320,0,200,&DreamBase::blank }, @@ -235,8 +227,7 @@ void DreamGenContext::inventory() { if (data.byte(kCommandtype) != 239) { data.byte(kCommandtype) = 239; - al = 32; - commandOnly(); + commandOnly(32); } if (data.word(kMousebutton) == data.word(kOldbutton)) @@ -260,7 +251,7 @@ void DreamGenContext::inventory() { openInv(); readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); data.byte(kOpenedob) = 255; examineOb(false); @@ -286,7 +277,7 @@ void DreamBase::getBackFromOb() { } void DreamGenContext::getOpenedSize() { - //ax = getOpenedSizeCPP(); + //ax = getOpenedSlotCount(); // We need to call the ASM-style versions of get*Ad, as these also set // bx and es @@ -309,7 +300,7 @@ void DreamGenContext::getOpenedSize() { } } -byte DreamGenContext::getOpenedSizeCPP() { +byte DreamGenContext::getOpenedSlotCount() { byte obj = data.byte(kOpenedob); switch (data.byte(kOpenedtype)) { case 4: @@ -321,6 +312,18 @@ byte DreamGenContext::getOpenedSizeCPP() { } } +byte DreamGenContext::getOpenedSlotSize() { + byte obj = data.byte(kOpenedob); + switch (data.byte(kOpenedtype)) { + case 4: + return getExAd(obj)->slotSize; + case 2: + return getFreeAd(obj)->slotSize; + default: + return getSetAd(obj)->slotSize; + } +} + void DreamGenContext::openOb() { uint8 commandLine[64] = "OBJECT NAME ONE "; @@ -331,7 +334,7 @@ void DreamGenContext::openOb() { al = printDirect(commandLine, data.word(kLastxpos) + 5, kInventy+86, 220, false); fillOpen(); - _openChangeSize = getOpenedSizeCPP() * kItempicsize + kInventx; + _openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx; } void DreamGenContext::identifyOb() { @@ -351,12 +354,10 @@ void DreamGenContext::identifyOb() { data.byte(kInmaparea) = 1; ah = bl; push(ax); - findPathOfPoint(); - data.byte(kPointerspath) = dl; + data.byte(kPointerspath) = findPathOfPoint(al, ah); ax = pop(); push(ax); - findFirstPath(); - data.byte(kPointerfirstpath) = al; + data.byte(kPointerfirstpath) = findFirstPath(al, ah); ax = pop(); byte x = al; @@ -419,8 +420,7 @@ void DreamGenContext::selectOb() { void DreamGenContext::setPickup() { if (data.byte(kObjecttype) != kSetObjectType1 && data.byte(kObjecttype) != kSetObjectType3) { - // The original called getAnyAd() here. However, since object types - // 1 and 3 are excluded, the resulting object is a DynObject + // Object types 1 and 3 are excluded, so the resulting object is a DynObject uint8 dummy; DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); if (object->mapad[0] == 4) { @@ -466,10 +466,6 @@ void DreamGenContext::setPickup() { workToScreenM(); } -void DreamGenContext::deleteExFrame() { - deleteExFrame(al); -} - void DreamBase::deleteExFrame(uint8 frameNum) { Frame *frame = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata + sizeof(Frame)*frameNum, sizeof(Frame)); @@ -493,10 +489,6 @@ void DreamBase::deleteExFrame(uint8 frameNum) { } } -void DreamGenContext::deleteExText() { - deleteExText(al); -} - void DreamBase::deleteExText(uint8 textNum) { uint16 offset = getSegment(data.word(kExtras)).word(kExtextdat + 2*textNum); @@ -519,11 +511,6 @@ void DreamBase::deleteExText(uint8 textNum) { } } -// This takes es:di and cl as input, but es:di always points to getExAd(cl) -void DreamGenContext::deleteExObject() { - deleteExObject(cl); -} - void DreamBase::deleteExObject(uint8 index) { DynObject *obj = getExAd(index); @@ -631,4 +618,450 @@ void DreamGenContext::outOfInv() { delPointer(); } +void DreamBase::purgeALocation(uint8 index) { + // index == al + for (uint8 i = 0; i < kNumexobjects; ++i) { + DynObject *t = getExAd(i); + if (t->currentLocation == index && t->mapad[0] == 0) { + deleteExObject(i); + } + } +} + +const uint8 *DreamBase::getObTextStart() { + uint16 textSeg, textDatOff, textOff; + if (data.byte(kObjecttype) == kFreeObjectType) { + textSeg = data.word(kFreedesc); + textDatOff = kFreetextdat; + textOff = kFreetext; + } else if (data.byte(kObjecttype) == kSetObjectType1) { + textSeg = data.word(kSetdesc); + textDatOff = kSettextdat; + textOff = kSettext; + } else { + textSeg = data.word(kExtras); + textDatOff = kExtextdat; + textOff = kExtext; + } + const uint8 *textBase = getSegment(textSeg).ptr(textOff, 0); + const uint8 *text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand)); + + if (data.byte(kObjecttype) != kSetObjectType1) + return text; + + const uint8 *obname = text; + while (true) { + const uint8 *start = text; + findNextColon(&text); + + // Not an empty description string? + if (*text != 0 && *text != ':') + return start; + + // If the description string (of a SetObjectType1 object) is empty, + // look for an object with the same name. + // Example: Eden's garage door outside has two parts. The right part + // has no description of its own but uses that of the left part. + + bool found = false; + do { + text++; + uint8 c = *obname; + + // scan for matching first character + while (*text != c) { + text++; + + // arbitrary give-up counter + if (text - (textBase - textOff) >= 8000) { + warning("Object description for %d/%d not found", data.byte(kObjecttype), data.byte(kCommand)); + return obname; + } + } + + // found matching first character, so match the rest + const uint8 *s1 = obname; + const uint8 *s2 = text; + do { + s1++; + s2++; + } while (*s1 != ':' && *s1 != 0 && *s1 == *s2); + + if (*s1 == ':' || *s1 == 0) + found = true; // (prefix) matched the entire object name + } while (!found); + + // We found an object with the same name. The next loop iteration + // will check if this one again has an empty description. + } +} + +void DreamBase::dropObject() { + if (data.byte(kCommandtype) != 223) { + data.byte(kCommandtype) = 223; + if (!data.byte(kPickup)) { + blank(); + return; + } + commandWithOb(37, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + if (isItWorn(getEitherAdCPP())) { + wornError(); + return; + } + + if (data.byte(kReallocation) != 47) { + byte flag, flagEx, type, flagX, flagY; + checkOne(data.byte(kRyanx) + 12, data.byte(kRyany) + 12, &flag, &flagEx, &type, &flagX, &flagY); + + if (flag >= 2) { + dropError(); + return; + } + } else { + dropError(); + return; + } + + if (data.byte(kMapxsize) == 64 && data.byte(kMapysize) == 64) { + // Inside lift + dropError(); + return; + } + + if (compare(data.byte(kItemframe), 4, "GUNA") || compare(data.byte(kItemframe), 4, "SHLD")) { + cantDrop(); + return; + } + + data.byte(kObjecttype) = 4; + DynObject *object = getExAd(data.byte(kItemframe)); + object->mapad[0] = 0; + object->mapad[1] = ((data.byte(kRyanx) + 4) >> 4) + data.byte(kMapx); + object->mapad[2] = (data.byte(kRyanx) + 4) & 0xF; + object->mapad[3] = ((data.byte(kRyany) + 8) >> 4) + data.byte(kMapy); + object->mapad[4] = (data.byte(kRyany) + 8) & 0xF; + data.byte(kPickup) = 0; + object->currentLocation = data.byte(kReallocation); +} + +bool DreamGenContext::checkObjectSizeCPP() { + byte containerSize = getOpenedSlotSize(); + DynObject *object = getEitherAdCPP(); + // If there is no size defined for the object in the editor, set its size + // to 6. This could be a bad idea, according to the original source. + byte objectSize = (object->objectSize != 255) ? object->objectSize : 6; + + if (containerSize >= 100) { + // Special type of container: only objects of the same special type fit. + if (containerSize == objectSize) + return true; + + errorMessage3(); + return false; + } + + if (objectSize >= 100) { + // Special type of object, but a regular container. + // Subtract 100 from the size to get its regular size. + objectSize -= 100; + } + + if (containerSize >= objectSize) + return true; + + errorMessage2(); + return false; +} + +void DreamGenContext::selectOpenOb() { + uint8 slotSize, slotCount; + getAnyAd(&slotSize, &slotCount); + if (slotCount == 255) { + // Can't open the object + blank(); + return; + } + + if (data.byte(kCommandtype) != 224) { + data.byte(kCommandtype) = 224; + commandWithOb(38, data.byte(kObjecttype), data.byte(kCommand)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + data.byte(kOpenedob) = data.byte(kCommand); + data.byte(kOpenedtype) = data.byte(kObjecttype); + createPanel(); + showPanel(); + showMan(); + examIcon(); + showExit(); + openInv(); + openOb(); + underTextLine(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamGenContext::reExFromInv() { + uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); + data.byte(kCommandtype) = objectId >> 8; + data.byte(kCommand) = objectId & 0x00FF; + data.byte(kExamagain) = 1; + data.byte(kPointermode) = 0; +} + +void DreamGenContext::swapWithInv() { + uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (subject == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 243) { + data.byte(kCommandtype) = 243; + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + } else { + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + byte prevType = data.byte(kObjecttype); + byte prevFrame = data.byte(kItemframe); + uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); + data.byte(kItemframe) = objectId & 0x00FF; + data.byte(kObjecttype) = objectId >> 8; + DynObject *object = getEitherAdCPP(); + object->mapad[0] = 20; + object->mapad[1] = 255; + byte prevType2 = data.byte(kObjecttype); + byte prevFrame2 = data.byte(kItemframe); + data.byte(kObjecttype) = prevType; + data.byte(kItemframe) = prevFrame; + //findInvPosCPP(); // found in the original source, but it seems to be useless + delPointer(); + object = getEitherAdCPP(); + object->mapad[0] = 4; + object->mapad[1] = 255; + object->mapad[2] = data.byte(kLastinvpos); + data.byte(kObjecttype) = prevType2; + data.byte(kItemframe) = prevFrame2; + fillRyan(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamGenContext::useOpened() { + if (data.byte(kOpenedob) == 255) + return; // cannot use opened object + + if (!data.byte(kPickup)) { + outOfOpen(); + return; + } + + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + + if ((objectId & 0x00FF) != 255) { + swapWithOpen(); + return; + } + + if (data.byte(kPickup) != 1) { + blank(); + return; + } + + objectId = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (objectId == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 227) { + data.byte(kCommandtype) = 227; + data.word(kOldsubject) = objectId; + commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + } + } else { + data.word(kOldsubject) = objectId; + commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + if (isItWorn(getEitherAdCPP())) { + wornError(); + return; + } + + delPointer(); + + if (data.byte(kItemframe) == data.byte(kOpenedob) && + data.byte(kObjecttype) == data.byte(kOpenedtype)) { + errorMessage1(); + return; + } + + if (!checkObjectSizeCPP()) + return; + + data.byte(kPickup) = 0; + DynObject *object = getEitherAdCPP(); + object->mapad[0] = data.byte(kOpenedtype); + object->mapad[1] = data.byte(kOpenedob); + object->mapad[2] = data.byte(kLastinvpos); + object->mapad[3] = data.byte(kReallocation); + fillOpen(); + underTextLine(); + readMouse(); + useOpened(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamGenContext::outOfOpen() { + if (data.byte(kOpenedob) == 255) + return; // cannot use opened object + + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + + if ((objectId & 0x00FF) == 255) { + blank(); + return; + } + + if (objectId == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 228) { + data.byte(kCommandtype) = 228; + data.word(kOldsubject) = objectId; + commandWithOb(36, objectId >> 8, objectId & 0x00FF); + } + } else { + data.word(kOldsubject) = objectId; + commandWithOb(36, objectId >> 8, objectId & 0x00FF); + } + + if (data.word(kMousebutton) == data.word(kOldbutton)) + return; // notletgo4 + + if (data.word(kMousebutton) != 1) { + if (data.word(kMousebutton) != 2) + return; // notletgo4 + + reExFromOpen(); + return; + } + + delPointer(); + data.byte(kPickup) = 1; + objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + data.byte(kObjecttype) = objectId >> 8; + data.byte(kItemframe) = objectId & 0xFF; + + if (data.byte(kObjecttype) != 4) { + transferToEx(); + data.byte(kItemframe) = al; + data.byte(kObjecttype) = 4; + } + + DynObject *object = getEitherAdCPP(); + object->mapad[0] = 20; + object->mapad[1] = 255; + + fillOpen(); + underTextLine(); + readMouse(); + useOpened(); + showPointer(); + workToScreen(); + delPointer(); +} + +void DreamGenContext::swapWithOpen() { + uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + if (subject == data.word(kOldsubject)) { + if (data.byte(kCommandtype) != 242) { + data.byte(kCommandtype) = 242; + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + } else { + data.word(kOldsubject) = subject; + commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + if (isItWorn(getEitherAdCPP())) { + wornError(); + return; + } + + delPointer(); + + if (data.byte(kItemframe) == data.byte(kOpenedob) && + data.byte(kObjecttype) == data.byte(kOpenedtype)) { + errorMessage1(); + return; + } + + if (!checkObjectSizeCPP()) + return; + + byte prevType = data.byte(kObjecttype); + byte prevFrame = data.byte(kItemframe); + uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + data.byte(kObjecttype) = objectId >> 8; + data.byte(kItemframe) = objectId & 0xFF; + + if (data.byte(kObjecttype) != 4) { + transferToEx(); + data.byte(kItemframe) = al; + data.byte(kObjecttype) = 4; + } + + DynObject *object = getEitherAdCPP(); + object->mapad[0] = 20; + object->mapad[1] = 255; + + byte prevType2 = data.byte(kObjecttype); + byte prevFrame2 = data.byte(kItemframe); + data.byte(kObjecttype) = prevType; + data.byte(kItemframe) = prevFrame; + //findOpenPos(); // was in the original source, looks to be unused + object = getEitherAdCPP(); + object->mapad[0] = data.byte(kOpenedtype); + object->mapad[1] = data.byte(kOpenedob); + object->mapad[2] = data.byte(kLastinvpos); + object->mapad[3] = data.byte(kReallocation); + data.byte(kObjecttype) = prevType2; + data.byte(kItemframe) = prevFrame2; + fillOpen(); + fillRyan(); + underTextLine(); + readMouse(); + useOpened(); + showPointer(); + workToScreen(); + delPointer(); +} + +uint16 DreamBase::findOpenPos() { + uint16 pos = (data.word(kMousex) - kInventx) / kItempicsize; + data.byte(kLastinvpos) = pos & 0xFF; + + return pos * 2 + kOpeninvlist; // return the object position in the inventory data +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 8d9d9a95bb..4f887db251 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -309,4 +309,45 @@ void DreamBase::workoutFrames() { data.byte(kTurndirection) = 0; } +byte DreamBase::findFirstPath(byte x, byte y) { + PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0); + + for (uint8 index = 0; index < 12; index++) { + if (paths[index].x1 == 0xff && paths[index].y1 == 0xff) + continue; // "nofirst" + + if (x < paths[index].x1 || y < paths[index].y1) + continue; // "nofirst" + + if (x >= paths[index].x2 || y >= paths[index].y2) + continue; // "nofirst" + + return paths[index].on; // "gotfirst" + } + + return 0; +} + +byte DreamBase::findPathOfPoint(byte x, byte y) { + PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0); + + for (uint8 index = 0; index < 12; index++) { + if (paths[index].on != 0xff) + continue; // "flunkedit" + + if (paths[index].x1 == 0xff && paths[index].y1 == 0xff) + continue; // "flunkedit" + + if (x < paths[index].x1 || y < paths[index].y1) + continue; // "flunkedit" + + if (x >= paths[index].x2 || y >= paths[index].y2) + continue; // "flunkedit" + + return index; // "gotvalidpath" + } + + return 0xff; +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp index 4d66134e96..a6ebbcc1ec 100644 --- a/engines/dreamweb/people.cpp +++ b/engines/dreamweb/people.cpp @@ -129,8 +129,7 @@ void DreamBase::setupInitialReelRoutines() { } void DreamBase::updatePeople() { - data.word(kListpos) = kPeoplelist; - memset(getSegment(data.word(kBuffers)).ptr(kPeoplelist, 12 * sizeof(People)), 0xff, 12 * sizeof(People)); + _peopleList.clear(); ++data.word(kMaintimer); for (int i = 0; _reelRoutines[i].reallocation != 255; ++i) { @@ -220,13 +219,12 @@ void DreamBase::madMode() { } void DreamBase::addToPeopleList(ReelRoutine *routine) { - uint16 routinePointer = (const uint8 *)routine - data.ptr(0, 0); + People people; + people._reelPointer = routine->reelPointer(); + people._routinePointer = routine; + people.b4 = routine->b7; - People *people = (People *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(People)); - people->setReelPointer(routine->reelPointer()); - people->setRoutinePointer(routinePointer); - people->b4 = routine->b7; - data.word(kListpos) += sizeof(People); + _peopleList.push_back(people); } bool DreamBase::checkSpeed(ReelRoutine &routine) { @@ -273,7 +271,7 @@ void DreamBase::sparky(ReelRoutine &routine) { if (data.word(kCard1money)) routine.b7 = 3; if (checkSpeed(routine)) { - if (routine.reelPointer() != 34) { + if (routine.reelPointer() == 34) { if (engine->randomNumber() < 30) routine.incReelPointer(); else @@ -923,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; @@ -1032,7 +1030,7 @@ void DreamBase::endGameSeq(ReelRoutine &routine) { if (routine.reelPointer() == 145) { routine.setReelPointer(146); - rollEndCredits(); + rollEndCreditsGameWon(); } } diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 0fd596ceac..0191aa8860 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -263,4 +263,91 @@ const char *DreamBase::monPrint(const char *string) { return iterator; } +void DreamBase::rollEndCreditsGameWon() { + playChannel0(16, 255); + data.byte(kVolume) = 7; + data.byte(kVolumeto) = 0; + data.byte(kVolumedirection) = (byte)-1; + + multiGet(mapStore(), 75, 20, 160, 160); + + const uint8 *string = getTextInFile1(3); + const int linespacing = data.word(kLinespacing); + + for (int i = 0; i < 254; ++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(), 75, 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, 75, &y, 160 + 1, true); + y += linespacing; + } + + vSync(); + multiDump(75, 20, 160, 160); + } + + // Skip to the next text line + byte c; + do { + c = *string++; + } while (c != ':' && c != 0); + } + + hangOn(100); + panelToMap(); + fadeScreenUpHalf(); +} + +void DreamBase::rollEndCreditsGameLost() { + 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 diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index cd32e4fa34..2076a349b5 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -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); @@ -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) { @@ -80,10 +80,10 @@ void DreamGenContext::doLoad(int savegameId) { vSync(); dumpPointer(); dumpTextLine(); - RectWithCallback loadlist[] = { - { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getBackToOps }, - { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamGenContext::actualLoad }, - { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamGenContext::selectSlot }, + RectWithCallback<DreamBase> loadlist[] = { + { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps }, + { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamBase::actualLoad }, + { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamBase::selectSlot }, { 0,320,0,200,&DreamBase::blank }, { 0xFFFF,0,0,0,0 } }; @@ -133,12 +133,12 @@ void DreamGenContext::doLoad(int savegameId) { data.word(kTextaddressy) = 182; data.byte(kTextlen) = 240; startup(); - workToScreenCPP(); + workToScreen(); data.byte(kGetback) = 4; } -void DreamGenContext::saveGame() { +void DreamBase::saveGame() { if (data.byte(kMandead) == 2) { blank(); return; @@ -176,10 +176,10 @@ void DreamGenContext::saveGame() { dumpPointer(); dumpTextLine(); - RectWithCallback savelist[] = { - { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getBackToOps }, - { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamGenContext::actualSave }, - { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamGenContext::selectSlot }, + RectWithCallback<DreamBase> savelist[] = { + { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamBase::getBackToOps }, + { kOpsx+128,kOpsx+190,kOpsy+12,kOpsy+100,&DreamBase::actualSave }, + { kOpsx+2,kOpsx+92,kOpsy+4,kOpsy+81,&DreamBase::selectSlot }, { 0,320,0,200,&DreamBase::blank }, { 0xFFFF,0,0,0,0 } }; @@ -220,7 +220,7 @@ void DreamGenContext::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 @@ -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; @@ -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; @@ -265,10 +265,10 @@ void DreamGenContext::doSaveLoad() { loadSaveBox(); showOpBox(); showMainOps(); - workToScreenCPP(); + workToScreen(); - RectWithCallback opsList[] = { - { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::getBackFromOps }, + RectWithCallback<DreamGenContext> opsList[] = { + { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamBase::getBackFromOps }, { kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamBase::DOSReturn }, { kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamGenContext::discOps }, { 0,320,0,200,&DreamBase::blank }, @@ -316,6 +316,27 @@ void DreamGenContext::doSaveLoad() { data.byte(kManisoffscreen) = 0; } +void DreamBase::getBackFromOps() { + if (data.byte(kMandead) == 2) + blank(); + else + getBack1(); +} + +void DreamBase::getBackToOps() { + if (data.byte(kCommandtype) != 201) { + data.byte(kCommandtype) = 201; + commandOnly(42); + } + + if (data.word(kMousebutton) != data.word(kOldbutton)) { + if (data.word(kMousebutton) & 1) { + oldToNames(); + data.byte(kGetback) = 2; + } + } +} + void DreamBase::showMainOps() { showFrame(tempGraphics(), kOpsx+10, kOpsy+10, 8, 0); showFrame(tempGraphics(), kOpsx+59, kOpsy+30, 7, 0); @@ -329,7 +350,46 @@ void DreamBase::showDiscOps() { showFrame(tempGraphics(), kOpsx+176+2, kOpsy+60-4, 5, 0); } -void DreamGenContext::actualSave() { +void DreamBase::discOps() { + if (data.byte(kCommandtype) != 249) { + data.byte(kCommandtype) = 249; + commandOnly(43); + } + + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + scanForNames(); + data.byte(kLoadingorsave) = 2; + showOpBox(); + showDiscOps(); + data.byte(kCurrentslot) = 0; + workToScreenM(); + data.byte(kGetback) = 0; + + RectWithCallback<DreamGenContext> discOpsList[] = { + { 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 } + }; + + do { + if (data.byte(kQuitrequested) != 0) + return; // quitdiscops + + delPointer(); + readMouse(); + showPointer(); + vSync(); + dumpPointer(); + dumpTextLine(); + checkCoords(discOpsList); + } while (!data.byte(kGetback)); +} + +void DreamBase::actualSave() { if (data.byte(kCommandtype) != 222) { data.byte(kCommandtype) = 222; commandOnly(44); @@ -356,7 +416,7 @@ void DreamGenContext::actualSave() { data.byte(kGetback) = 4; } -void DreamGenContext::actualLoad() { +void DreamBase::actualLoad() { if (data.byte(kCommandtype) != 221) { data.byte(kCommandtype) = 221; commandOnly(41); @@ -419,7 +479,7 @@ void DreamBase::savePosition(unsigned int slot, const char *descbuf) { outSaveFile->write(descbuf, len[0]); outSaveFile->write(data.ptr(kStartvars, len[1]), len[1]); outSaveFile->write(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]); - outSaveFile->write(getSegment(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]); + outSaveFile->write(_listOfChanges, len[3]); // len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango' outSaveFile->write((const uint8 *)&madeUpRoom, sizeof(Room)); @@ -485,7 +545,7 @@ void DreamBase::loadPosition(unsigned int slot) { } inSaveFile->read(data.ptr(kStartvars, len[1]), len[1]); inSaveFile->read(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]); - inSaveFile->read(getSegment(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]); + inSaveFile->read(_listOfChanges, len[3]); // len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango' // Note: the values read into g_madeUpRoomDat are only used in actualLoad, @@ -529,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; @@ -560,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); @@ -584,7 +645,14 @@ void DreamGenContext::loadOld() { data.byte(kGetback) = 0; } -void DreamGenContext::loadSaveBox() { +void DreamBase::showDecisions() { + createPanel2(); + showOpBox(); + showFrame(tempGraphics(), kOpsx + 17, kOpsy + 13, 6, 0); + underTextLine(); +} + +void DreamBase::loadSaveBox() { loadIntoTemp("DREAMWEB.G08"); } @@ -612,7 +680,7 @@ void DreamBase::showNames() { } } -void DreamGenContext::checkInput() { +void DreamBase::checkInput() { if (data.byte(kLoadingorsave) == 3) return; @@ -649,7 +717,7 @@ void DreamGenContext::checkInput() { workToScreenM(); } -void DreamGenContext::selectSlot() { +void DreamBase::selectSlot() { if (data.byte(kCommandtype) != 244) { data.byte(kCommandtype) = 244; commandOnly(45); @@ -681,4 +749,37 @@ void DreamGenContext::selectSlot() { delPointer(); } +void DreamBase::showSlots() { + showFrame(tempGraphics(), kOpsx + 7, kOpsy + 8, 2, 0); + + uint16 y = kOpsy + 11; + + for (int slot = 0; slot < 7; slot++) { + if (slot == data.byte(kCurrentslot)) + showFrame(tempGraphics(), kOpsx + 10, y, 3, 0); + + y += 10; + } +} + +void DreamBase::showOpBox() { + showFrame(tempGraphics(), kOpsx, kOpsy, 0, 0); + + // CHECKME: There seem to be versions of dreamweb in which this call + // should be removed. It displays a red dot on the ops dialogs if left in. + showFrame(tempGraphics(), kOpsx, kOpsy + 55, 4, 0); +} + +void DreamBase::showLoadOps() { + showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0); + showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); + printMessage(kOpsx + 104, kOpsy + 14, 55, 101, (101 & 1)); +} + +void DreamBase::showSaveOps() { + showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0); + showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); + printMessage(kOpsx + 104, kOpsy + 14, 54, 101, (101 & 1)); +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp index 784a6d0d11..4683f333c9 100644 --- a/engines/dreamweb/sound.cpp +++ b/engines/dreamweb/sound.cpp @@ -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; diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index cc6b09fd68..f23804b395 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -24,18 +24,12 @@ namespace DreamGen { -Sprite *DreamBase::spriteTable() { - Sprite *sprite = (Sprite *)getSegment(data.word(kBuffers)).ptr(kSpritetable, 16 * sizeof(Sprite)); - return sprite; -} - void DreamBase::printSprites() { for (size_t priority = 0; priority < 7; ++priority) { - Sprite *sprites = spriteTable(); - for (size_t j = 0; j < 16; ++j) { - const Sprite &sprite = sprites[j]; - if (sprite.updateCallback() == 0x0ffff) - continue; + Common::List<Sprite>::const_iterator i; + for (i = _spriteTable.begin(); i != _spriteTable.end(); ++i) { + const Sprite &sprite = *i; + assert(sprite._updateCallback != 0x0ffff); if (priority != sprite.priority) continue; if (sprite.hidden == 1) @@ -64,24 +58,27 @@ void DreamBase::printASprite(const Sprite *sprite) { c = 8; else c = 0; - showFrame((const Frame *)getSegment(sprite->frameData()).ptr(0, 0), x, y, sprite->frameNumber, c); + showFrame((const Frame *)getSegment(sprite->_frameData).ptr(0, 0), x, y, sprite->frameNumber, c); } void DreamBase::clearSprites() { - memset(spriteTable(), 0xff, sizeof(Sprite) * 16); + _spriteTable.clear(); } Sprite *DreamBase::makeSprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi) { - Sprite *sprite = spriteTable(); - while (sprite->frameNumber != 0xff) { // NB: No boundchecking in the original code either - ++sprite; - } + // Note: the original didn't append sprites here, but filled up the + // first unused entry. This can change the order of entries, but since they + // are drawn based on the priority field, this shouldn't matter. + _spriteTable.push_back(Sprite()); + Sprite *sprite = &_spriteTable.back(); + + memset(sprite, 0xff, sizeof(Sprite)); - sprite->setUpdateCallback(updateCallback); + sprite->_updateCallback = updateCallback; sprite->x = x; sprite->y = y; - sprite->setFrameData(frameData); - WRITE_LE_UINT16(&sprite->w8, somethingInDi); + sprite->_frameData = frameData; + sprite->w8 = somethingInDi; sprite->w2 = 0xffff; sprite->frameNumber = 0; sprite->delay = 0; @@ -89,25 +86,25 @@ Sprite *DreamBase::makeSprite(uint8 x, uint8 y, uint16 updateCallback, uint16 fr } void DreamBase::spriteUpdate() { - Sprite *sprites = spriteTable(); - sprites[0].hidden = data.byte(kRyanon); - - Sprite *sprite = sprites; - for (size_t i=0; i < 16; ++i) { - uint16 updateCallback = sprite->updateCallback(); - if (updateCallback != 0xffff) { - sprite->w24 = sprite->w2; - if (updateCallback == addr_mainman) // NB : Let's consider the callback as an enum while more code is not ported to C++ - mainMan(sprite); - else { - assert(updateCallback == addr_backobject); - backObject(sprite); - } + // During the intro the sprite table can be empty + if (!_spriteTable.empty()) + _spriteTable.front().hidden = data.byte(kRyanon); + + Common::List<Sprite>::iterator i; + for (i = _spriteTable.begin(); i != _spriteTable.end(); ++i) { + Sprite &sprite = *i; + assert(sprite._updateCallback != 0xffff); + + sprite.w24 = sprite.w2; + if (sprite._updateCallback == addr_mainman) // NB : Let's consider the callback as an enum while more code is not ported to C++ + mainMan(&sprite); + else { + assert(sprite._updateCallback == addr_backobject); + backObject(&sprite); } if (data.byte(kNowinnewroom) == 1) break; - ++sprite; } } @@ -228,7 +225,7 @@ void DreamBase::aboutTurn(Sprite *sprite) { } void DreamBase::backObject(Sprite *sprite) { - SetObject *objData = (SetObject *)getSegment(data.word(kSetdat)).ptr(sprite->objData(), 0); + SetObject *objData = (SetObject *)getSegment(data.word(kSetdat)).ptr(sprite->_objData, 0); if (sprite->delay != 0) { --sprite->delay; @@ -474,25 +471,26 @@ const Frame *DreamBase::getReelFrameAX(uint16 frame) { } void DreamBase::showRain() { - Rain *rain = (Rain *)getSegment(data.word(kBuffers)).ptr(kRainlist, 0); + Common::List<Rain>::iterator i; // Do nothing if there's no rain at all - if (rain->x == 255) + if (_rainList.empty()) return; const Frame *frame = (const Frame *)getSegment(data.word(kMainsprites)).ptr(58 * sizeof(Frame), sizeof(Frame)); const uint8 *frameData = getSegment(data.word(kMainsprites)).ptr(kFrframes + frame->ptr(), 512); - for (; rain->x != 255; ++rain) { - uint16 y = rain->y + data.word(kMapady) + data.word(kMapystart); - uint16 x = rain->x + data.word(kMapadx) + data.word(kMapxstart); - uint16 size = rain->size; - uint16 offset = (rain->w3() - rain->b5) & 511; - rain->setW3(offset); + for (i = _rainList.begin(); i != _rainList.end(); ++i) { + Rain &rain = *i; + uint16 y = rain.y + data.word(kMapady) + data.word(kMapystart); + uint16 x = rain.x + data.word(kMapadx) + data.word(kMapxstart); + uint16 size = rain.size; + uint16 offset = (rain.w3 - rain.b5) & 511; + rain.w3 = offset; const uint8 *src = frameData + offset; uint8 *dst = workspace() + y * 320 + x; - for (uint16 i = 0; i < size; ++i) { - uint8 v = src[i]; + for (uint16 j = 0; j < size; ++j) { + uint8 v = src[j]; if (v != 0) *dst = v; dst += 320-1; // advance diagonally @@ -538,21 +536,10 @@ void DreamBase::moveMap(uint8 param) { data.byte(kNowinnewroom) = 1; } -void DreamGenContext::checkOne() { - uint8 flag, flagEx, type, flagX, flagY; - checkOne(cl, ch, &flag, &flagEx, &type, &flagX, &flagY); - - cl = flag; - ch = flagEx; - dl = flagX; - dh = flagY; - al = type; -} - void DreamBase::checkOne(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uint8 *type, uint8 *flagX, uint8 *flagY) { *flagX = x / 16; *flagY = y / 16; - const uint8 *tileData = getSegment(data.word(kBuffers)).ptr(kMapflags + (*flagY * 11 + *flagX) * 3, 3); + const uint8 *tileData = &_mapFlags[(*flagY * 11 + *flagX) * 3]; *flag = tileData[0]; *flagEx = tileData[1]; *type = tileData[2]; @@ -567,18 +554,20 @@ uint8 DreamBase::getBlockOfPixel(uint8 x, uint8 y) { return type; } -Rain *DreamBase::splitIntoLines(uint8 x, uint8 y, Rain *rain) { +void DreamBase::splitIntoLines(uint8 x, uint8 y) { do { + Rain rain; + // Look for line start while (!getBlockOfPixel(x, y)) { --x; ++y; if (x == 0 || y >= data.byte(kMapysize)) - return rain; + return; } - rain->x = x; - rain->y = y; + rain.x = x; + rain.y = y; uint8 length = 1; @@ -591,14 +580,11 @@ Rain *DreamBase::splitIntoLines(uint8 x, uint8 y, Rain *rain) { ++length; } - rain->size = length; - rain->w3_lo = engine->randomNumber(); - rain->w3_hi = engine->randomNumber(); - rain->b5 = (engine->randomNumber() & 3) + 4; - ++rain; + rain.size = length; + rain.w3 = (engine->randomNumber() << 8) | engine->randomNumber(); + rain.b5 = (engine->randomNumber() & 3) + 4; + _rainList.push_back(rain); } while (x > 0 && y < data.byte(kMapysize)); - - return rain; } struct RainLocation { @@ -640,8 +626,7 @@ static const RainLocation rainLocationList[] = { void DreamBase::initRain() { const RainLocation *r = rainLocationList; - Rain *rainList = (Rain *)getSegment(data.word(kBuffers)).ptr(kRainlist, 0); - Rain *rain = rainList; + _rainList.clear(); uint8 rainSpacing = 0; @@ -656,7 +641,6 @@ void DreamBase::initRain() { if (rainSpacing == 0) { // location not found in rainLocationList: no rain - rain->x = 0xff; return; } @@ -672,7 +656,7 @@ void DreamBase::initRain() { if (x >= data.byte(kMapxsize)) break; - rain = splitIntoLines(x, 0, rain); + splitIntoLines(x, 0); } while (true); // start lines of rain from side of screen @@ -687,10 +671,8 @@ void DreamBase::initRain() { if (y >= data.byte(kMapysize)) break; - rain = splitIntoLines(data.byte(kMapxsize) - 1, y, rain); + splitIntoLines(data.byte(kMapxsize) - 1, y); } while (true); - - rain->x = 0xff; } void DreamBase::intro1Text() { @@ -723,50 +705,6 @@ void DreamBase::intro3Text(uint16 nextReelPointer) { setupTimedTemp(46, 82, 36, 56, 100, 1); } -void DreamBase::rollEndCredits() { - playChannel0(16, 255); - data.byte(kVolume) = 7; - data.byte(kVolumeto) = 0; - data.byte(kVolumedirection) = (byte)-1; - - multiGet(mapStore(), 75, 20, 160, 160); - - const uint8 *string = getTextInFile1(3); - const int linespacing = data.word(kLinespacing); - - for (int i = 0; i < 254; ++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(), 75, 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, 75, &y, 160 + 1, true); - y += linespacing; - } - - vSync(); - multiDump(75, 20, 160, 160); - } - - // Skip to the next text line - byte c; - do { - c = *string++; - } while (c != ':' && c != 0); - } - hangOn(100); - panelToMap(); - fadeScreenUpHalf(); -} - - void DreamBase::monks2text() { bool isGermanCD = isCD() && engine->getLanguage() == Common::DE_DEU; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 313f3caf0b..b0a168930b 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -30,13 +30,9 @@ namespace DreamGen { struct Sprite { uint16 _updateCallback; - uint16 updateCallback() const { return READ_LE_UINT16(&_updateCallback); } - void setUpdateCallback(uint16 v) { WRITE_LE_UINT16(&_updateCallback, v); } uint16 w2; uint16 w4; uint16 _frameData; - uint16 frameData() const { return READ_LE_UINT16(&_frameData); } - void setFrameData(uint16 v) { WRITE_LE_UINT16(&_frameData, v); } uint16 w8; uint8 x; uint8 y; @@ -48,8 +44,6 @@ struct Sprite { uint8 delay; uint8 animFrame; // index into SetObject::frames uint16 _objData; - uint16 objData() const { return READ_LE_UINT16(&_objData); } - void setObjData(uint16 v) { WRITE_LE_UINT16(&_objData, v); } uint8 speed; uint8 priority; uint16 w24; @@ -62,10 +56,11 @@ struct Sprite { class DreamGenContext; +template <class T = DreamGenContext> struct RectWithCallback { uint16 _xMin, _xMax; uint16 _yMin, _yMax; - void (DreamGenContext::*_callback)(); + void (T::*_callback)(); bool contains(uint16 x, uint16 y) const { return (x >= _xMin) && (x < _xMax) && (y >= _yMin) && (y < _yMax); @@ -125,10 +120,10 @@ struct DynObject { uint8 currentLocation; uint8 index; uint8 mapad[5]; - uint8 slotSize; - uint8 slotCount; - uint8 b9; - uint8 b10; + uint8 slotSize; // the size of an object's slots + uint8 slotCount; // the number of slots of an object + uint8 objectSize; // the size of an object + uint8 turnedOn; uint8 initialLocation; uint8 id[4]; }; @@ -178,14 +173,8 @@ struct ReelRoutine { }; struct People { - uint8 b0; - uint8 b1; - uint16 reelPointer() const { return READ_LE_UINT16(&b0); } - void setReelPointer(uint16 v) { WRITE_LE_UINT16(&b0, v); } - uint8 b2; - uint8 b3; - uint16 routinePointer() const { return READ_LE_UINT16(&b2); } - void setRoutinePointer(uint16 v) { WRITE_LE_UINT16(&b2, v); } + uint16 _reelPointer; + ReelRoutine *_routinePointer; uint8 b4; }; @@ -218,10 +207,7 @@ struct Rain { uint8 x; uint8 y; uint8 size; - uint8 w3_lo; - uint8 w3_hi; - uint16 w3() const { return READ_LE_UINT16(&w3_lo); } - void setW3(uint16 v) { WRITE_LE_UINT16(&w3_lo, v); } + uint16 w3; uint8 b5; }; @@ -235,10 +221,10 @@ struct Change { struct PathNode { uint8 x; uint8 y; - uint8 b2; - uint8 b3; - uint8 b4; - uint8 b5; + uint8 x1; + uint8 y1; + uint8 x2; + uint8 y2; uint8 on; uint8 dir; }; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 6989a57a93..413bd27c85 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -21,7 +21,6 @@ */ #include "dreamweb/dreamweb.h" -#include "engines/util.h" #include "common/config-manager.h" namespace DreamGen { @@ -329,23 +328,23 @@ static const Atmosphere g_atmosphereList[] = { { 10,33,30,6,255 }, { 10,22,30,6,255 }, - + { 9,22,10,6,255 }, { 9,22,20,16,255 }, { 9,22,30,16,255 }, { 9,22,40,16,255 }, { 9,22,50,16,255 }, - + { 6,11,30,6,255 }, { 6,0,10,15,255 }, { 6,0,20,15,255 }, { 6,11,20,15,255 }, { 6,22,20,15,255 }, - + { 7,11,20,6,255 }, { 7,0,20,6,255 }, { 7,0,30,6,255 }, - + { 55,44,0,5,255 }, { 55,44,10,5,255 }, @@ -367,12 +366,12 @@ static const Atmosphere g_atmosphereList[] = { { 8,33,40,6,255 }, { 8,22,40,6,255 }, { 8,11,40,6,255 }, - + { 11,11,20,12,255 }, { 11,11,30,12,255 }, { 11,22,20,12,255 }, { 11,22,30,12,255 }, - + { 12,22,20,12,255 }, { 13,22,20,12,255 }, { 13,33,20,12,255 }, @@ -384,7 +383,7 @@ static const Atmosphere g_atmosphereList[] = { { 14,33,30,12,255 }, { 14,33,40,12,255 }, { 14,22,0,16,255 }, - + { 19,0,0,12,255 }, { 20,0,20,16,255 }, @@ -495,7 +494,7 @@ void DreamGenContext::dreamweb() { while (true) { - unsigned int count = scanForNames(); + uint count = scanForNames(); bool startNewGame = true; @@ -509,7 +508,7 @@ void DreamGenContext::dreamweb() { clearPalette(); doLoad(savegameId); - workToScreenCPP(); + workToScreen(); fadeScreenUp(); startNewGame = false; @@ -544,6 +543,7 @@ void DreamGenContext::dreamweb() { // "playGame" // "titles" + // TODO: In the demo version, titles() did nothing clearPalette(); bibleQuote(); if (!quitRequested()) // "titlesearly" @@ -707,7 +707,7 @@ void DreamGenContext::screenUpdate() { delPointer(); } -void DreamGenContext::startup() { +void DreamBase::startup() { data.byte(kCurrentkey) = 0; data.byte(kMainmode) = 0; createPanel(); @@ -728,7 +728,7 @@ void DreamGenContext::startup1() { startup(); - workToScreenCPP(); + workToScreen(); fadeScreenUp(); } @@ -740,10 +740,6 @@ void DreamBase::switchRyanOff() { data.byte(kRyanon) = 1; } -uint8 *DreamBase::textUnder() { - return getSegment(data.word(kBuffers)).ptr(kTextunder, 0); -} - uint16 DreamBase::standardLoad(const char *fileName, uint16 *outSizeInBytes) { FileHeader header; @@ -833,25 +829,17 @@ void DreamBase::dumpTextLine() { } void DreamBase::getUnderTimed() { - uint16 y = data.byte(kTimedy); if (data.byte(kForeignrelease)) - y -= 3; - multiGet(getSegment(data.word(kBuffers)).ptr(kUndertimedtext, 0), data.byte(kTimedx), y, 240, kUndertimedysize); + multiGet(_underTimedText, data.byte(kTimedx), data.byte(kTimedy) - 3, 240, kUnderTimedTextSizeY_f); + else + multiGet(_underTimedText, data.byte(kTimedx), data.byte(kTimedy), 240, kUnderTimedTextSizeY); } void DreamBase::putUnderTimed() { - uint16 y = data.byte(kTimedy); if (data.byte(kForeignrelease)) - y -= 3; - multiPut(getSegment(data.word(kBuffers)).ptr(kUndertimedtext, 0), data.byte(kTimedx), y, 240, kUndertimedysize); -} - -void DreamBase::getUnderCentre() { - multiGet(mapStore(), 58, 72, 254, 110); -} - -void DreamBase::putUnderCentre() { - multiPut(mapStore(), 58, 72, 254, 110); + multiPut(_underTimedText, data.byte(kTimedx), data.byte(kTimedy) - 3, 240, kUnderTimedTextSizeY_f); + else + multiPut(_underTimedText, data.byte(kTimedx), data.byte(kTimedy), 240, kUnderTimedTextSizeY); } void DreamGenContext::triggerMessage(uint16 index) { @@ -861,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; } @@ -989,19 +977,21 @@ void DreamBase::DOSReturn() { } } -void DreamGenContext::set16ColPalette() { -} - void DreamBase::eraseOldObs() { if (data.byte(kNewobs) == 0) return; - Sprite *sprites = spriteTable(); - for (size_t i = 0; i < 16; ++i) { - Sprite &sprite = sprites[i]; - if (sprite.objData() != 0xffff) { - memset(&sprite, 0xff, sizeof(Sprite)); - } + // Note: the original didn't delete sprites here, but marked the + // entries as unused, to be filled again by makeSprite. This can + // change the order of entries, but since they are drawn based on the + // priority field, this shouldn't matter. + Common::List<Sprite>::iterator i; + for (i = _spriteTable.begin(); i != _spriteTable.end(); ) { + Sprite &sprite = *i; + if (sprite._objData != 0xffff) + i = _spriteTable.erase(i); + else + ++i; } } @@ -1052,7 +1042,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; @@ -1142,15 +1132,10 @@ void DreamBase::crosshair() { } void DreamBase::delTextLine() { - uint16 x = data.word(kTextaddressx); - uint16 y = data.word(kTextaddressy); - if (data.byte(kForeignrelease) != 0) - y -= 3; - multiPut(textUnder(), x, y, kUndertextsizex, kUndertextsizey); -} - -void DreamGenContext::commandOnly() { - commandOnly(al); + if (data.byte(kForeignrelease)) + multiPut(_textUnder, data.byte(kTextaddressx), data.word(kTextaddressy) - 3, kUnderTextSizeX_f, kUnderTextSizeY_f); + else + multiPut(_textUnder, data.byte(kTextaddressx), data.word(kTextaddressy), kUnderTextSizeX, kUnderTextSizeY); } void DreamBase::commandOnly(uint8 command) { @@ -1163,17 +1148,11 @@ void DreamBase::commandOnly(uint8 command) { data.byte(kNewtextline) = 1; } -void DreamGenContext::checkIfPerson() { - flags._z = !checkIfPerson(al, ah); -} - bool DreamGenContext::checkIfPerson(uint8 x, uint8 y) { - People *people = (People *)getSegment(data.word(kBuffers)).ptr(kPeoplelist, 0); - - for (size_t i = 0; i < 12; ++i, ++people) { - if (people->b4 == 255) - continue; - Reel *reel = getReelStart(people->reelPointer()); + Common::List<People>::iterator i; + for (i = _peopleList.begin(); i != _peopleList.end(); ++i) { + People &people = *i; + Reel *reel = getReelStart(people._reelPointer); if (reel->frame() == 0xffff) ++reel; const Frame *frame = getReelFrameAX(reel->frame()); @@ -1189,40 +1168,34 @@ bool DreamGenContext::checkIfPerson(uint8 x, uint8 y) { continue; if (y >= ymax) continue; - data.word(kPersondata) = people->routinePointer(); - obName(people->b4, 5); + _personData = people._routinePointer; + obName(people.b4, 5); return true; } return false; } -void DreamGenContext::checkIfFree() { - flags._z = !checkIfFree(al, ah); -} - bool DreamGenContext::checkIfFree(uint8 x, uint8 y) { - const ObjPos *freeList = (const ObjPos *)getSegment(data.word(kBuffers)).ptr(kFreelist, 80 * sizeof(ObjPos)); - for (size_t i = 0; i < 80; ++i) { - const ObjPos *objPos = freeList + 79 - i; - if (objPos->index == 0xff || !objPos->contains(x,y)) + Common::List<ObjPos>::const_iterator i; + for (i = _freeList.reverse_begin(); i != _freeList.end(); --i) { + const ObjPos &pos = *i; + assert(pos.index != 0xff); + if (!pos.contains(x,y)) continue; - obName(objPos->index, 2); + obName(pos.index, 2); return true; } return false; } -void DreamGenContext::checkIfEx() { - flags._z = !checkIfEx(al, ah); -} - bool DreamGenContext::checkIfEx(uint8 x, uint8 y) { - const ObjPos *exList = (const ObjPos *)getSegment(data.word(kBuffers)).ptr(kExlist, 100 * sizeof(ObjPos)); - for (size_t i = 0; i < 100; ++i) { - const ObjPos *objPos = exList + 99 - i; - if (objPos->index == 0xff || !objPos->contains(x,y)) + Common::List<ObjPos>::const_iterator i; + for (i = _exList.reverse_begin(); i != _exList.end(); --i) { + const ObjPos &pos = *i; + assert(pos.index != 0xff); + if (!pos.contains(x,y)) continue; - obName(objPos->index, 4); + obName(pos.index, 4); return true; } return false; @@ -1251,7 +1224,7 @@ const uint8 *DreamBase::findObName(uint8 type, uint8 index) { void DreamBase::copyName(uint8 type, uint8 index, uint8 *dst) { const uint8 *src = findObName(type, index); size_t i; - for (i = 0; i < 28; ++i) { + for (i = 0; i < 28; ++i) { char c = src[i]; if (c == ':') break; @@ -1262,11 +1235,7 @@ void DreamBase::copyName(uint8 type, uint8 index, uint8 *dst) { dst[i] = 0; } -void DreamGenContext::commandWithOb() { - commandWithOb(al, bh, bl); -} - -void DreamGenContext::commandWithOb(uint8 command, uint8 type, uint8 index) { +void DreamBase::commandWithOb(uint8 command, uint8 type, uint8 index) { uint8 commandLine[64] = "OBJECT NAME ONE "; delTextLine(); uint16 commandText = kTextstart + getSegment(data.word(kCommandtext)).word(command * 2); @@ -1283,24 +1252,24 @@ void DreamGenContext::commandWithOb(uint8 command, uint8 type, uint8 index) { data.byte(kNewtextline) = 1; } -void DreamGenContext::examineObText() { +void DreamBase::examineObText() { commandWithOb(1, data.byte(kCommandtype), data.byte(kCommand)); } -void DreamGenContext::blockNameText() { +void DreamBase::blockNameText() { commandWithOb(0, data.byte(kCommandtype), data.byte(kCommand)); } -void DreamGenContext::personNameText() { +void DreamBase::personNameText() { commandWithOb(2, data.byte(kCommandtype), data.byte(kCommand) & 127); } -void DreamGenContext::walkToText() { +void DreamBase::walkToText() { commandWithOb(3, data.byte(kCommandtype), data.byte(kCommand)); } void DreamBase::findOrMake(uint8 index, uint8 value, uint8 type) { - Change *change = (Change *)getSegment(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); + Change *change = _listOfChanges; for (; change->index != 0xff; ++change) { if (index == change->index && data.byte(kReallocation) == change->location && type == change->type) { change->value = value; @@ -1314,8 +1283,8 @@ void DreamBase::findOrMake(uint8 index, uint8 value, uint8 type) { change->type = type; } -void DreamGenContext::setAllChanges() { - Change *change = (Change *)getSegment(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); +void DreamBase::setAllChanges() { + Change *change = _listOfChanges; for (; change->index != 0xff; ++change) if (change->location == data.byte(kReallocation)) doChange(change->index, change->value, change->type); @@ -1336,16 +1305,16 @@ DynObject *DreamBase::getEitherAdCPP() { return getFreeAd(data.byte(kItemframe)); } -void *DreamBase::getAnyAd(uint8 *value1, uint8 *value2) { +void *DreamBase::getAnyAd(uint8 *slotSize, uint8 *slotCount) { if (data.byte(kObjecttype) == kExObjectType) { DynObject *exObject = getExAd(data.byte(kCommand)); - *value1 = exObject->slotSize; - *value2 = exObject->slotCount; + *slotSize = exObject->slotSize; + *slotCount = exObject->slotCount; return exObject; } else if (data.byte(kObjecttype) == kFreeObjectType) { DynObject *freeObject = getFreeAd(data.byte(kCommand)); - *value1 = freeObject->slotSize; - *value2 = freeObject->slotCount; + *slotSize = freeObject->slotSize; + *slotCount = freeObject->slotCount; return freeObject; } else { // 1 or 3. 0 should never happen SetObject *setObject = getSetAd(data.byte(kCommand)); @@ -1353,8 +1322,8 @@ void *DreamBase::getAnyAd(uint8 *value1, uint8 *value2) { // instead of slotSize/slotCount (bytes 3 and 4). // Changed this for consistency with the Ex/Free cases, and also // with getOpenedSize() - *value1 = setObject->slotSize; - *value2 = setObject->slotCount; + *slotSize = setObject->slotSize; + *slotCount = setObject->slotCount; return setObject; } } @@ -1386,7 +1355,7 @@ void DreamBase::doChange(uint8 index, uint8 value, uint8 type) { } } -void DreamGenContext::deleteTaken() { +void DreamBase::deleteTaken() { const DynObject *extraObjects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0); DynObject *freeObjects = (DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0); for (size_t i = 0; i < kNumexobjects; ++i) { @@ -1422,11 +1391,7 @@ void DreamBase::removeSetObject(uint8 index) { getSetAd(index)->mapad[0] = 0xff; } -void DreamGenContext::finishedWalking() { - flags._z = finishedWalkingCPP(); -} - -bool DreamGenContext::finishedWalkingCPP() { +bool DreamBase::finishedWalking() { return (data.byte(kLinepointer) == 254) && (data.byte(kFacing) == data.byte(kTurntoface)); } @@ -1437,7 +1402,7 @@ void DreamBase::getFlagUnderP(uint8 *flag, uint8 *flagEx) { } void DreamGenContext::walkAndExamine() { - if (!finishedWalkingCPP()) + if (!finishedWalking()) return; data.byte(kCommandtype) = data.byte(kWalkexamtype); data.byte(kCommand) = data.byte(kWalkexamnum); @@ -1446,10 +1411,6 @@ void DreamGenContext::walkAndExamine() { examineOb(); } -void DreamGenContext::obName() { - obName(al, ah); -} - void DreamGenContext::obName(uint8 command, uint8 commandType) { if (data.byte(kReasseschanges) == 0) { if ((commandType == data.byte(kCommandtype)) && (command == data.byte(kCommand))) { @@ -1464,7 +1425,7 @@ void DreamGenContext::obName(uint8 command, uint8 commandType) { setWalk(); data.byte(kReasseschanges) = 1; return; - } else if (! finishedWalkingCPP()) + } else if (!finishedWalking()) return; else if (data.byte(kCommandtype) == 5) { if (data.word(kWatchingtime) == 0) @@ -1529,7 +1490,7 @@ void DreamBase::delPointer() { data.word(kDelherey) = data.word(kOldpointery); data.byte(kDelxs) = data.byte(kPointerxs); data.byte(kDelys) = data.byte(kPointerys); - multiPut(getSegment(data.word(kBuffers)).ptr(kPointerback, 0), data.word(kDelherex), data.word(kDelherey), data.byte(kPointerxs), data.byte(kPointerys)); + multiPut(_pointerBack, data.word(kDelherex), data.word(kDelherey), data.byte(kPointerxs), data.byte(kPointerys)); } void DreamBase::showBlink() { @@ -1570,14 +1531,15 @@ void DreamBase::dumpPointer() { multiDump(data.word(kOldpointerx), data.word(kOldpointery), data.byte(kPointerxs), data.byte(kPointerys)); } -void DreamGenContext::checkCoords(const RectWithCallback *rectWithCallbacks) { +template <class T> +void DreamBase::checkCoords(const RectWithCallback<T> *rectWithCallbacks) { if (data.byte(kNewlocation) != 0xff) return; - const RectWithCallback *r; + const RectWithCallback<T> *r; for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) { if (r->contains(data.word(kMousex), data.word(kMousey))) { - (this->*(r->_callback))(); + (((T *)this)->*(r->_callback))(); return; } } @@ -1608,7 +1570,7 @@ void DreamBase::showPointer() { uint16 yMin = (y >= height / 2) ? y - height / 2 : 0; data.word(kOldpointerx) = xMin; data.word(kOldpointery) = yMin; - multiGet(getSegment(data.word(kBuffers)).ptr(kPointerback, 0), xMin, yMin, width, height); + multiGet(_pointerBack, xMin, yMin, width, height); showFrame(frames, x, y, 3 * data.byte(kItemframe) + 1, 128); showFrame(engine->icons1(), x, y, 3, 128); } else { @@ -1621,7 +1583,7 @@ void DreamBase::showPointer() { height = 12; data.byte(kPointerxs) = width; data.byte(kPointerys) = height; - multiGet(getSegment(data.word(kBuffers)).ptr(kPointerback, 0), x, y, width, height); + multiGet(_pointerBack, x, y, width, height); showFrame(engine->icons1(), x, y, data.byte(kPointerframe) + 20, 0); } } @@ -1695,8 +1657,8 @@ void DreamBase::printMessage2(uint16 x, uint16 y, uint8 index, uint8 maxWidth, b printDirect(string, x, y, maxWidth, centered); } -static bool objectMatches(void *object, const char *id) { - const char *objId = (const char *)(((const uint8 *)object) + 12); // whether it is a DynObject or a SetObject +bool DreamBase::objectMatches(void *object, const char *id) { + const char *objId = (const char *)object + 12; // whether it is a DynObject or a SetObject for (size_t i = 0; i < 4; ++i) { if (id[i] != objId[i] + 'A') return false; @@ -1704,11 +1666,6 @@ static bool objectMatches(void *object, const char *id) { return true; } -void DreamGenContext::compare() { - char id[4] = { cl, ch, dl, dh }; - flags._z = compare(al, ah, id); -} - bool DreamBase::compare(uint8 index, uint8 flag, const char id[4]) { return objectMatches(getAnyAdDir(index, flag), id); } @@ -1722,18 +1679,6 @@ uint16 DreamBase::findSetObject(const char *id) { return 128; } -void DreamGenContext::findExObject() { - char id[5]; - id[0] = al; - id[1] = ah; - id[2] = cl; - id[3] = ch; - id[4] = '\0'; - al = findExObject(id); - es = data.word(kExtras); - bx = kExdata + al * 16; -} - uint16 DreamBase::findExObject(const char *id) { for (uint16 index = 0; index < kNumexobjects; index++) { if (objectMatches(getExAd(index), id)) @@ -1743,16 +1688,6 @@ uint16 DreamBase::findExObject(const char *id) { return kNumexobjects; } -void DreamGenContext::isRyanHolding() { - char id[5]; - id[0] = al; - id[1] = ah; - id[2] = cl; - id[3] = ch; - id[4] = '\0'; - flags._z = !isRyanHolding(id); -} - bool DreamBase::isRyanHolding(const char *id) { for (uint16 index = 0; index < kNumexobjects; index++) { DynObject *object = getExAd(index); @@ -1796,30 +1731,23 @@ void DreamBase::showIcon() { } } -void DreamGenContext::checkIfSet() { - flags._z = !checkIfSet(al, ah); -} - bool DreamGenContext::checkIfSet(uint8 x, uint8 y) { - const ObjPos *setList = (const ObjPos *)getSegment(data.word(kBuffers)).ptr(kSetlist, sizeof(ObjPos) * 128); - for (size_t i = 0; i < 128; ++i) { - const ObjPos *pos = setList + 127 - i; - if (pos->index == 0xff || !pos->contains(x,y)) + Common::List<ObjPos>::const_iterator i; + for (i = _setList.reverse_begin(); i != _setList.end(); --i) { + const ObjPos &pos = *i; + assert(pos.index != 0xff); + if (!pos.contains(x,y)) continue; - if (! pixelCheckSet(pos, x, y)) + if (!pixelCheckSet(&pos, x, y)) continue; - if (! isItDescribed(pos)) + if (!isItDescribed(&pos)) continue; - obName(pos->index, 1); + obName(pos.index, 1); return true; } return false; } -void DreamGenContext::hangOn() { - hangOn(cx); -} - void DreamBase::hangOn(uint16 frameCount) { while (frameCount) { vSync(); @@ -1843,10 +1771,6 @@ void DreamBase::hangOnW(uint16 frameCount) { } } -void DreamGenContext::hangOnP() { - hangOnP(cx); -} - void DreamBase::hangOnP(uint16 count) { data.word(kMaintimer) = 0; uint8 pointerFrame = data.byte(kPointerframe); @@ -1880,13 +1804,6 @@ void DreamBase::hangOnP(uint16 count) { data.byte(kPointermode) = 0; } -void DreamGenContext::findNextColon() { - const uint8 *initialString = es.ptr(si, 0); - const uint8 *string = initialString; - al = findNextColon(&string); - si += (string - initialString); -} - uint8 DreamBase::findNextColon(const uint8 **string) { uint8 c; do { @@ -1896,16 +1813,6 @@ uint8 DreamBase::findNextColon(const uint8 **string) { return c; } -const uint8 *DreamGenContext::getObTextStartCPP() { - push(es); - push(si); - getObTextStart(); - const uint8 *result = es.ptr(si, 0); - si = pop(); - es = pop(); - return result; -} - void DreamGenContext::enterSymbol() { data.byte(kManisoffscreen) = 1; getRidOfReels(); @@ -1930,7 +1837,7 @@ void DreamGenContext::enterSymbol() { dumpPointer(); dumpTextLine(); dumpSymbol(); - RectWithCallback symbolList[] = { + RectWithCallback<DreamBase> symbolList[] = { { kSymbolx+40,kSymbolx+64,kSymboly+2,kSymboly+16,&DreamBase::quitSymbol }, { kSymbolx,kSymbolx+52,kSymboly+20,kSymboly+50,&DreamBase::setTopLeft }, { kSymbolx+52,kSymbolx+104,kSymboly+20,kSymboly+50,&DreamBase::setTopRight }, @@ -2001,16 +1908,10 @@ void DreamBase::sortOutMap() { } } -void DreamGenContext::showCity() { - clearWork(); - showFrame(tempGraphics(), 57, 32, 0, 0); - showFrame(tempGraphics(), 120+57, 32, 1, 0); -} - void DreamGenContext::mainScreen() { data.byte(kInmaparea) = 0; if (data.byte(kWatchon) == 1) { - RectWithCallback mainList[] = { + RectWithCallback<DreamGenContext> mainList[] = { { 44,70,32,46,&DreamGenContext::look }, { 0,50,0,180,&DreamGenContext::inventory }, { 226,244,10,26,&DreamGenContext::zoomOnOff }, @@ -2021,7 +1922,7 @@ void DreamGenContext::mainScreen() { }; checkCoords(mainList); } else { - RectWithCallback mainList2[] = { + RectWithCallback<DreamGenContext> mainList2[] = { { 44,70,32,46,&DreamGenContext::look }, { 0,50,0,180,&DreamGenContext::inventory }, { 226+48,244+48,10,26,&DreamGenContext::zoomOnOff }, @@ -2117,7 +2018,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; @@ -2136,10 +2037,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() { @@ -2321,7 +2218,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) { engine->closeFile(); } -void DreamGenContext::restoreAll() { +void DreamBase::restoreAll() { const Room &room = g_roomData[data.byte(kLocation)]; loadRoomData(room, true); setAllChanges(); @@ -2472,14 +2369,6 @@ void DreamBase::examIcon() { showFrame(engine->icons2(), 254, 5, 3, 0); } -uint8 DreamBase::getLocation(uint8 index) { - return data.byte(kRoomscango + index); -} - -void DreamBase::setLocation(uint8 index) { - data.byte(kRoomscango + index) = 1; -} - const uint8 *DreamBase::getTextInFile1(uint16 index) { SegmentRef text = getSegment(data.word(kTextfile1)); uint16 offset = text.word(index * 2) + kTextstart; @@ -2487,18 +2376,18 @@ const uint8 *DreamBase::getTextInFile1(uint16 index) { return string; } -void DreamGenContext::checkFolderCoords() { - RectWithCallback folderList[] = { +void DreamBase::checkFolderCoords() { + RectWithCallback<DreamBase> folderList[] = { { 280,320,160,200, &DreamBase::quitKey }, - { 143,300,6,194, &DreamGenContext::nextFolder }, - { 0,143,6,194, &DreamGenContext::lastFolder }, + { 143,300,6,194, &DreamBase::nextFolder }, + { 0,143,6,194, &DreamBase::lastFolder }, { 0,320,0,200, &DreamBase::blank }, { 0xFFFF,0,0,0, 0 } }; checkCoords(folderList); } -void DreamGenContext::nextFolder() { +void DreamBase::nextFolder() { if (data.byte(kFolderpage) == 12) { blank(); return; @@ -2518,7 +2407,7 @@ void DreamGenContext::nextFolder() { } } -void DreamGenContext::lastFolder() { +void DreamBase::lastFolder() { if (data.byte(kFolderpage) == 0) { blank(); return; @@ -2601,7 +2490,7 @@ void DreamBase::workToScreenM() { readMouse(); showPointer(); vSync(); - workToScreenCPP(); + workToScreen(); delPointer(); } @@ -2621,7 +2510,7 @@ void DreamBase::dumpMenu() { multiDump(kMenux, kMenuy, 48, 48); } -void DreamGenContext::useMenu() { +void DreamBase::useMenu() { getRidOfReels(); loadMenu(); createPanel(); @@ -2645,7 +2534,7 @@ void DreamGenContext::useMenu() { dumpPointer(); dumpMenu(); dumpTextLine(); - RectWithCallback menuList[] = { + RectWithCallback<DreamBase> menuList[] = { { kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamBase::quitKey }, { 0,320,0,200,&DreamBase::blank }, { 0xFFFF,0,0,0,0 } @@ -2660,7 +2549,7 @@ void DreamGenContext::useMenu() { workToScreenM(); } -void DreamGenContext::atmospheres() { +void DreamBase::atmospheres() { const Atmosphere *a = &g_atmosphereList[0]; @@ -2684,8 +2573,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) @@ -2722,16 +2611,6 @@ void DreamGenContext::atmospheres() { cancelCh0(); } -void DreamGenContext::readCityPic() { - loadIntoTemp("DREAMWEB.G04"); -} - -void DreamGenContext::readDestIcon() { - loadIntoTemp("DREAMWEB.G05"); - loadIntoTemp2("DREAMWEB.G06"); - loadIntoTemp3("DREAMWEB.G08"); -} - uint8 DreamGenContext::nextSymbol(uint8 symbol) { uint8 result = symbol + 1; if (result == 6) @@ -2771,308 +2650,6 @@ void DreamBase::readKey() { data.word(kBufferout) = bufOut; } -void DreamGenContext::hangOne(uint16 delay) { - do { - vSync(); - if (data.byte(kLasthardkey) == 1) - return; // "hangonearly" - } while (--delay); -} - -void DreamGenContext::hangOne() { - hangOne(cx); -} - -void DreamGenContext::bibleQuote() { - initGraphics(640, 480, true); - - showPCX("DREAMWEB.I00"); - fadeScreenUps(); - - hangOne(80); - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "biblequotearly" - } - - hangOne(560); - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "biblequotearly" - } - - fadeScreenDowns(); - - hangOne(200); - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "biblequotearly" - } - - cancelCh0(); - - data.byte(kLasthardkey) = 0; -} - -void DreamGenContext::realCredits() { - data.byte(kRoomssample) = 33; - loadRoomsSample(); - data.byte(kVolume) = 0; - - initGraphics(640, 480, true); - hangOn(35); - - showPCX("DREAMWEB.I01"); - playChannel0(12, 0); - - hangOne(2); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - allPalette(); - hangOne(80); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - showPCX("DREAMWEB.I02"); - playChannel0(12, 0); - hangOne(2); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - allPalette(); - hangOne(80); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - showPCX("DREAMWEB.I03"); - playChannel0(12, 0); - hangOne(2); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - allPalette(); - hangOne(80); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - showPCX("DREAMWEB.I04"); - playChannel0(12, 0); - hangOne(2); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - allPalette(); - hangOne(80); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - showPCX("DREAMWEB.I05"); - playChannel0(12, 0); - hangOne(2); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - allPalette(); - hangOne(80); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - showPCX("DREAMWEB.I06"); - fadeScreenUps(); - hangOne(60); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - playChannel0(13, 0); - hangOne(350); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "realcreditsearly" - } - - fadeScreenDowns(); - hangOne(256); - - data.byte(kLasthardkey) = 0; -} - -void DreamGenContext::runIntroSeq() { - data.byte(kGetback) = 0; - - do { - vSync(); - - if (data.byte(kLasthardkey) == 1) - break; - - spriteUpdate(); - vSync(); - - if (data.byte(kLasthardkey) == 1) - break; - - delEverything(); - printSprites(); - reelsOnScreen(); - afterIntroRoom(); - useTimedText(); - vSync(); - - if (data.byte(kLasthardkey) == 1) - break; - - dumpMap(); - dumpTimedText(); - vSync(); - - if (data.byte(kLasthardkey) == 1) - break; - - } while (data.byte(kGetback) != 1); - - - if (data.byte(kLasthardkey) == 1) { - getRidOfTempText(); - clearBeforeLoad(); - } - - // These were not called in this program arc - // in the original code.. Bug? - //getRidOfTempText(); - //clearBeforeLoad(); -} - -void DreamGenContext::intro() { - loadTempText("DREAMWEB.T82"); - loadPalFromIFF(); - setMode(); - data.byte(kNewlocation) = 50; - clearPalette(); - loadIntroRoom(); - data.byte(kVolume) = 7; - data.byte(kVolumedirection) = (byte)-1; - data.byte(kVolumeto) = 4; - playChannel0(12, 255); - fadeScreenUps(); - runIntroSeq(); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "introearly" - } - - clearBeforeLoad(); - data.byte(kNewlocation) = 52; - loadIntroRoom(); - runIntroSeq(); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "introearly" - } - - clearBeforeLoad(); - data.byte(kNewlocation) = 53; - loadIntroRoom(); - runIntroSeq(); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "introearly" - } - - clearBeforeLoad(); - allPalette(); - data.byte(kNewlocation) = 54; - loadIntroRoom(); - runIntroSeq(); - - if (data.byte(kLasthardkey) == 1) { - data.byte(kLasthardkey) = 0; - return; // "introearly" - } - - getRidOfTempText(); - clearBeforeLoad(); - - data.byte(kLasthardkey) = 0; -} - void DreamBase::setTopLeft() { if (data.byte(kSymboltopdir) != 0) { blank(); @@ -3133,7 +2710,7 @@ void DreamBase::setBotRight() { data.byte(kSymbolbotdir) = 1; } -void DreamGenContext::newGame() { +void DreamBase::newGame() { if (data.byte(kCommandtype) != 251) { data.byte(kCommandtype) = 251; commandOnly(47); @@ -3143,27 +2720,6 @@ void DreamGenContext::newGame() { data.byte(kGetback) = 3; } -void DreamBase::getBackFromOps() { - if (data.byte(kMandead) == 2) - blank(); - else - getBack1(); -} - -void DreamBase::getBackToOps() { - if (data.byte(kCommandtype) != 201) { - data.byte(kCommandtype) = 201; - commandOnly(42); - } - - if (data.word(kMousebutton) != data.word(kOldbutton)) { - if (data.word(kMousebutton) & 1) { - oldToNames(); - data.byte(kGetback) = 2; - } - } -} - void DreamGenContext::pickupOb(uint8 command, uint8 pos) { data.byte(kLastinvpos) = pos; data.byte(kObjecttype) = kFreeObjectType; @@ -3201,26 +2757,7 @@ void DreamGenContext::walkIntoRoom() { } } -void DreamGenContext::loadIntroRoom() { - data.byte(kIntrocount) = 0; - data.byte(kLocation) = 255; - loadRoom(); - data.word(kMapoffsetx) = 72; - data.word(kMapoffsety) = 16; - clearSprites(); - data.byte(kThroughdoor) = 0; - data.byte(kCurrentkey) = '0'; - data.byte(kMainmode) = 0; - clearWork(); - data.byte(kNewobs) = 1; - drawFloor(); - reelsOnScreen(); - spriteUpdate(); - printSprites(); - workToScreenCPP(); -} - -void DreamGenContext::afterIntroRoom() { +void DreamBase::afterIntroRoom() { if (data.byte(kNowinnewroom) == 0) return; // notnewintro @@ -3231,22 +2768,11 @@ void DreamGenContext::afterIntroRoom() { reelsOnScreen(); spriteUpdate(); printSprites(); - workToScreenCPP(); + workToScreen(); data.byte(kNowinnewroom) = 0; } -void DreamGenContext::gettingShot() { - data.byte(kNewlocation) = 55; - clearPalette(); - loadIntroRoom(); - fadeScreenUps(); - data.byte(kVolumeto) = 0; - data.byte(kVolumedirection) = (byte)-1; - runEndSeq(); - clearBeforeLoad(); -} - -void DreamGenContext::redrawMainScrn() { +void DreamBase::redrawMainScrn() { data.word(kTimecount) = 0; createPanel(); data.byte(kNewobs) = 0; @@ -3297,7 +2823,7 @@ void DreamBase::openInv() { data.byte(kCommandtype) = 255; } -void DreamGenContext::obsThatDoThings() { +void DreamBase::obsThatDoThings() { if (!compare(data.byte(kCommand), data.byte(kObjecttype), "MEMB")) return; // notlouiscard @@ -3307,8 +2833,8 @@ void DreamGenContext::obsThatDoThings() { } } -void DreamGenContext::describeOb() { - const uint8 *obText = getObTextStartCPP(); +void DreamBase::describeOb() { + const uint8 *obText = getObTextStart(); uint16 y = 92; if (data.byte(kForeignrelease) && data.byte(kObjecttype) == kSetObjectType1) y = 82; @@ -3335,7 +2861,7 @@ void DreamGenContext::describeOb() { } } -void DreamGenContext::delEverything() { +void DreamBase::delEverything() { if (data.byte(kMapysize) + data.word(kMapoffsety) < 182) { mapToPanel(); } else { @@ -3351,7 +2877,7 @@ void DreamGenContext::errorMessage1() { printMessage(76, 21, 58, 240, (240 & 1)); readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); hangOnP(50); showPanel(); @@ -3360,7 +2886,7 @@ void DreamGenContext::errorMessage1() { readMouse(); useOpened(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); } @@ -3370,7 +2896,7 @@ void DreamGenContext::errorMessage2() { printMessage(76, 21, 59, 240, (240 & 1)); readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); hangOnP(50); showPanel(); @@ -3379,7 +2905,7 @@ void DreamGenContext::errorMessage2() { readMouse(); useOpened(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); } @@ -3394,90 +2920,15 @@ void DreamGenContext::errorMessage3() { readMouse(); useOpened(); showPointer(); - workToScreenCPP(); - delPointer(); -} - -void DreamGenContext::reExFromOpen() { - -} - -void DreamGenContext::nextDest() { - if (data.byte(kCommandtype) != 218) { - data.byte(kCommandtype) = 218; - commandOnly(28); - } - - if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) - return; // nodu - - do { - data.byte(kDestpos)++; - if (data.byte(kDestpos) == 15) - data.byte(kDestpos) = 0; // last destination - - getDestInfo(); - } while (al == 0); - - data.byte(kNewtextline) = 1; - delTextLine(); - delPointer(); - showPanel(); - showMan(); - showArrows(); - locationPic(); - underTextLine(); - readMouse(); - showPointer(); - workToScreenCPP(); - delPointer(); -} - -void DreamGenContext::lastDest() { - if (data.byte(kCommandtype) != 219) { - data.byte(kCommandtype) = 219; - commandOnly(29); - } - - if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) - return; // nodd - - do { - data.byte(kDestpos)--; - if (data.byte(kDestpos) == 0xFF) - data.byte(kDestpos) = 15; // first destination - - getDestInfo(); - } while (al == 0); - - data.byte(kNewtextline) = 1; - delTextLine(); - delPointer(); - showPanel(); - showMan(); - showArrows(); - locationPic(); - underTextLine(); - readMouse(); - showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); } -void DreamGenContext::destSelect() { - if (data.byte(kCommandtype) != 222) { - data.byte(kCommandtype) = 222; - commandOnly(30); - } - - if (!(data.word(kMousebutton) & 1) || data.word(kOldbutton) == 1) - return; // notrav +void DreamBase::reExFromOpen() { - getDestInfo(); - data.byte(kNewlocation) = data.byte(kDestpos); } -void DreamGenContext::putBackObStuff() { +void DreamBase::putBackObStuff() { createPanel(); showPanel(); showMan(); @@ -3489,62 +2940,10 @@ void DreamGenContext::putBackObStuff() { data.byte(kCommandtype) = 255; readMouse(); showPointer(); - workToScreenCPP(); - delPointer(); -} - -void DreamGenContext::redes() { - if (data.byte(kCh1playing) != 255 || data.byte(kTalkmode) != 2) { - blank(); - return; - } - - if (data.byte(kCommandtype) != 217) { - data.byte(kCommandtype) = 217; - commandOnly(50); - } - - if (!(data.word(kMousebutton) & 1)) - return; - - delPointer(); - createPanel(); - showPanel(); - showMan(); - showExit(); - convIcons(); - startTalk(); - readMouse(); - showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); } -void DreamGenContext::moreTalk() { - if (data.byte(kTalkmode) != 0) { - redes(); - return; - } - - if (data.byte(kCommandtype) != 215) { - data.byte(kCommandtype) = 215; - commandOnly(49); - } - - if (data.word(kMousebutton) == data.word(kOldbutton)) - return; // nomore - - if (!(data.word(kMousebutton) & 1)) - return; - - data.byte(kTalkmode) = 2; - data.byte(kTalkpos) = 4; - - if (data.byte(kCharacter) >= 100) - data.byte(kTalkpos) = 48; // second part - doSomeTalk(); -} - bool DreamBase::isSetObOnMap(uint8 index) { return (getSetAd(index)->mapad[0] == 0); } @@ -3554,68 +2953,6 @@ void DreamBase::dumpZoom() { multiDump(kZoomx + 5, kZoomy + 4, 46, 40); } -void DreamGenContext::selectLocation() { - data.byte(kInmaparea) = 0; - clearBeforeLoad(); - data.byte(kGetback) = 0; - data.byte(kPointerframe) = 22; - readCityPic(); - showCity(); - getRidOfTemp(); - readDestIcon(); - loadTravelText(); - showPanel(); - showMan(); - showArrows(); - showExit(); - locationPic(); - underTextLine(); - data.byte(kCommandtype) = 255; - readMouse(); - data.byte(kPointerframe) = 0; - showPointer(); - workToScreenCPP(); - playChannel0(9, 255); - data.byte(kNewlocation) = 255; - - while (data.byte(kNewlocation) == 255) { - if (quitRequested()) - break; - - delPointer(); - readMouse(); - showPointer(); - vSync(); - dumpPointer(); - dumpTextLine(); - - if (data.byte(kGetback) == 1) - break; - - RectWithCallback destList[] = { - { 238,258,4,44,&DreamGenContext::nextDest }, - { 104,124,4,44,&DreamGenContext::lastDest }, - { 280,308,4,44,&DreamGenContext::lookAtPlace }, - { 104,216,138,192,&DreamGenContext::destSelect }, - { 273,320,157,198,&DreamBase::getBack1 }, - { 0,320,0,200,&DreamBase::blank }, - { 0xFFFF,0,0,0,0 } - }; - checkCoords(destList); - } - - if (quitRequested() || data.byte(kGetback) == 1 || data.byte(kNewlocation) == data.byte(kLocation)) { - data.byte(kNewlocation) = data.byte(kReallocation); - data.byte(kGetback) = 0; - } - - getRidOfTemp(); - getRidOfTemp2(); - getRidOfTemp3(); - deallocateMem(data.word(kTraveltext)); -} - - void DreamBase::examineInventory() { if (data.byte(kCommandtype) != 249) { data.byte(kCommandtype) = 249; @@ -3636,32 +2973,6 @@ void DreamBase::examineInventory() { workToScreenM(); } -void DreamBase::showArrows() { - showFrame(tempGraphics(), 116 - 12, 16, 0, 0); - showFrame(tempGraphics(), 226 + 12, 16, 1, 0); - showFrame(tempGraphics(), 280, 14, 2, 0); -} - -void DreamBase::showOpBox() { - showFrame(tempGraphics(), kOpsx, kOpsy, 0, 0); - - // CHECKME: There seem to be versions of dreamweb in which this call - // should be removed. It displays a red dot on the ops dialogs if left in. - showFrame(tempGraphics(), kOpsx, kOpsy + 55, 4, 0); -} - -void DreamGenContext::showLoadOps() { - showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0); - showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); - printMessage(kOpsx + 104, kOpsy + 14, 55, 101, (101 & 1)); -} - -void DreamGenContext::showSaveOps() { - showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0); - showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0); - printMessage(kOpsx + 104, kOpsy + 14, 54, 101, (101 & 1)); -} - void DreamBase::middlePanel() { Frame *tempSprites = (Frame *)getSegment(data.word(kTempsprites)).ptr(0, 0); showFrame(tempSprites, 72 + 47 + 20, 0, 48, 0); @@ -3676,25 +2987,18 @@ void DreamBase::showDiary() { } void DreamBase::underTextLine() { - uint16 y = data.word(kTextaddressy); if (data.byte(kForeignrelease)) - y -= 3; - multiGet(textUnder(), data.byte(kTextaddressx), y, kUndertextsizex, kUndertextsizey); -} - -void DreamGenContext::showDecisions() { - createPanel2(); - showOpBox(); - showFrame(tempGraphics(), kOpsx + 17, kOpsy + 13, 6, 0); - underTextLine(); + multiGet(_textUnder, data.byte(kTextaddressx), data.word(kTextaddressy) - 3, kUnderTextSizeX_f, kUnderTextSizeY_f); + else + multiGet(_textUnder, data.byte(kTextaddressx), data.word(kTextaddressy), kUnderTextSizeX, kUnderTextSizeY); } void DreamBase::getUnderZoom() { - multiGet(getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), kZoomx + 5, kZoomy + 4, 46, 40); + multiGet(_zoomSpace, kZoomx + 5, kZoomy + 4, 46, 40); } void DreamBase::putUnderZoom() { - multiPut(getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), kZoomx + 5, kZoomy + 4, 46, 40); + multiPut(_zoomSpace, kZoomx + 5, kZoomy + 4, 46, 40); } void DreamBase::showWatchReel() { @@ -3763,10 +3067,7 @@ void DreamGenContext::afterNewRoom() { data.byte(kCommandtype) = 0; findRoomInLoc(); if (data.byte(kRyanon) != 1) { - al = data.byte(kRyanx) + 12; - ah = data.byte(kRyany) + 12; - findPathOfPoint(); - data.byte(kManspath) = dl; + data.byte(kManspath) = findPathOfPoint(data.byte(kRyanx) + 12, data.byte(kRyany) + 12); findXYFromPath(); data.byte(kResetmanxy) = 1; } @@ -3784,7 +3085,7 @@ void DreamGenContext::afterNewRoom() { zoom(); workToScreenM(); walkIntoRoom(); - reminders(); + edensFlatReminders(); atmospheres(); } @@ -3821,12 +3122,12 @@ void DreamGenContext::decide() { data.byte(kManisoffscreen) = 1; loadSaveBox(); showDecisions(); - workToScreenCPP(); + workToScreen(); fadeScreenUp(); data.byte(kGetback) = 0; - RectWithCallback decideList[] = { - { kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamGenContext::newGame }, + RectWithCallback<DreamGenContext> decideList[] = { + { kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamBase::newGame }, { kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamBase::DOSReturn }, { kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamGenContext::loadOld }, { 0,320,0,200,&DreamBase::blank }, @@ -3854,146 +3155,6 @@ void DreamGenContext::decide() { data.byte(kTextlen) = 240; } -void DreamGenContext::talk() { - data.byte(kTalkpos) = 0; - data.byte(kInmaparea) = 0; - data.byte(kCharacter) = data.byte(kCommand); - createPanel(); - showPanel(); - showMan(); - showExit(); - underTextLine(); - convIcons(); - startTalk(); - data.byte(kCommandtype) = 255; - readMouse(); - showPointer(); - workToScreenCPP(); - - RectWithCallback talkList[] = { - { 273,320,157,198,&DreamBase::getBack1 }, - { 240,290,2,44,&DreamGenContext::moreTalk }, - { 0,320,0,200,&DreamBase::blank }, - { 0xFFFF,0,0,0,0 } - }; - - do { - delPointer(); - readMouse(); - animPointer(); - showPointer(); - vSync(); - dumpPointer(); - dumpTextLine(); - data.byte(kGetback) = 0; - checkCoords(talkList); - if (data.byte(kQuitrequested)) - break; - } while (!data.byte(kGetback)); - - if (data.byte(kTalkpos) >= 4) - data.byte(data.word(kPersondata)+7) |= 128; - - redrawMainScrn(); - workToScreenM(); - if (data.byte(kSpeechloaded) == 1) { - cancelCh1(); - data.byte(kVolumedirection) = (byte)-1; - data.byte(kVolumeto) = 0; - } -} - -void DreamGenContext::discOps() { - if (data.byte(kCommandtype) != 249) { - data.byte(kCommandtype) = 249; - commandOnly(43); - } - - if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) - return; - - scanForNames(); - data.byte(kLoadingorsave) = 2; - showOpBox(); - showDiscOps(); - data.byte(kCurrentslot) = 0; - workToScreenM(); - data.byte(kGetback) = 0; - - RectWithCallback discOpsList[] = { - { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::loadGame }, - { kOpsx+10,kOpsx+79,kOpsy+10,kOpsy+59,&DreamGenContext::saveGame }, - { kOpsx+176,kOpsx+192,kOpsy+60,kOpsy+76,&DreamGenContext::getBackToOps }, - { 0,320,0,200,&DreamBase::blank }, - { 0xFFFF,0,0,0,0 } - }; - - do { - if (data.byte(kQuitrequested) != 0) - return; // quitdiscops - - delPointer(); - readMouse(); - showPointer(); - vSync(); - dumpPointer(); - dumpTextLine(); - checkCoords(discOpsList); - } while (!data.byte(kGetback)); -} - -void DreamGenContext::hangOnPQ() { - data.byte(kGetback) = 0; - - RectWithCallback quitList[] = { - { 273,320,157,198,&DreamBase::getBack1 }, - { 0,320,0,200,&DreamBase::blank }, - { 0xFFFF,0,0,0,0 } - }; - - uint16 speechFlag = 0; - - do { - delPointer(); - readMouse(); - animPointer(); - showPointer(); - vSync(); - dumpPointer(); - dumpTextLine(); - checkCoords(quitList); - - if (data.byte(kGetback) == 1 || data.byte(kQuitrequested)) { - // Quit conversation - delPointer(); - data.byte(kPointermode) = 0; - cancelCh1(); - flags._c = true; - return; - } - - if (data.byte(kSpeechloaded) == 1 && data.byte(kCh1playing) == 255) { - speechFlag++; - if (speechFlag == 40) - break; - } - } while (!data.word(kMousebutton) || data.word(kOldbutton)); - - delPointer(); - data.byte(kPointermode) = 0; - flags._c = false; - } - -void DreamGenContext::endGame() { - loadTempText("DREAMWEB.T83"); - monkSpeaking(); - gettingShot(); - getRidOfTempText(); - data.byte(kVolumeto) = 7; - data.byte(kVolumedirection) = 1; - hangOn(200); -} - void DreamGenContext::showGun() { data.byte(kAddtored) = 0; data.byte(kAddtogreen) = 0; @@ -4020,13 +3181,13 @@ void DreamGenContext::showGun() { createPanel2(); showFrame(tempGraphics(), 100, 4, 0, 0); showFrame(tempGraphics(), 158, 106, 1, 0); - workToScreenCPP(); + workToScreen(); getRidOfTemp(); fadeScreenUp(); hangOn(160); playChannel0(12, 0); loadTempText("DREAMWEB.T83"); - rollEndCredits2(); + rollEndCreditsGameLost(); getRidOfTempText(); } @@ -4070,7 +3231,7 @@ void DreamBase::diaryKeyN() { data.byte(kDiarypage) = 0; } -void DreamGenContext::dropError() { +void DreamBase::dropError() { data.byte(kCommandtype) = 255; delPointer(); printMessage(76, 21, 56, 240, 240 & 1); @@ -4083,7 +3244,7 @@ void DreamGenContext::dropError() { workToScreenM(); } -void DreamGenContext::cantDrop() { +void DreamBase::cantDrop() { data.byte(kCommandtype) = 255; delPointer(); printMessage(76, 21, 24, 240, 240 & 1); @@ -4118,74 +3279,10 @@ void DreamBase::getBack1() { } } -void DreamGenContext::newPlace() { - if (data.byte(kNeedtotravel) == 1) { - data.byte(kNeedtotravel) = 0; - selectLocation(); - } else if (data.byte(kAutolocation) != 0xFF) { - data.byte(kNewlocation) = data.byte(kAutolocation); - data.byte(kAutolocation) = 0xFF; - } -} - -void DreamGenContext::monkSpeaking() { - // FIXME: This is the CD version only. - - data.byte(kRoomssample) = 35; - loadRoomsSample(); - loadIntoTemp("DREAMWEB.G15"); - clearWork(); - showFrame(tempGraphics(), 160, 72, 0, 128); // show monk - workToScreen(); - data.byte(kVolume) = 7; - data.byte(kVolumedirection) = (byte)-1; - data.byte(kVolumeto) = 5; - playChannel0(12, 255); - fadeScreenUps(); - hangOn(300); - - for (int i = 40; i <= 48; i++) { - loadSpeech('T', 83, 'T', i); - - playChannel1(50 + 12); - - do { - engine->waitForVSync(); - } while (data.byte(kCh1playing) != 255); - } - - data.byte(kVolumedirection) = 1; - data.byte(kVolumeto) = 7; - fadeScreenDowns(); - hangOn(300); - getRidOfTemp(); -} - -void DreamGenContext::useButtonA() { - if (!isSetObOnMap(95)) { - showFirstUse(); - turnAnyPathOn(0, data.byte(kRoomnum) - 1); - removeSetObject(9); - placeSetObject(95); - data.word(kWatchingtime) = 15 * 2; - data.word(kReeltowatch) = 71; - data.word(kEndwatchreel) = 85; - data.byte(kWatchspeed) = 1; - data.byte(kSpeedcount) = 1; - data.byte(kGetback) = 1; - data.byte(kProgresspoints)++; - } else { - // Done this bit - showSecondUse(); - putBackObStuff(); - } -} - -void DreamGenContext::autoAppear() { +void DreamBase::autoAppear() { if (data.byte(kLocation) == 32) { // In alley - al = 5; - resetLocation(); + resetLocation(5); setLocation(10); data.byte(kDestpos) = 10; return; @@ -4215,8 +3312,7 @@ void DreamGenContext::autoAppear() { if (data.byte(kReallocation) == 25) { // Sart roof data.byte(kNewsitem) = 3; - al = 6; - resetLocation(); + resetLocation(6); setLocation(11); data.byte(kDestpos) = 11; } else { @@ -4236,10 +3332,6 @@ void DreamBase::quitKey() { data.byte(kGetback) = 1; } -void DreamGenContext::setupTimedUse() { - DreamBase::setupTimedUse(al, cx, dx, bl, bh); -} - void DreamBase::setupTimedUse(uint16 textIndex, uint16 countToTimed, uint16 timeCount, byte x, byte y) { if (data.word(kTimecount) != 0) return; // can't setup @@ -4282,7 +3374,7 @@ void DreamBase::entryTexts() { } } -void DreamGenContext::entryAnims() { +void DreamBase::entryAnims() { data.word(kReeltowatch) = 0xFFFF; data.byte(kWatchmode) = (byte)-1; @@ -4296,8 +3388,7 @@ void DreamGenContext::entryAnims() { data.byte(kSpeedcount) = 1; break; case 44: // Sparky's - al = 8; - resetLocation(); + resetLocation(8); data.word(kWatchingtime) = 50*2; data.word(kReeltowatch) = 247; data.word(kEndwatchreel) = 297; @@ -4434,7 +3525,7 @@ void DreamGenContext::updateSymbolBot() { } } -void DreamGenContext::showDiaryPage() { +void DreamBase::showDiaryPage() { showFrame(tempGraphics(), kDiaryx, kDiaryy, 0, 0); data.byte(kKerning) = 1; useTempCharset(); @@ -4451,7 +3542,7 @@ void DreamGenContext::showDiaryPage() { useCharset1(); } -void DreamGenContext::dumpDiaryKeys() { +void DreamBase::dumpDiaryKeys() { if (data.byte(kPresscount) == 1) { if (data.byte(kSartaindead) != 1 && data.byte(kDiarypage) == 5 && getLocation(6) != 1) { // Add Sartain Industries note @@ -4477,33 +3568,13 @@ void DreamGenContext::dumpDiaryKeys() { multiDump(kDiaryx + 151, kDiaryy + 71, 16, 16); } -void DreamGenContext::runEndSeq() { - atmospheres(); - data.byte(kGetback) = 0; - - do { - vSync(); - spriteUpdate(); - vSync(); - delEverything(); - printSprites(); - reelsOnScreen(); - afterIntroRoom(); - useTimedText(); - vSync(); - dumpMap(); - dumpTimedText(); - vSync(); - } while (data.byte(kGetback) != 1); -} - -void DreamGenContext::lookAtCard() { +void DreamBase::lookAtCard() { data.byte(kManisoffscreen) = 1; getRidOfReels(); loadKeypad(); createPanel2(); showFrame(tempGraphics(), 160, 80, 42, 128); - const uint8 *obText = getObTextStartCPP(); + const uint8 *obText = getObTextStart(); findNextColon(&obText); findNextColon(&obText); findNextColon(&obText); @@ -4522,35 +3593,22 @@ void DreamGenContext::lookAtCard() { putBackObStuff(); } -void DreamGenContext::showSlots() { - showFrame(tempGraphics(), kOpsx + 7, kOpsy + 8, 2, 0); - - uint16 y = kOpsy + 11; - - for (int slot = 0; slot < 7; slot++) { - if (slot == data.byte(kCurrentslot)) - showFrame(tempGraphics(), kOpsx + 10, y, 3, 0); - - y += 10; - } -} - void DreamBase::clearBuffers() { memset(getSegment(data.word(kBuffers)).ptr(0, kLengthofbuffer), 0, kLengthofbuffer); memset(getSegment(data.word(kExtras)).ptr(0, kLengthofextra), 0xFF, kLengthofextra); - memcpy(getSegment(data.word(kBuffers)).ptr(kInitialvars, kLengthofvars), data.ptr(kStartvars, kLengthofvars), kLengthofvars); + memcpy(_initialVars, data.ptr(kStartvars, kLengthofvars), kLengthofvars); clearChanges(); } void DreamBase::clearChanges() { - memset(getSegment(data.word(kBuffers)).ptr(kListofchanges, 4*kNumchanges), 0xFF, 4*kNumchanges); + memset(_listOfChanges, 0xFF, 4*kNumchanges); setupInitialReelRoutines(); - memcpy(data.ptr(kStartvars, kLengthofvars), getSegment(data.word(kBuffers)).ptr(kInitialvars, kLengthofvars), kLengthofvars); + memcpy(data.ptr(kStartvars, kLengthofvars), _initialVars, kLengthofvars); data.byte(kExpos) = 0; data.word(kExframepos) = 0; @@ -4563,7 +3621,7 @@ void DreamBase::clearChanges() { memcpy(data.ptr(kRoomscango, 16), initialRoomsCanGo, 16); } -void DreamGenContext::showDiaryKeys() { +void DreamBase::showDiaryKeys() { if (!data.byte(kPresscount)) return; // nokeyatall @@ -4584,36 +3642,83 @@ void DreamGenContext::showDiaryKeys() { showDiaryPage(); } -void DreamGenContext::lookAtPlace() { - if (data.byte(kCommandtype) != 224) { - data.byte(kCommandtype) = 224; - commandOnly(27); +void DreamBase::edensFlatReminders() { + if (data.byte(kReallocation) != 24 || data.byte(kMapx) != 44) + return; // not in Eden's lift + + if (data.byte(kProgresspoints)) + return; // not the first time in Eden's apartment + + uint16 exObjextIndex = findExObject("CSHR"); + if (!isRyanHolding("DKEY") || exObjextIndex == kNumexobjects) { + setupTimedUse(50, 48, 8, 54, 70); // forgot something + return; + } + + DynObject *object = getExAd(exObjextIndex); + + if (object->mapad[0] != 4) { + setupTimedUse(50, 48, 8, 54, 70); // forgot something + return; + } else if (object->mapad[1] != 255) { + if (!compare(object->mapad[1], object->mapad[0], "PURS")) { + setupTimedUse(50, 48, 8, 54, 70); // forgot something + return; + } + } + + data.byte(kProgresspoints)++; // got card +} + +void DreamBase::incRyanPage() { + if (data.byte(kCommandtype) != 222) { + data.byte(kCommandtype) = 222; + commandOnly(31); } - if (!(data.word(kMousebutton) & 1) || - data.word(kMousebutton) == data.word(kOldbutton) || - data.byte(kDestpos) >= 15) - return; // noinfo + if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) + return; + + data.byte(kRyanpage) = (data.word(kMousex) - (kInventx + 167)) / 18; delPointer(); - delTextLine(); - getUnderCentre(); - showFrame(tempGraphics3(), 60, 72, 0, 0); - showFrame(tempGraphics3(), 60, 72 + 55, 4, 0); - if (data.byte(kForeignrelease)) - showFrame(tempGraphics3(), 60, 72+55+21, 4, 0); + fillRyan(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); - uint16 offset = kTextstart + getSegment(data.word(kTraveltext)).word(data.byte(kDestpos) * 2); - const uint8 *string = getSegment(data.word(kTraveltext)).ptr(offset, 0); - findNextColon(&string); - uint16 y = (data.byte(kForeignrelease)) ? 84 + 4 : 84; - printDirect(&string, 63, &y, 191, 191 & 1); - workToScreenM(); - hangOnP(500); - data.byte(kPointermode) = 0; - data.byte(kPointerframe) = 0; - putUnderCentre(); - workToScreenM(); +} + +void DreamBase::emergencyPurge() { + while (true) { + if (data.word(kExframepos) + 4000 < kExframeslen) { + // Not near frame end + if (data.word(kExtextpos) + 400 < kExtextlen) + return; // notneartextend + } + + purgeAnItem(); + } +} + +void DreamBase::purgeAnItem() { + const DynObject *extraObjects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0); + + for (size_t i = 0; i < kNumexobjects; ++i) { + if (extraObjects[i].mapad[0] && extraObjects[i].id[0] == 255 && + extraObjects[i].initialLocation != data.byte(kReallocation)) { + deleteExObject(i); + return; + } + } + + for (size_t i = 0; i < kNumexobjects; ++i) { + if (extraObjects[i].mapad[0] && extraObjects[i].id[0] == 255) { + deleteExObject(i); + return; + } + } } } // End of namespace DreamGen diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 1a76a785b8..7301ba9158 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -23,10 +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) { DreamBase::multiGet(dst, x, y, width, height); @@ -41,8 +38,6 @@ } void quickQuit(); void readOneBlock(); - void readCityPic(); - void readDestIcon(); void seeCommandTail(); void quickQuit2(); void printDirect(); @@ -52,100 +47,37 @@ 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); - } - void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) { - DreamBase::showFrame(frameData, x, y, frameNumber, effectsFlag); - } void width160(); - void zoom(); - void commandOnly(); - void commandOnly(uint8 command) { - DreamBase::commandOnly(command); - } - void checkIfPerson(); bool checkIfPerson(uint8 x, uint8 y); - void checkIfFree(); bool checkIfFree(uint8 x, uint8 y); - void checkIfEx(); bool checkIfEx(uint8 x, uint8 y); - void commandWithOb(); - void commandWithOb(uint8 command, uint8 type, uint8 index); - void blockNameText(); - void walkToText(); - void personNameText(); DynObject *getFreeAd(uint8 index) { return DreamBase::getFreeAd(index); } DynObject *getExAd(uint8 index) { return DreamBase::getExAd(index); } - void *getAnyAd(uint8 *value1, uint8 *value2) { - return DreamBase::getAnyAd(value1, value2); + void *getAnyAd(uint8 *slotSize, uint8 *slotCount) { + return DreamBase::getAnyAd(slotSize, slotCount); } SetObject *getSetAd(uint8 index) { return DreamBase::getSetAd(index); } - void setAllChanges(); - void deleteTaken(); - bool finishedWalkingCPP(); - void finishedWalking(); - void checkOne(); - void checkOne(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uint8 *type, uint8 *flagX, uint8 *flagY) { - DreamBase::checkOne(x, y, flag, flagEx, type, flagX, flagY); - } void walkAndExamine(); - void obName(); void obName(uint8 command, uint8 commandType); - void checkCoords(const RectWithCallback *rectWithCallbacks); + void getExPos(); - void compare(); - bool compare(uint8 index, uint8 flag, const char id[4]) { - return DreamBase::compare(index, flag, id); - } - bool pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y); - void checkIfSet(); bool checkIfSet(uint8 x, uint8 y); - void isItWorn(); - bool isItWorn(const DynObject *object) { - return DreamBase::isItWorn(object); - } - void wornError(); - void makeWorn(); - void makeWorn(DynObject *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 hangOnP(); - void hangOnP(uint16 count) { - DreamBase::hangOnP(count); - } - uint8 findNextColon(const uint8 **string) { - return DreamBase::findNextColon(string); - } - void findNextColon(); - const uint8 *getObTextStartCPP(); - void useText(const uint8 *string); - void examineObText(); - void showCity(); - uint16 getPersFrame(uint8 index); - void convIcons(); void examineOb(bool examineAgain = true); void dumpWatch(); void transferText(); void watchCount(); - void loadRoom(); void readSetData(); - void useMenu(); void useMon(); void makeCaps(); byte makeCaps(byte c) { @@ -163,219 +95,54 @@ void monMessage(uint8 index) { DreamBase::monMessage(index); } - void playChannel1(); - void playChannel1(uint8 index) { - DreamBase::playChannel1(index); - } void look(); void autoLook(); void doLook(); - void showFirstUse(); - void showSecondUse(); - void actualSave(); - void actualLoad(); - void restoreAll(); void enterSymbol(); - void viewFolder(); - void edensCDPlayer(); - void hotelBell(); - void playGuitar(); - void callEdensDLift(); - void callEdensLift(); - void sitDownInBar(); - void trapDoor(); - void useBalcony(); - void useChurchHole(); - void useCoveredBox(); - void useElevator1(); - void useElevator2(); - void useElevator3(); - void useElevator4(); - void useElevator5(); - void useDryer(); - void useRailing(); - void useWindow(); - void useHatch(); - void useLighter(); - void useSLab(); - void usePipe(); - void useOpenBox(); - void useAxe(); void useKey(); - void wheelSound(); - void callHotelLift(); - void useShield(); - void useWall(); - void useChurchGate(); - void useFullCart(); - void useClearBox(); - void usePlate(); - void usePlinth(); - void useElvDoor(); void useObject(); - void useWinch(); - void useCardReader1(); - void useCardReader2(); - void useCardReader3(); - void usePoolReader(); - void useCooker(); - void useWire(); - void useControl(); - void useHandle(); - void useAltar(); - bool defaultUseHandler(const char *id); - void openTVDoor(); - void wearWatch(); - void wearShades(); - void checkFolderCoords(); - void nextFolder(); - void lastFolder(); void singleKey(uint8 key, uint16 x, uint16 y); - void loadSaveBox(); 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(); - void realCredits(); - void runIntroSeq(); - void intro(); - void newGame(); void pickupOb(uint8 command, uint8 pos); void initialInv(); void walkIntoRoom(); - void loadIntroRoom(); - void afterIntroRoom(); - void gettingShot(); - void redrawMainScrn(); - void selectSlot(); - void selectSlot2(); void allPointer(); - void openYourNeighbour(); - void openRyan(); - void openPoolBoss(); - void openEden(); - void openSarters(); - void openLouis(); - void useLadder(); - void useLadderB(); - void useCart(); - void useTrainer(); - void useHole(); - void runTap(); - void chewy(); - void sLabDoorA(); - void sLabDoorB(); - void sLabDoorC(); - void sLabDoorE(); - void sLabDoorD(); - void sLabDoorF(); - void openHotelDoor(); - void openHotelDoor2(); - void grafittiDoor(); - void openTomb(); - void hotelControl(); - void obsThatDoThings(); - void delEverything(); void errorMessage1(); void errorMessage2(); void errorMessage3(); - void reExFromOpen(); - void nextDest(); - void lastDest(); - void destSelect(); - void putBackObStuff(); - void moreTalk(); - void redes(); - void selectLocation(); - void showGroup(); - void loadSpeech(); - bool loadSpeech(byte type1, int idx1, byte type2, int idx2) { - return DreamBase::loadSpeech(type1, idx1, type2, idx2); - } - void set16ColPalette(); - void showSaveOps(); - void showLoadOps(); void afterNewRoom(); void madmanRun(); - void showDecisions(); void decide(); - void talk(); - void discOps(); - void doSaveLoad(); - void useDiary(); - void hangOnPQ(); void showGun(); - void endGame(); - void checkInput(); - void dropError(); - void cantDrop(); - void newPlace(); - void monkSpeaking(); - void rollEndCredits2(); - void useButtonA(); - void autoAppear(); - void setupTimedUse(); - void entryAnims(); void triggerMessage(uint16 index); void processTrigger(); void updateSymbolTop(); void updateSymbolBot(); - void showDiaryPage(); - void dumpDiaryKeys(); - void runEndSeq(); - void lookAtCard(); bool execCommand(); - void findExObject(); - uint16 findExObject(const char *id) { - return DreamBase::findExObject(id); - } - void isRyanHolding(); - bool isRyanHolding(const char *id) { - return DreamBase::isRyanHolding(id); - } - void describeOb(); void getOpenedSize(); - byte getOpenedSizeCPP(); + byte getOpenedSlotSize(); + byte getOpenedSlotCount(); + bool checkObjectSizeCPP(); void openOb(); - void notHeldError(); - void useGun(); void identifyOb(); - void showSlots(); - void useCashCard(); - void useStereo(); void selectOb(); void findInvPos(); uint16 findInvPosCPP(); void setPickup(); - void showDiaryKeys(); - void showKeys(); void getKeyAndLogo(); - void deleteExObject(); - void deleteExObject(uint8 index) { - DreamBase::deleteExObject(index); - } - void deleteExFrame(); - void deleteExFrame(uint8 frameNum) { - DreamBase::deleteExFrame(frameNum); - } - void deleteExText(); - void deleteExText(uint8 textNum) { - DreamBase::deleteExText(textNum); - } void signOn(); - void lookAtPlace(); void inToInv(); void outOfInv(); + void selectOpenOb(); + void reExFromInv(); + void useOpened(); + void outOfOpen(); + void swapWithOpen(); + void swapWithInv(); + void searchForFiles(); #endif diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp index 86d1b886ef..a73a5091c0 100644 --- a/engines/dreamweb/talk.cpp +++ b/engines/dreamweb/talk.cpp @@ -24,15 +24,243 @@ namespace DreamGen { -uint16 DreamGenContext::getPersFrame(uint8 index) { - return getSegment(data.word(kPeople)).word(kPersonframes + index * 2); +void DreamBase::talk() { + data.byte(kTalkpos) = 0; + data.byte(kInmaparea) = 0; + data.byte(kCharacter) = data.byte(kCommand); + createPanel(); + showPanel(); + showMan(); + showExit(); + underTextLine(); + convIcons(); + startTalk(); + data.byte(kCommandtype) = 255; + readMouse(); + showPointer(); + workToScreen(); + + RectWithCallback<DreamGenContext> talkList[] = { + { 273,320,157,198,&DreamBase::getBack1 }, + { 240,290,2,44,&DreamBase::moreTalk }, + { 0,320,0,200,&DreamBase::blank }, + { 0xFFFF,0,0,0,0 } + }; + + do { + delPointer(); + readMouse(); + animPointer(); + showPointer(); + vSync(); + dumpPointer(); + dumpTextLine(); + data.byte(kGetback) = 0; + checkCoords(talkList); + if (data.byte(kQuitrequested)) + break; + } while (!data.byte(kGetback)); + + if (data.byte(kTalkpos) >= 4) + _personData->b7 |= 128; + + redrawMainScrn(); + workToScreenM(); + if (data.byte(kSpeechloaded) == 1) { + cancelCh1(); + data.byte(kVolumedirection) = (byte)-1; + data.byte(kVolumeto) = 0; + } } -void DreamGenContext::convIcons() { +void DreamBase::convIcons() { uint8 index = data.byte(kCharacter) & 127; uint16 frame = getPersFrame(index); const Frame *base = findSource(frame); showFrame(base, 234, 2, frame, 0); } +uint16 DreamBase::getPersFrame(uint8 index) { + return getSegment(data.word(kPeople)).word(kPersonframes + index * 2); +} + +void DreamBase::startTalk() { + data.byte(kTalkmode) = 0; + + const uint8 *str = getPersonText(data.byte(kCharacter) & 0x7F, 0); + uint16 y; + + data.word(kCharshift) = 91+91; + y = 64; + printDirect(&str, 66, &y, 241, true); + + data.word(kCharshift) = 0; + y = 80; + printDirect(&str, 66, &y, 241, true); + + data.byte(kSpeechloaded) = 0; + loadSpeech('R', data.byte(kReallocation), 'C', 64*(data.byte(kCharacter) & 0x7F)); + if (data.byte(kSpeechloaded) == 1) { + data.byte(kVolumedirection) = 1; + data.byte(kVolumeto) = 6; + playChannel1(50 + 12); + } +} + +const uint8 *DreamBase::getPersonText(uint8 index, uint8 talkPos) { + uint16 offset = kPersontext + getSegment(data.word(kPeople)).word(((index * 64 + talkPos) * 2) + kPersontxtdat); + return getSegment(data.word(kPeople)).ptr(offset, 0); +} + +void DreamBase::moreTalk() { + if (data.byte(kTalkmode) != 0) { + redes(); + return; + } + + if (data.byte(kCommandtype) != 215) { + data.byte(kCommandtype) = 215; + commandOnly(49); + } + + if (data.word(kMousebutton) == data.word(kOldbutton)) + return; // nomore + + if (!(data.word(kMousebutton) & 1)) + return; + + data.byte(kTalkmode) = 2; + data.byte(kTalkpos) = 4; + + if (data.byte(kCharacter) >= 100) + data.byte(kTalkpos) = 48; // second part + doSomeTalk(); +} + +void DreamBase::doSomeTalk() { + while (true) { + const uint8 *str = getPersonText(data.byte(kCharacter) & 0x7F, data.byte(kTalkpos)); + + if (*str == 0) { + // endheartalk + data.byte(kPointermode) = 0; + return; + } + + createPanel(); + showPanel(); + showMan(); + showExit(); + convIcons(); + + printDirect(str, 164, 64, 144, false); + + loadSpeech('R', data.byte(kReallocation), 'C', (64 * (data.byte(kCharacter) & 0x7F)) + data.byte(kTalkpos)); + if (data.byte(kSpeechloaded) != 0) + playChannel1(62); + + data.byte(kPointermode) = 3; + workToScreenM(); + if (hangOnPQ()) + return; + + data.byte(kTalkpos)++; + + str = getPersonText(data.byte(kCharacter) & 0x7F, data.byte(kTalkpos)); + if (*str == 0) { + // endheartalk + data.byte(kPointermode) = 0; + return; + } + + if (*str != ':' && *str != 32) { + createPanel(); + showPanel(); + showMan(); + showExit(); + convIcons(); + printDirect(str, 48, 128, 144, false); + + loadSpeech('R', data.byte(kReallocation), 'C', (64 * (data.byte(kCharacter) & 0x7F)) + data.byte(kTalkpos)); + if (data.byte(kSpeechloaded) != 0) + playChannel1(62); + + data.byte(kPointermode) = 3; + workToScreenM(); + if (hangOnPQ()) + return; + } + + data.byte(kTalkpos)++; + } +} + +bool DreamBase::hangOnPQ() { + data.byte(kGetback) = 0; + + RectWithCallback<DreamBase> quitList[] = { + { 273,320,157,198,&DreamBase::getBack1 }, + { 0,320,0,200,&DreamBase::blank }, + { 0xFFFF,0,0,0,0 } + }; + + uint16 speechFlag = 0; + + do { + delPointer(); + readMouse(); + animPointer(); + showPointer(); + vSync(); + dumpPointer(); + dumpTextLine(); + checkCoords(quitList); + + if (data.byte(kGetback) == 1 || data.byte(kQuitrequested)) { + // Quit conversation + delPointer(); + data.byte(kPointermode) = 0; + cancelCh1(); + return true; + } + + if (data.byte(kSpeechloaded) == 1 && data.byte(kCh1playing) == 255) { + speechFlag++; + if (speechFlag == 40) + break; + } + } while (!data.word(kMousebutton) || data.word(kOldbutton)); + + delPointer(); + data.byte(kPointermode) = 0; + return false; +} + +void DreamBase::redes() { + if (data.byte(kCh1playing) != 255 || data.byte(kTalkmode) != 2) { + blank(); + return; + } + + if (data.byte(kCommandtype) != 217) { + data.byte(kCommandtype) = 217; + commandOnly(50); + } + + if (!(data.word(kMousebutton) & 1)) + return; + + delPointer(); + createPanel(); + showPanel(); + showMan(); + showExit(); + convIcons(); + startTalk(); + readMouse(); + showPointer(); + workToScreen(); + delPointer(); +} + } // End of namespace DreamGen diff --git a/engines/dreamweb/titles.cpp b/engines/dreamweb/titles.cpp new file mode 100644 index 0000000000..a521036202 --- /dev/null +++ b/engines/dreamweb/titles.cpp @@ -0,0 +1,422 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" +#include "engines/util.h" + +namespace DreamGen { + +void DreamBase::endGame() { + loadTempText("DREAMWEB.T83"); + monkSpeaking(); + gettingShot(); + getRidOfTempText(); + data.byte(kVolumeto) = 7; + data.byte(kVolumedirection) = 1; + hangOn(200); +} + +void DreamBase::monkSpeaking() { + // FIXME: This is the CD version only. + + data.byte(kRoomssample) = 35; + loadRoomsSample(); + loadIntoTemp("DREAMWEB.G15"); + clearWork(); + showFrame(tempGraphics(), 160, 72, 0, 128); // show monk + workToScreen(); + data.byte(kVolume) = 7; + data.byte(kVolumedirection) = (byte)-1; + data.byte(kVolumeto) = 5; + playChannel0(12, 255); + fadeScreenUps(); + hangOn(300); + + for (int i = 40; i <= 48; i++) { + loadSpeech('T', 83, 'T', i); + + playChannel1(50 + 12); + + do { + engine->waitForVSync(); + } while (data.byte(kCh1playing) != 255); + } + + data.byte(kVolumedirection) = 1; + data.byte(kVolumeto) = 7; + fadeScreenDowns(); + hangOn(300); + getRidOfTemp(); +} + +void DreamBase::gettingShot() { + data.byte(kNewlocation) = 55; + clearPalette(); + loadIntroRoom(); + fadeScreenUps(); + data.byte(kVolumeto) = 0; + data.byte(kVolumedirection) = (byte)-1; + runEndSeq(); + clearBeforeLoad(); +} + +void DreamBase::bibleQuote() { + initGraphics(640, 480, true); + + showPCX("DREAMWEB.I00"); + fadeScreenUps(); + + hangOne(80); + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "biblequotearly" + } + + hangOne(560); + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "biblequotearly" + } + + fadeScreenDowns(); + + hangOne(200); + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "biblequotearly" + } + + cancelCh0(); + + data.byte(kLasthardkey) = 0; +} + +void DreamBase::hangOne(uint16 delay) { + do { + vSync(); + if (data.byte(kLasthardkey) == 1) + return; // "hangonearly" + } while (--delay); +} + +void DreamBase::intro() { + loadTempText("DREAMWEB.T82"); + loadPalFromIFF(); + setMode(); + data.byte(kNewlocation) = 50; + clearPalette(); + loadIntroRoom(); + data.byte(kVolume) = 7; + data.byte(kVolumedirection) = (byte)-1; + data.byte(kVolumeto) = 4; + playChannel0(12, 255); + fadeScreenUps(); + runIntroSeq(); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "introearly" + } + + clearBeforeLoad(); + data.byte(kNewlocation) = 52; + loadIntroRoom(); + runIntroSeq(); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "introearly" + } + + clearBeforeLoad(); + data.byte(kNewlocation) = 53; + loadIntroRoom(); + runIntroSeq(); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "introearly" + } + + clearBeforeLoad(); + allPalette(); + data.byte(kNewlocation) = 54; + loadIntroRoom(); + runIntroSeq(); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "introearly" + } + + getRidOfTempText(); + clearBeforeLoad(); + + data.byte(kLasthardkey) = 0; +} + +void DreamBase::runIntroSeq() { + data.byte(kGetback) = 0; + + do { + vSync(); + + if (data.byte(kLasthardkey) == 1) + break; + + spriteUpdate(); + vSync(); + + if (data.byte(kLasthardkey) == 1) + break; + + delEverything(); + printSprites(); + reelsOnScreen(); + afterIntroRoom(); + useTimedText(); + vSync(); + + if (data.byte(kLasthardkey) == 1) + break; + + dumpMap(); + dumpTimedText(); + vSync(); + + if (data.byte(kLasthardkey) == 1) + break; + + } while (data.byte(kGetback) != 1); + + + if (data.byte(kLasthardkey) == 1) { + getRidOfTempText(); + clearBeforeLoad(); + } + + // These were not called in this program arc + // in the original code.. Bug? + //getRidOfTempText(); + //clearBeforeLoad(); +} + +void DreamBase::runEndSeq() { + atmospheres(); + data.byte(kGetback) = 0; + + do { + vSync(); + spriteUpdate(); + vSync(); + delEverything(); + printSprites(); + reelsOnScreen(); + afterIntroRoom(); + useTimedText(); + vSync(); + dumpMap(); + dumpTimedText(); + vSync(); + } while (data.byte(kGetback) != 1); +} + +void DreamBase::loadIntroRoom() { + data.byte(kIntrocount) = 0; + data.byte(kLocation) = 255; + loadRoom(); + data.word(kMapoffsetx) = 72; + data.word(kMapoffsety) = 16; + clearSprites(); + data.byte(kThroughdoor) = 0; + data.byte(kCurrentkey) = '0'; + data.byte(kMainmode) = 0; + clearWork(); + data.byte(kNewobs) = 1; + drawFloor(); + reelsOnScreen(); + spriteUpdate(); + printSprites(); + workToScreen(); +} + +void DreamBase::set16ColPalette() { +} + +void DreamBase::realCredits() { + data.byte(kRoomssample) = 33; + loadRoomsSample(); + data.byte(kVolume) = 0; + + initGraphics(640, 480, true); + hangOn(35); + + showPCX("DREAMWEB.I01"); + playChannel0(12, 0); + + hangOne(2); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + allPalette(); + hangOne(80); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + showPCX("DREAMWEB.I02"); + playChannel0(12, 0); + hangOne(2); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + allPalette(); + hangOne(80); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + showPCX("DREAMWEB.I03"); + playChannel0(12, 0); + hangOne(2); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + allPalette(); + hangOne(80); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + showPCX("DREAMWEB.I04"); + playChannel0(12, 0); + hangOne(2); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + allPalette(); + hangOne(80); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + showPCX("DREAMWEB.I05"); + playChannel0(12, 0); + hangOne(2); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + allPalette(); + hangOne(80); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + showPCX("DREAMWEB.I06"); + fadeScreenUps(); + hangOne(60); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + playChannel0(13, 0); + hangOne(350); + + if (data.byte(kLasthardkey) == 1) { + data.byte(kLasthardkey) = 0; + return; // "realcreditsearly" + } + + fadeScreenDowns(); + hangOne(256); + + data.byte(kLasthardkey) = 0; +} + +} // End of namespace DreamGen diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp index 5cb1f6b92c..8aa735d84f 100644 --- a/engines/dreamweb/use.cpp +++ b/engines/dreamweb/use.cpp @@ -39,86 +39,86 @@ void DreamGenContext::useRoutine() { static const UseListEntry kUseList[] = { { &DreamGenContext::useMon, "NETW" }, - { &DreamGenContext::useElevator1, "ELVA" }, - { &DreamGenContext::useElevator2, "ELVB" }, - { &DreamGenContext::useElevator3, "ELVC" }, - { &DreamGenContext::useElevator4, "ELVE" }, - { &DreamGenContext::useElevator5, "ELVF" }, - { &DreamGenContext::useChurchGate, "CGAT" }, - { &DreamGenContext::useStereo, "REMO" }, - { &DreamGenContext::useButtonA, "BUTA" }, - { &DreamGenContext::useWinch, "CBOX" }, - { &DreamGenContext::useLighter, "LITE" }, - { &DreamGenContext::usePlate, "PLAT" }, - { &DreamGenContext::useControl, "LIFT" }, - { &DreamGenContext::useWire, "WIRE" }, - { &DreamGenContext::useHandle, "HNDL" }, - { &DreamGenContext::useHatch, "HACH" }, - { &DreamGenContext::useElvDoor, "DOOR" }, - { &DreamGenContext::useCashCard, "CSHR" }, - { &DreamGenContext::useGun, "GUNA" }, - { &DreamGenContext::useCardReader1, "CRAA" }, - { &DreamGenContext::useCardReader2, "CRBB" }, - { &DreamGenContext::useCardReader3, "CRCC" }, - { &DreamGenContext::sitDownInBar, "SEAT" }, - { &DreamGenContext::useMenu, "MENU" }, - { &DreamGenContext::useCooker, "COOK" }, - { &DreamGenContext::callHotelLift, "ELCA" }, - { &DreamGenContext::callEdensLift, "EDCA" }, - { &DreamGenContext::callEdensDLift, "DDCA" }, - { &DreamGenContext::useAltar, "ALTR" }, - { &DreamGenContext::openHotelDoor, "LOKA" }, - { &DreamGenContext::openHotelDoor2, "LOKB" }, - { &DreamGenContext::openLouis, "ENTA" }, - { &DreamGenContext::openRyan, "ENTB" }, - { &DreamGenContext::openPoolBoss, "ENTE" }, - { &DreamGenContext::openYourNeighbour, "ENTC" }, - { &DreamGenContext::openEden, "ENTD" }, - { &DreamGenContext::openSarters, "ENTH" }, - { &DreamGenContext::wearWatch, "WWAT" }, - { &DreamGenContext::usePoolReader, "POOL" }, - { &DreamGenContext::wearShades, "WSHD" }, - { &DreamGenContext::grafittiDoor, "GRAF" }, - { &DreamGenContext::trapDoor, "TRAP" }, - { &DreamGenContext::edensCDPlayer, "CDPE" }, - { &DreamGenContext::openTVDoor, "DLOK" }, - { &DreamGenContext::useHole, "HOLE" }, - { &DreamGenContext::useDryer, "DRYR" }, - { &DreamGenContext::useChurchHole, "HOLY" }, - { &DreamGenContext::useWall, "WALL" }, - { &DreamGenContext::useDiary, "BOOK" }, - { &DreamGenContext::useAxe, "AXED" }, - { &DreamGenContext::useShield, "SHLD" }, - { &DreamGenContext::useRailing, "BCNY" }, - { &DreamGenContext::useCoveredBox, "LIDC" }, - { &DreamGenContext::useClearBox, "LIDU" }, - { &DreamGenContext::useOpenBox, "LIDO" }, - { &DreamGenContext::usePipe, "PIPE" }, - { &DreamGenContext::useBalcony, "BALC" }, - { &DreamGenContext::useWindow, "WIND" }, - { &DreamGenContext::viewFolder, "PAPR" }, - { &DreamGenContext::useTrainer, "UWTA" }, - { &DreamGenContext::useTrainer, "UWTB" }, + { &DreamBase::useElevator1, "ELVA" }, + { &DreamBase::useElevator2, "ELVB" }, + { &DreamBase::useElevator3, "ELVC" }, + { &DreamBase::useElevator4, "ELVE" }, + { &DreamBase::useElevator5, "ELVF" }, + { &DreamBase::useChurchGate, "CGAT" }, + { &DreamBase::useStereo, "REMO" }, + { &DreamBase::useButtonA, "BUTA" }, + { &DreamBase::useWinch, "CBOX" }, + { &DreamBase::useLighter, "LITE" }, + { &DreamBase::usePlate, "PLAT" }, + { &DreamBase::useControl, "LIFT" }, + { &DreamBase::useWire, "WIRE" }, + { &DreamBase::useHandle, "HNDL" }, + { &DreamBase::useHatch, "HACH" }, + { &DreamBase::useElvDoor, "DOOR" }, + { &DreamBase::useCashCard, "CSHR" }, + { &DreamBase::useGun, "GUNA" }, + { &DreamBase::useCardReader1, "CRAA" }, + { &DreamBase::useCardReader2, "CRBB" }, + { &DreamBase::useCardReader3, "CRCC" }, + { &DreamBase::sitDownInBar, "SEAT" }, + { &DreamBase::useMenu, "MENU" }, + { &DreamBase::useCooker, "COOK" }, + { &DreamBase::callHotelLift, "ELCA" }, + { &DreamBase::callEdensLift, "EDCA" }, + { &DreamBase::callEdensDLift, "DDCA" }, + { &DreamBase::useAltar, "ALTR" }, + { &DreamBase::openHotelDoor, "LOKA" }, + { &DreamBase::openHotelDoor2, "LOKB" }, + { &DreamBase::openLouis, "ENTA" }, + { &DreamBase::openRyan, "ENTB" }, + { &DreamBase::openPoolBoss, "ENTE" }, + { &DreamBase::openYourNeighbour, "ENTC" }, + { &DreamBase::openEden, "ENTD" }, + { &DreamBase::openSarters, "ENTH" }, + { &DreamBase::wearWatch, "WWAT" }, + { &DreamBase::usePoolReader, "POOL" }, + { &DreamBase::wearShades, "WSHD" }, + { &DreamBase::grafittiDoor, "GRAF" }, + { &DreamBase::trapDoor, "TRAP" }, + { &DreamBase::edensCDPlayer, "CDPE" }, + { &DreamBase::openTVDoor, "DLOK" }, + { &DreamBase::useHole, "HOLE" }, + { &DreamBase::useDryer, "DRYR" }, + { &DreamBase::useChurchHole, "HOLY" }, + { &DreamBase::useWall, "WALL" }, + { &DreamBase::useDiary, "BOOK" }, + { &DreamBase::useAxe, "AXED" }, + { &DreamBase::useShield, "SHLD" }, + { &DreamBase::useRailing, "BCNY" }, + { &DreamBase::useCoveredBox, "LIDC" }, + { &DreamBase::useClearBox, "LIDU" }, + { &DreamBase::useOpenBox, "LIDO" }, + { &DreamBase::usePipe, "PIPE" }, + { &DreamBase::useBalcony, "BALC" }, + { &DreamBase::useWindow, "WIND" }, + { &DreamBase::viewFolder, "PAPR" }, + { &DreamBase::useTrainer, "UWTA" }, + { &DreamBase::useTrainer, "UWTB" }, { &DreamGenContext::enterSymbol, "STAT" }, - { &DreamGenContext::openTomb, "TLID" }, - { &DreamGenContext::useSLab, "SLAB" }, - { &DreamGenContext::useCart, "CART" }, - { &DreamGenContext::useFullCart, "FCAR" }, - { &DreamGenContext::sLabDoorA, "SLBA" }, - { &DreamGenContext::sLabDoorB, "SLBB" }, - { &DreamGenContext::sLabDoorC, "SLBC" }, - { &DreamGenContext::sLabDoorD, "SLBD" }, - { &DreamGenContext::sLabDoorE, "SLBE" }, - { &DreamGenContext::sLabDoorF, "SLBF" }, - { &DreamGenContext::usePlinth, "PLIN" }, - { &DreamGenContext::useLadder, "LADD" }, - { &DreamGenContext::useLadderB, "LADB" }, - { &DreamGenContext::chewy, "GUMA" }, - { &DreamGenContext::wheelSound, "SQEE" }, - { &DreamGenContext::runTap, "TAPP" }, - { &DreamGenContext::playGuitar, "GUIT" }, - { &DreamGenContext::hotelControl, "CONT" }, - { &DreamGenContext::hotelBell, "BELL" }, + { &DreamBase::openTomb, "TLID" }, + { &DreamBase::useSlab, "SLAB" }, + { &DreamBase::useCart, "CART" }, + { &DreamBase::useFullCart, "FCAR" }, + { &DreamBase::slabDoorA, "SLBA" }, + { &DreamBase::slabDoorB, "SLBB" }, + { &DreamBase::slabDoorC, "SLBC" }, + { &DreamBase::slabDoorD, "SLBD" }, + { &DreamBase::slabDoorE, "SLBE" }, + { &DreamBase::slabDoorF, "SLBF" }, + { &DreamBase::usePlinth, "PLIN" }, + { &DreamBase::useLadder, "LADD" }, + { &DreamBase::useLadderB, "LADB" }, + { &DreamBase::chewy, "GUMA" }, + { &DreamBase::wheelSound, "SQEE" }, + { &DreamBase::runTap, "TAPP" }, + { &DreamBase::playGuitar, "GUIT" }, + { &DreamBase::hotelControl, "CONT" }, + { &DreamBase::hotelBell, "BELL" }, }; if (data.byte(kReallocation) >= 50) { @@ -128,18 +128,19 @@ void DreamGenContext::useRoutine() { } getAnyAd(); - const uint8 *id = es.ptr(bx + 12, 4); + // CHECKME: Do the callbacks use es:bx ? + void *obj = es.ptr(bx, 15); for (size_t i = 0; i < sizeof(kUseList)/sizeof(UseListEntry); ++i) { const UseListEntry &entry = kUseList[i]; - if (('A' + id[0] == entry.id[0]) && ('A' + id[1] == entry.id[1]) && ('A' + id[2] == entry.id[2]) && ('A' + id[3] == entry.id[3])) { + if (objectMatches(obj, entry.id)) { (this->*entry.callback)(); return; } } delPointer(); - const uint8 *obText = getObTextStartCPP(); + const uint8 *obText = getObTextStart(); if (findNextColon(&obText) != 0) { if (findNextColon(&obText) != 0) { if (*obText != 0) { @@ -163,7 +164,7 @@ void DreamGenContext::useRoutine() { data.byte(kCommandtype) = 255; } -void DreamGenContext::useText(const uint8 *string) { +void DreamBase::useText(const uint8 *string) { createPanel(); showPanel(); showMan(); @@ -173,16 +174,16 @@ void DreamGenContext::useText(const uint8 *string) { workToScreenM(); } -void DreamGenContext::showFirstUse() { - const uint8 *obText = getObTextStartCPP(); +void DreamBase::showFirstUse() { + const uint8 *obText = getObTextStart(); findNextColon(&obText); findNextColon(&obText); useText(obText); hangOnP(400); } -void DreamGenContext::showSecondUse() { - const uint8 *obText = getObTextStartCPP(); +void DreamBase::showSecondUse() { + const uint8 *obText = getObTextStart(); findNextColon(&obText); findNextColon(&obText); findNextColon(&obText); @@ -190,7 +191,7 @@ void DreamGenContext::showSecondUse() { hangOnP(400); } -void DreamGenContext::viewFolder() { +void DreamBase::viewFolder() { data.byte(kManisoffscreen) = 1; getRidOfAll(); loadFolder(); @@ -219,7 +220,7 @@ void DreamGenContext::viewFolder() { workToScreenM(); } -void DreamGenContext::edensCDPlayer() { +void DreamBase::edensCDPlayer() { showFirstUse(); data.word(kWatchingtime) = 18 * 2; data.word(kReeltowatch) = 25; @@ -229,25 +230,25 @@ void DreamGenContext::edensCDPlayer() { data.byte(kGetback) = 1; } -void DreamGenContext::hotelBell() { +void DreamBase::hotelBell() { playChannel1(12); showFirstUse(); putBackObStuff(); } -void DreamGenContext::playGuitar() { +void DreamBase::playGuitar() { playChannel1(14); showFirstUse(); putBackObStuff(); } -void DreamGenContext::useElevator1() { +void DreamBase::useElevator1() { showFirstUse(); selectLocation(); data.byte(kGetback) = 1; } -void DreamGenContext::useElevator2() { +void DreamBase::useElevator2() { showFirstUse(); if (data.byte(kLocation) == 23) // In pool hall @@ -261,7 +262,7 @@ void DreamGenContext::useElevator2() { data.byte(kGetback) = 1; } -void DreamGenContext::useElevator3() { +void DreamBase::useElevator3() { showFirstUse(); data.byte(kCounttoclose) = 20; data.byte(kNewlocation) = 34; @@ -273,7 +274,7 @@ void DreamGenContext::useElevator3() { data.byte(kGetback) = 1; } -void DreamGenContext::useElevator4() { +void DreamBase::useElevator4() { showFirstUse(); data.word(kReeltowatch) = 0; data.word(kEndwatchreel) = 11; @@ -285,7 +286,7 @@ void DreamGenContext::useElevator4() { data.byte(kNewlocation) = 24; } -void DreamGenContext::useElevator5() { +void DreamBase::useElevator5() { placeSetObject(4); removeSetObject(0); data.byte(kNewlocation) = 20; @@ -295,19 +296,19 @@ void DreamGenContext::useElevator5() { data.byte(kGetback) = 1; } -void DreamGenContext::useHatch() { +void DreamBase::useHatch() { showFirstUse(); data.byte(kNewlocation) = 40; data.byte(kGetback) = 1; } -void DreamGenContext::wheelSound() { +void DreamBase::wheelSound() { playChannel1(17); showFirstUse(); putBackObStuff(); } -void DreamGenContext::callHotelLift() { +void DreamBase::callHotelLift() { playChannel1(12); showFirstUse(); data.byte(kCounttoopen) = 8; @@ -318,7 +319,7 @@ void DreamGenContext::callHotelLift() { turnPathOn(4); } -void DreamGenContext::useShield() { +void DreamBase::useShield() { if (data.byte(kReallocation) != 20 || data.byte(kCombatcount) == 0) { // Not in Sart room showFirstUse(); @@ -332,7 +333,7 @@ void DreamGenContext::useShield() { } } -void DreamGenContext::useCoveredBox() { +void DreamBase::useCoveredBox() { data.byte(kProgresspoints)++; showFirstUse(); data.word(kWatchingtime) = 50; @@ -343,7 +344,7 @@ void DreamGenContext::useCoveredBox() { data.byte(kGetback) = 1; } -void DreamGenContext::useRailing() { +void DreamBase::useRailing() { showFirstUse(); data.word(kWatchingtime) = 80; data.word(kReeltowatch) = 0; @@ -354,7 +355,7 @@ void DreamGenContext::useRailing() { data.byte(kMandead) = 4; } -void DreamGenContext::wearWatch() { +void DreamBase::wearWatch() { if (data.byte(kWatchon) == 1) { // Already wearing watch showSecondUse(); @@ -363,12 +364,12 @@ void DreamGenContext::wearWatch() { showFirstUse(); data.byte(kWatchon) = 1; data.byte(kGetback) = 1; - getAnyAd(); - makeWorn(); + uint8 dummy; + makeWorn((DynObject *)getAnyAd(&dummy, &dummy)); } } -void DreamGenContext::wearShades() { +void DreamBase::wearShades() { if (data.byte(kShadeson) == 1) { // Already wearing shades showSecondUse(); @@ -377,12 +378,12 @@ void DreamGenContext::wearShades() { data.byte(kShadeson) = 1; showFirstUse(); data.byte(kGetback) = 1; - getAnyAd(); - makeWorn(); + uint8 dummy; + makeWorn((DynObject *)getAnyAd(&dummy, &dummy)); } } -void DreamGenContext::useChurchHole() { +void DreamBase::useChurchHole() { showFirstUse(); data.byte(kGetback) = 1; data.word(kWatchingtime) = 28; @@ -392,7 +393,7 @@ void DreamGenContext::useChurchHole() { data.byte(kSpeedcount) = 1; } -void DreamGenContext::sitDownInBar() { +void DreamBase::sitDownInBar() { if (data.byte(kWatchmode) != 0xFF) { // Sat down showSecondUse(); @@ -410,13 +411,13 @@ void DreamGenContext::sitDownInBar() { } } -void DreamGenContext::useDryer() { +void DreamBase::useDryer() { playChannel1(12); showFirstUse(); data.byte(kGetback) = 1; } -void DreamGenContext::useBalcony() { +void DreamBase::useBalcony() { showFirstUse(); turnPathOn(6); turnPathOff(0); @@ -440,7 +441,7 @@ void DreamGenContext::useBalcony() { data.byte(kGetback) = 1; } -void DreamGenContext::useWindow() { +void DreamBase::useWindow() { if (data.byte(kManspath) != 6) { // Not on balcony showSecondUse(); @@ -453,7 +454,7 @@ void DreamGenContext::useWindow() { } } -void DreamGenContext::trapDoor() { +void DreamBase::trapDoor() { data.byte(kProgresspoints)++; showFirstUse(); switchRyanOff(); @@ -466,14 +467,14 @@ void DreamGenContext::trapDoor() { data.byte(kGetback) = 1; } -void DreamGenContext::callEdensLift() { +void DreamBase::callEdensLift() { showFirstUse(); data.byte(kCounttoopen) = 8; data.byte(kGetback) = 1; turnPathOn(2); } -void DreamGenContext::callEdensDLift() { +void DreamBase::callEdensDLift() { if (data.byte(kLiftflag) == 1) { // Eden's D here showSecondUse(); @@ -486,38 +487,38 @@ void DreamGenContext::callEdensDLift() { } } -void DreamGenContext::openYourNeighbour() { +void DreamBase::openYourNeighbour() { enterCode(255, 255, 255, 255); data.byte(kGetback) = 1; } -void DreamGenContext::openRyan() { +void DreamBase::openRyan() { enterCode(5, 1, 0, 6); data.byte(kGetback) = 1; } -void DreamGenContext::openPoolBoss() { +void DreamBase::openPoolBoss() { enterCode(5, 2, 2, 2); data.byte(kGetback) = 1; } -void DreamGenContext::openEden() { +void DreamBase::openEden() { enterCode(2, 8, 6, 5); data.byte(kGetback) = 1; } -void DreamGenContext::openSarters() { +void DreamBase::openSarters() { enterCode(7, 8, 3, 3); data.byte(kGetback) = 1; } -void DreamGenContext::openLouis() { +void DreamBase::openLouis() { enterCode(5, 2, 3, 8); data.byte(kGetback) = 1; } -void DreamGenContext::useWall() { +void DreamBase::useWall() { showFirstUse(); if (data.byte(kManspath) != 3) { @@ -560,7 +561,7 @@ void DreamGenContext::useWall() { } } -void DreamGenContext::useLadder() { +void DreamBase::useLadder() { showFirstUse(); data.byte(kMapx) = data.byte(kMapx) - 11; findRoomInLoc(); @@ -574,7 +575,7 @@ void DreamGenContext::useLadder() { data.byte(kGetback) = 1; } -void DreamGenContext::useLadderB() { +void DreamBase::useLadderB() { showFirstUse(); data.byte(kMapx) = data.byte(kMapx) + 11; findRoomInLoc(); @@ -588,7 +589,7 @@ void DreamGenContext::useLadderB() { data.byte(kGetback) = 1; } -void DreamGenContext::sLabDoorA() { +void DreamBase::slabDoorA() { showFirstUse(); data.byte(kGetback) = 1; data.byte(kWatchspeed) = 1; @@ -608,7 +609,7 @@ void DreamGenContext::sLabDoorA() { } } -void DreamGenContext::sLabDoorB() { +void DreamBase::slabDoorB() { if (data.byte(kDreamnumber) != 1) { // Wrong showFirstUse(); @@ -640,7 +641,7 @@ void DreamGenContext::sLabDoorB() { } } -void DreamGenContext::sLabDoorC() { +void DreamBase::slabDoorC() { showFirstUse(); data.byte(kGetback) = 1; data.byte(kWatchspeed) = 1; @@ -660,7 +661,7 @@ void DreamGenContext::sLabDoorC() { } } -void DreamGenContext::sLabDoorD() { +void DreamBase::slabDoorD() { showFirstUse(); data.byte(kGetback) = 1; data.byte(kWatchspeed) = 1; @@ -680,7 +681,7 @@ void DreamGenContext::sLabDoorD() { } } -void DreamGenContext::sLabDoorE() { +void DreamBase::slabDoorE() { showFirstUse(); data.byte(kGetback) = 1; data.byte(kWatchspeed) = 1; @@ -700,7 +701,7 @@ void DreamGenContext::sLabDoorE() { } } -void DreamGenContext::sLabDoorF() { +void DreamBase::slabDoorF() { showFirstUse(); data.byte(kGetback) = 1; data.byte(kWatchspeed) = 1; @@ -720,7 +721,7 @@ void DreamGenContext::sLabDoorF() { } } -bool DreamGenContext::defaultUseHandler(const char *id) { +bool DreamBase::defaultUseHandler(const char *id) { if (data.byte(kWithobject) == 255) { withWhat(); return true; // event handled @@ -736,7 +737,7 @@ bool DreamGenContext::defaultUseHandler(const char *id) { return false; // continue with the original event } -void DreamGenContext::useChurchGate() { +void DreamBase::useChurchGate() { if (defaultUseHandler("CUTT")) return; @@ -754,7 +755,7 @@ void DreamGenContext::useChurchGate() { turnPathOn(2); // Open church } -void DreamGenContext::useGun() { +void DreamBase::useGun() { if (data.byte(kObjecttype) != kExObjectType) { // gun is not taken @@ -823,8 +824,7 @@ void DreamGenContext::useGun() { } else if (data.byte(kReallocation) == 29) { // aide data.byte(kGetback) = 1; - al = 13; - resetLocation(); + resetLocation(13); setLocation(12); data.byte(kDestpos) = 12; data.byte(kDestination) = 2; @@ -866,7 +866,7 @@ void DreamGenContext::useGun() { } } -void DreamGenContext::useFullCart() { +void DreamBase::useFullCart() { data.byte(kProgresspoints)++; turnAnyPathOn(2, data.byte(kRoomnum) + 6); data.byte(kManspath) = 4; @@ -884,7 +884,7 @@ void DreamGenContext::useFullCart() { data.byte(kGetback) = 1; } -void DreamGenContext::useClearBox() { +void DreamBase::useClearBox() { if (defaultUseHandler("RAIL")) return; @@ -899,7 +899,7 @@ void DreamGenContext::useClearBox() { data.byte(kGetback) = 1; } -void DreamGenContext::openTVDoor() { +void DreamBase::openTVDoor() { if (defaultUseHandler("ULOK")) return; @@ -909,7 +909,7 @@ void DreamGenContext::openTVDoor() { data.byte(kGetback) = 1; } -void DreamGenContext::usePlate() { +void DreamBase::usePlate() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -936,7 +936,7 @@ void DreamGenContext::usePlate() { } } -void DreamGenContext::usePlinth() { +void DreamBase::usePlinth() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -959,7 +959,7 @@ void DreamGenContext::usePlinth() { } } -void DreamGenContext::useElvDoor() { +void DreamBase::useElvDoor() { if (defaultUseHandler("AXED")) return; @@ -989,7 +989,7 @@ void DreamGenContext::useObject() { useRoutine(); } -void DreamGenContext::useWinch() { +void DreamBase::useWinch() { uint16 contentIndex = checkInside(40, 1); if (contentIndex == kNumexobjects || !compare(contentIndex, kExObjectType, "FUSE")) { // No winch @@ -1013,7 +1013,7 @@ void DreamGenContext::useWinch() { data.byte(kProgresspoints)++; } -void DreamGenContext::useCart() { +void DreamBase::useCart() { if (defaultUseHandler("ROCK")) return; @@ -1027,28 +1027,29 @@ void DreamGenContext::useCart() { data.byte(kGetback) = 1; } -void DreamGenContext::useTrainer() { - // TODO: Use the C++ version of getAnyAd() - getAnyAd(); - if (es.byte(bx + 2) != 4) { +void DreamBase::useTrainer() { + uint8 dummy; + DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); + if (object->mapad[0] != 4) { notHeldError(); } else { data.byte(kProgresspoints)++; - makeWorn(); + makeWorn(object); showSecondUse(); putBackObStuff(); } } -void DreamGenContext::chewy() { +void DreamBase::chewy() { + // Chewing a gum showFirstUse(); - // TODO: Use the C++ version of getAnyAd() - getAnyAd(); - es.byte(bx + 2) = 255; + uint8 dummy; + DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); + object->mapad[0] = 255; data.byte(kGetback) = 1; } -void DreamGenContext::useHole() { +void DreamBase::useHole() { if (defaultUseHandler("HNDA")) return; @@ -1060,7 +1061,7 @@ void DreamGenContext::useHole() { data.byte(kGetback) = 1; } -void DreamGenContext::openHotelDoor() { +void DreamBase::openHotelDoor() { if (defaultUseHandler("KEYA")) return; @@ -1070,7 +1071,7 @@ void DreamGenContext::openHotelDoor() { data.byte(kGetback) = 1; } -void DreamGenContext::openHotelDoor2() { +void DreamBase::openHotelDoor2() { if (defaultUseHandler("KEYA")) return; @@ -1079,7 +1080,7 @@ void DreamGenContext::openHotelDoor2() { putBackObStuff(); } -void DreamGenContext::grafittiDoor() { +void DreamBase::grafittiDoor() { if (defaultUseHandler("APEN")) return; @@ -1087,7 +1088,7 @@ void DreamGenContext::grafittiDoor() { putBackObStuff(); } -void DreamGenContext::usePoolReader() { +void DreamBase::usePoolReader() { if (defaultUseHandler("MEMB")) return; @@ -1103,7 +1104,7 @@ void DreamGenContext::usePoolReader() { } } -void DreamGenContext::useCardReader1() { +void DreamBase::useCardReader1() { if (defaultUseHandler("CSHR")) return; @@ -1125,7 +1126,7 @@ void DreamGenContext::useCardReader1() { } } -void DreamGenContext::useCardReader2() { +void DreamBase::useCardReader2() { if (defaultUseHandler("CSHR")) return; @@ -1152,7 +1153,7 @@ void DreamGenContext::useCardReader2() { } } -void DreamGenContext::useCardReader3() { +void DreamBase::useCardReader3() { if (defaultUseHandler("CSHR")) return; @@ -1174,7 +1175,7 @@ void DreamGenContext::useCardReader3() { } } -void DreamGenContext::useLighter() { +void DreamBase::useLighter() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1191,7 +1192,7 @@ void DreamGenContext::useLighter() { } } -void DreamGenContext::useWire() { +void DreamBase::useWire() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1216,7 +1217,7 @@ void DreamGenContext::useWire() { putBackObStuff(); } -void DreamGenContext::openTomb() { +void DreamBase::openTomb() { data.byte(kProgresspoints)++; showFirstUse(); data.word(kWatchingtime) = 35 * 2; @@ -1227,7 +1228,7 @@ void DreamGenContext::openTomb() { data.byte(kGetback) = 1; } -void DreamGenContext::hotelControl() { +void DreamBase::hotelControl() { if (data.byte(kReallocation) != 21 || data.byte(kMapx) != 33) showSecondUse(); // Not right control else @@ -1236,7 +1237,7 @@ void DreamGenContext::hotelControl() { putBackObStuff(); } -void DreamGenContext::useCooker() { +void DreamBase::useCooker() { if (checkInside(data.byte(kCommand), data.byte(kObjecttype)) == kNumexobjects) showFirstUse(); else @@ -1254,7 +1255,7 @@ void DreamBase::removeFreeObject(uint8 index) { getFreeAd(index)->mapad[0] = 0xFF; } -void DreamGenContext::useDiary() { +void DreamBase::useDiary() { getRidOfReels(); loadIntoTemp("DREAMWEB.G14"); loadTempText("DREAMWEB.T51"); @@ -1266,11 +1267,11 @@ void DreamGenContext::useDiary() { showDiaryPage(); readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); data.byte(kGetback) = 0; - RectWithCallback diaryList[] = { + RectWithCallback<DreamBase> diaryList[] = { { kDiaryx+94,kDiaryx+110,kDiaryy+97,kDiaryy+113,&DreamBase::diaryKeyN }, { kDiaryx+151,kDiaryx+167,kDiaryy+71,kDiaryy+87,&DreamBase::diaryKeyP }, { kDiaryx+176,kDiaryx+192,kDiaryy+108,kDiaryy+124,&DreamBase::quitKey }, @@ -1300,7 +1301,7 @@ void DreamGenContext::useDiary() { workToScreenM(); } -void DreamGenContext::useControl() { +void DreamBase::useControl() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1353,7 +1354,7 @@ void DreamGenContext::useControl() { } } -void DreamGenContext::useSLab() { +void DreamBase::useSlab() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1385,7 +1386,7 @@ void DreamGenContext::useSLab() { data.byte(kGetback) = 1; } -void DreamGenContext::usePipe() { +void DreamBase::usePipe() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1408,7 +1409,7 @@ void DreamGenContext::usePipe() { } } -void DreamGenContext::useOpenBox() { +void DreamBase::useOpenBox() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1440,7 +1441,7 @@ void DreamGenContext::useOpenBox() { showFirstUse(); } -void DreamGenContext::runTap() { +void DreamBase::runTap() { if (data.byte(kWithobject) == 255) { withWhat(); return; @@ -1467,7 +1468,7 @@ void DreamGenContext::runTap() { putBackObStuff(); } -void DreamGenContext::useAxe() { +void DreamBase::useAxe() { if (data.byte(kReallocation) != 22) { // Not in pool showFirstUse(); @@ -1528,7 +1529,7 @@ void DreamGenContext::useKey() { } } -void DreamGenContext::useHandle() { +void DreamBase::useHandle() { SetObject *object = getSetAd(findSetObject("CUTW")); if (object->mapad[0] == 255) { // Wire not cut @@ -1542,7 +1543,7 @@ void DreamGenContext::useHandle() { data.byte(kGetback) = 1; } -void DreamGenContext::useAltar() { +void DreamBase::useAltar() { if (findExObject("CNDA") == 114 || findExObject("CNDB") == 114) { // Things on altar showFirstUse(); @@ -1585,12 +1586,12 @@ void DreamBase::withWhat() { data.byte(kCommandtype) = 255; readMouse(); showPointer(); - workToScreenCPP(); + workToScreen(); delPointer(); data.byte(kInvopen) = 2; } -void DreamGenContext::notHeldError() { +void DreamBase::notHeldError() { createPanel(); showPanel(); showMan(); @@ -1602,7 +1603,7 @@ void DreamGenContext::notHeldError() { putBackObStuff(); } -void DreamGenContext::useCashCard() { +void DreamBase::useCashCard() { getRidOfReels(); loadKeypad(); createPanel(); @@ -1611,7 +1612,7 @@ void DreamGenContext::useCashCard() { showMan(); uint16 y = (!data.byte(kForeignrelease)) ? 120 : 120 - 3; showFrame(tempGraphics(), 114, y, 39, 0); - const uint8 *obText = getObTextStartCPP(); + const uint8 *obText = getObTextStart(); findNextColon(&obText); findNextColon(&obText); y = 98; @@ -1631,7 +1632,10 @@ void DreamGenContext::useCashCard() { putBackObStuff(); } -void DreamGenContext::useStereo() { +void DreamBase::useStereo() { + // Handles the stereo in Ryan's apartment (accessible from the remote on + // the couch) + if (data.byte(kLocation) != 0) { showPuzText(4, 400); putBackObStuff(); @@ -1642,20 +1646,18 @@ void DreamGenContext::useStereo() { // No CD inside showPuzText(6, 400); putBackObStuff(); - // TODO: Use the C++ version of getAnyAd() - getAnyAd(); - es.byte(bx + 10) = 255; + uint8 dummy; + DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); + object->turnedOn = 255; } else { // CD inside - getAnyAd(); - es.byte(bx + 10) ^= 1; - if (es.byte(bx + 10) != 255) { - // Stereo off - showPuzText(7, 400); - } else { - // Stereo on - showPuzText(8, 400); - } + uint8 dummy; + DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); + object->turnedOn ^= 1; + if (object->turnedOn != 255) + showPuzText(7, 400); // Stereo off + else + showPuzText(8, 400); // Stereo on putBackObStuff(); } @@ -1684,4 +1686,25 @@ void DreamBase::showPuzText(uint16 command, uint16 count) { hangOnP(count); } +void DreamBase::useButtonA() { + if (!isSetObOnMap(95)) { + showFirstUse(); + turnAnyPathOn(0, data.byte(kRoomnum) - 1); + removeSetObject(9); + placeSetObject(95); + data.word(kWatchingtime) = 15 * 2; + data.word(kReeltowatch) = 71; + data.word(kEndwatchreel) = 85; + data.byte(kWatchspeed) = 1; + data.byte(kSpeedcount) = 1; + data.byte(kGetback) = 1; + data.byte(kProgresspoints)++; + } else { + // Done this bit + showSecondUse(); + putBackObStuff(); + } +} + + } // End of namespace DreamGen diff --git a/engines/dreamweb/vgafades.cpp b/engines/dreamweb/vgafades.cpp index 7518c226f4..3833050003 100644 --- a/engines/dreamweb/vgafades.cpp +++ b/engines/dreamweb/vgafades.cpp @@ -24,40 +24,28 @@ namespace DreamGen { -uint8 *DreamBase::mainPalette() { - return getSegment(data.word(kBuffers)).ptr(kMaingamepal, 256 * 3); -} - -uint8 *DreamBase::startPalette() { - return getSegment(data.word(kBuffers)).ptr(kStartpal, 256 * 3); -} - -uint8 *DreamBase::endPalette() { - return getSegment(data.word(kBuffers)).ptr(kEndpal, 256 * 3); -} - void DreamBase::clearStartPal() { - memset(startPalette(), 0, 256 * 3); + memset(_startPal, 0, 256 * 3); } void DreamBase::clearEndPal() { - memset(endPalette(), 0, 256 * 3); + memset(_endPal, 0, 256 * 3); } void DreamBase::palToStartPal() { - memcpy(startPalette(), mainPalette(), 256 * 3); + memcpy(_startPal, _mainPal, 256 * 3); } void DreamBase::endPalToStart() { - memcpy(startPalette(), endPalette(), 256 * 3); + memcpy(_startPal, _endPal, 256 * 3); } void DreamBase::startPalToEnd() { - memcpy(endPalette(), startPalette(), 256 * 3); + memcpy(_endPal, _startPal, 256 * 3); } void DreamBase::palToEndPal() { - memcpy(endPalette(), mainPalette(), 256 * 3); + memcpy(_endPal, _mainPal, 256 * 3); } void DreamBase::fadeDOS() { @@ -65,7 +53,7 @@ void DreamBase::fadeDOS() { engine->waitForVSync(); //processEvents will be called from vsync - uint8 *dst = startPalette(); + uint8 *dst = _startPal; engine->getPalette(dst, 0, 64); for (int fade = 0; fade < 64; ++fade) { for (int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors @@ -83,7 +71,7 @@ void DreamBase::doFade() { return; engine->processEvents(); - uint8 *src = startPalette() + 3 * data.byte(kColourpos); + uint8 *src = _startPal + 3 * data.byte(kColourpos); engine->setPalette(src, data.byte(kColourpos), data.byte(kNumtofade)); data.byte(kColourpos) += data.byte(kNumtofade); @@ -97,8 +85,8 @@ void DreamBase::fadeCalculation() { return; } - uint8 *startPal = startPalette(); - const uint8 *endPal = endPalette(); + uint8 *startPal = _startPal; + const uint8 *endPal = _endPal; for (size_t i = 0; i < 256 * 3; ++i) { uint8 s = startPal[i]; uint8 e = endPal[i]; @@ -114,10 +102,10 @@ void DreamBase::fadeCalculation() { --data.byte(kFadecount); } -void DreamBase::fadeupYellows() { +void DreamBase::fadeUpYellows() { palToEndPal(); - memset(endPalette() + 231 * 3, 0, 8 * 3); - memset(endPalette() + 246 * 3, 0, 1 * 3); + memset(_endPal + 231 * 3, 0, 8 * 3); + memset(_endPal + 246 * 3, 0, 1 * 3); data.byte(kFadedirection) = 1; data.byte(kFadecount) = 63; data.byte(kColourpos) = 0; @@ -125,11 +113,11 @@ void DreamBase::fadeupYellows() { hangOn(128); } -void DreamBase::fadeupMonFirst() { +void DreamBase::fadeUpMonFirst() { palToStartPal(); palToEndPal(); - memset(startPalette() + 231 * 3, 0, 8 * 3); - memset(startPalette() + 246 * 3, 0, 1 * 3); + memset(_startPal + 231 * 3, 0, 8 * 3); + memset(_startPal + 246 * 3, 0, 1 * 3); data.byte(kFadedirection) = 1; data.byte(kFadecount) = 63; data.byte(kColourpos) = 0; @@ -139,6 +127,39 @@ void DreamBase::fadeupMonFirst() { hangOn(64); } + +void DreamBase::fadeDownMon() { + palToStartPal(); + palToEndPal(); + memset(_endPal + 231 * 3, 0, 8 * 3); + memset(_endPal + 246 * 3, 0, 1 * 3); + data.byte(kFadedirection) = 1; + data.byte(kFadecount) = 63; + data.byte(kColourpos) = 0; + data.byte(kNumtofade) = 128; + hangOn(64); +} + +void DreamBase::fadeUpMon() { + palToStartPal(); + palToEndPal(); + memset(_startPal + 231 * 3, 0, 8 * 3); + memset(_startPal + 246 * 3, 0, 1 * 3); + data.byte(kFadedirection) = 1; + data.byte(kFadecount) = 63; + data.byte(kColourpos) = 0; + data.byte(kNumtofade) = 128; + hangOn(128); +} + +void DreamBase::initialMonCols() { + palToStartPal(); + memset(_startPal + 230 * 3, 0, 9 * 3); + memset(_startPal + 246 * 3, 0, 1 * 3); + engine->processEvents(); + engine->setPalette(_startPal + 230 * 3, 230, 18); +} + void DreamBase::fadeScreenUp() { clearStartPal(); palToEndPal(); @@ -188,8 +209,8 @@ void DreamBase::fadeScreenDownHalf() { palToStartPal(); palToEndPal(); - const uint8 *startPal = startPalette(); - uint8 *endPal = endPalette(); + const uint8 *startPal = _startPal; + uint8 *endPal = _endPal; for (int i = 0; i < 256 * 3; ++i) { *endPal >>= 1; endPal++; @@ -214,8 +235,8 @@ void DreamBase::clearPalette() { // Converts palette to grey scale, summed using formula // .20xred + .59xGreen + .11xBlue void DreamBase::greyscaleSum() { - byte *src = mainPalette(); - byte *dst = endPalette(); + byte *src = _mainPal; + byte *dst = _endPal; for (int i = 0; i < 256; ++i) { const unsigned int r = 20 * *src++; @@ -242,12 +263,12 @@ void DreamBase::greyscaleSum() { } void DreamBase::allPalette() { - memcpy(startPalette(), mainPalette(), 3 * 256); + memcpy(_startPal, _mainPal, 3 * 256); dumpCurrent(); } void DreamBase::dumpCurrent() { - uint8 *pal = startPalette(); + uint8 *pal = _startPal; engine->waitForVSync(); engine->processEvents(); @@ -260,17 +281,4 @@ void DreamBase::dumpCurrent() { engine->setPalette(pal, 128, 128); } -void DreamGenContext::showGroup() { - engine->processEvents(); - unsigned n = (uint16)cx; - uint8 *src = ds.ptr(si, n * 3); - engine->setPalette(src, al, n); - si += n * 3; - cx = 0; -} - -void DreamGenContext::rollEndCredits2() { - rollEm(); -} - } // End of namespace DreamGen diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index cea9dbef8c..ce89711f87 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -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(); } @@ -202,7 +195,7 @@ void DreamBase::showPCX(const Common::String &name) { // the color components have to be adjusted from 8 to 6 bits. pcxFile.seek(16, SEEK_SET); - mainGamePal = mainPalette(); + mainGamePal = _mainPal; pcxFile.read(mainGamePal, 48); memset(mainGamePal + 48, 0xff, 720); @@ -360,18 +353,11 @@ 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); } -void DreamGenContext::zoom() { +void DreamBase::zoom() { if (data.word(kWatchingtime) != 0) return; if (data.byte(kZoomon) != 1) @@ -432,7 +418,7 @@ void DreamBase::transferInv() { data.word(kExframepos) += byteCount; } -bool DreamGenContext::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) { +bool DreamBase::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) { x -= pos->xMin; y -= pos->yMin; SetObject *setObject = getSetAd(pos->index); @@ -448,7 +434,7 @@ void DreamBase::loadPalFromIFF() { palFile.close(); const uint8 *src = mapStore() + 0x30; - uint8 *dst = mainPalette(); + uint8 *dst = _mainPal; for (size_t i = 0; i < 256*3; ++i) { uint8 c = src[i] / 4; if (data.byte(kBrightness) == 1) { diff --git a/engines/saga/saga.h b/engines/saga/saga.h index fb01b1ac5d..829425aeaf 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -208,18 +208,6 @@ enum PanelButtonType { kPanelAllButtons = 0xFFFFF }; -enum GameSoundTypes { - kSoundPCM = 0, - kSoundVOX = 1, - kSoundVOC = 2, - kSoundWAV = 3, - kSoundMP3 = 4, - kSoundOGG = 5, - kSoundFLAC = 6, - kSoundAIFF = 7, - kSoundShorten = 8 -}; - enum TextStringIds { kTextPickUp, kTextLookAt, diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index add34e22a2..5a97eb6019 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -30,12 +30,17 @@ #include "saga/sound.h" #include "common/file.h" +#include "common/substream.h" #include "audio/audiostream.h" #include "audio/decoders/adpcm.h" #include "audio/decoders/aiff.h" +#include "audio/decoders/flac.h" +#include "audio/decoders/mac_snd.h" +#include "audio/decoders/mp3.h" #include "audio/decoders/raw.h" #include "audio/decoders/voc.h" +#include "audio/decoders/vorbis.h" #include "audio/decoders/wave.h" #ifdef ENABLE_SAGA2 #include "saga/shorten.h" @@ -167,14 +172,31 @@ void SndRes::playVoice(uint32 resourceId) { _vm->_sound->playVoice(buffer); } +enum GameSoundType { + kSoundPCM = 0, + kSoundVOX = 1, + kSoundVOC = 2, + kSoundWAV = 3, + kSoundMP3 = 4, + kSoundOGG = 5, + kSoundFLAC = 6, + kSoundAIFF = 7, + kSoundShorten = 8, + kSoundMacSND = 9 +}; + +// Use a macro to read in the sound data based on if we actually want to buffer it or not +#define READ_STREAM(streamSize) \ + (onlyHeader \ + ? new Common::SeekableSubReadStream(&readS, readS.pos(), readS.pos() + (streamSize)) \ + : readS.readStream(streamSize)) + bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buffer, bool onlyHeader) { - Audio::AudioStream *voxStream; size_t soundResourceLength; bool result = false; - GameSoundTypes resourceType = kSoundPCM; - byte *data = 0; + GameSoundType resourceType = kSoundPCM; int rate = 0, size = 0; - Common::File* file; + Common::File *file; if (resourceId == (uint32)-1) { return false; @@ -210,7 +232,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff soundResourceLength = resourceData->size; } - Common::SeekableReadStream& readS = *file; + Common::SeekableReadStream &readS = *file; bool uncompressedSound = false; if (soundResourceLength >= 8) { @@ -250,160 +272,141 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff } - // Default sound type is 16-bit signed PCM, used in ITE by PCM and VOX files - buffer.isCompressed = context->isCompressed(); - buffer.soundType = resourceType; - buffer.originalSize = 0; - // Set default flags and frequency for PCM, VOC and VOX files, which got no header - buffer.flags = Audio::FLAG_16BITS; - buffer.frequency = 22050; + // Default sound type is 16-bit signed PCM, used in ITE + byte rawFlags = Audio::FLAG_16BITS; + if (_vm->getGameId() == GID_ITE) { - if (_vm->getFeatures() & GF_8BIT_UNSIGNED_PCM) { // older ITE demos - buffer.flags |= Audio::FLAG_UNSIGNED; - buffer.flags &= ~Audio::FLAG_16BITS; - } else { + if (context->fileType() & GAME_MACBINARY) { + // ITE Mac has sound in the Mac snd format + resourceType = kSoundMacSND; + } else if (_vm->getFeatures() & GF_8BIT_UNSIGNED_PCM) { // older ITE demos + rawFlags |= Audio::FLAG_UNSIGNED; + rawFlags &= ~Audio::FLAG_16BITS; + } else if (!uncompressedSound && !scumm_stricmp(context->fileName(), "voicesd.rsc")) { // Voice files in newer ITE demo versions are OKI ADPCM (VOX) encoded. - // These are LE in all the Windows and Mac demos - if (!uncompressedSound && !scumm_stricmp(context->fileName(), "voicesd.rsc")) { - resourceType = kSoundVOX; - buffer.flags |= Audio::FLAG_LITTLE_ENDIAN; - } + resourceType = kSoundVOX; } } - buffer.buffer = NULL; + + buffer.stream = 0; // Check for LE sounds if (!context->isBigEndian()) - buffer.flags |= Audio::FLAG_LITTLE_ENDIAN; - - // Older Mac versions of ITE were Macbinary packed - int soundOffset = (context->fileType() & GAME_MACBINARY) ? 36 : 0; + rawFlags |= Audio::FLAG_LITTLE_ENDIAN; switch (resourceType) { - case kSoundPCM: - buffer.size = soundResourceLength - soundOffset; - if (!onlyHeader) { - buffer.buffer = (byte *) malloc(buffer.size); - if (soundOffset > 0) - readS.skip(soundOffset); - readS.read(buffer.buffer, buffer.size); - } + case kSoundPCM: { + // In ITE CD German, some voices are absent and contain just 5 zero bytes. + // Round down to an even number when the audio is 16-bit so makeRawStream + // will accept the data (needs to be an even size for 16-bit data). + // See bug #1256701 + + if ((soundResourceLength & 1) && (rawFlags & Audio::FLAG_16BITS)) + soundResourceLength &= ~1; + + Audio::SeekableAudioStream *audStream = Audio::makeRawStream(READ_STREAM(soundResourceLength), 22050, rawFlags); + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); result = true; - break; + } break; case kSoundVOX: - buffer.size = soundResourceLength * 4; - if (!onlyHeader) { - voxStream = Audio::makeADPCMStream(&readS, DisposeAfterUse::NO, soundResourceLength, Audio::kADPCMOki); - buffer.buffer = (byte *)malloc(buffer.size); - voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2); - delete voxStream; - } + buffer.stream = Audio::makeADPCMStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES, soundResourceLength, Audio::kADPCMOki, 22050, 1); + buffer.streamLength = Audio::Timestamp(0, soundResourceLength * 2, buffer.stream->getRate()); result = true; break; + case kSoundMacSND: { + Audio::SeekableAudioStream *audStream = Audio::makeMacSndStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES); + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); + result = true; + } break; + case kSoundAIFF: { + Audio::SeekableAudioStream *audStream = Audio::makeAIFFStream(READ_STREAM(soundResourceLength), DisposeAfterUse::YES); + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); + result = true; + } break; + case kSoundVOC: { + Audio::SeekableAudioStream *audStream = Audio::makeVOCStream(READ_STREAM(soundResourceLength), Audio::FLAG_UNSIGNED, DisposeAfterUse::YES); + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); + result = true; + } break; case kSoundWAV: - case kSoundAIFF: case kSoundShorten: - case kSoundVOC: if (resourceType == kSoundWAV) { - result = Audio::loadWAVFromStream(readS, size, rate, buffer.flags); - } else if (resourceType == kSoundAIFF) { - result = Audio::loadAIFFFromStream(readS, size, rate, buffer.flags); + result = Audio::loadWAVFromStream(readS, size, rate, rawFlags); #ifdef ENABLE_SAGA2 } else if (resourceType == kSoundShorten) { - result = loadShortenFromStream(readS, size, rate, buffer.flags); + result = loadShortenFromStream(readS, size, rate, rawFlags); #endif - } else if (resourceType == kSoundVOC) { - data = Audio::loadVOCFromStream(readS, size, rate); - result = (data != NULL); - if (onlyHeader) - free(data); - buffer.flags |= Audio::FLAG_UNSIGNED; - buffer.flags &= ~Audio::FLAG_16BITS; - buffer.flags &= ~Audio::FLAG_STEREO; } if (result) { - buffer.frequency = rate; - buffer.size = size; - - if (!onlyHeader) { - if (resourceType == kSoundVOC) { - buffer.buffer = data; - } else { - buffer.buffer = (byte *)malloc(size); - readS.read(buffer.buffer, size); - } - } + Audio::SeekableAudioStream *audStream = Audio::makeRawStream(READ_STREAM(size), rate, rawFlags); + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); } break; case kSoundMP3: case kSoundOGG: - case kSoundFLAC: - ResourceData *resourceData; - resourceData = context->getResourceData(resourceId); - - // Read compressed sfx header - readS.readByte(); // Skip compression identifier byte - buffer.frequency = readS.readUint16LE(); - buffer.originalSize = readS.readUint32LE(); - if (readS.readByte() == 8) // read sample bits - buffer.flags &= ~Audio::FLAG_16BITS; - if (readS.readByte() != 0) // read stereo flag - buffer.flags |= Audio::FLAG_STEREO; - - buffer.size = soundResourceLength; - buffer.soundType = resourceType; - buffer.fileOffset = resourceData->offset + 9; // skip compressed sfx header: byte + uint16 + uint32 + byte + byte - - if (!onlyHeader) { - buffer.buffer = (byte *)malloc(buffer.size); - readS.read(buffer.buffer, buffer.size); + case kSoundFLAC: { + readS.skip(9); // skip sfx header + + Audio::SeekableAudioStream *audStream = 0; + Common::SeekableReadStream *memStream = READ_STREAM(soundResourceLength - 9); + + if (resourceType == kSoundMP3) { +#ifdef USE_MAD + audStream = Audio::makeMP3Stream(memStream, DisposeAfterUse::YES); +#endif + } else if (resourceType == kSoundOGG) { +#ifdef USE_VORBIS + audStream = Audio::makeVorbisStream(memStream, DisposeAfterUse::YES); +#endif + } else /* if (resourceType == kSoundFLAC) */ { +#ifdef USE_FLAC + audStream = Audio::makeFLACStream(memStream, DisposeAfterUse::YES); +#endif } - result = true; - break; + if (audStream) { + buffer.stream = audStream; + buffer.streamLength = audStream->getLength(); + result = true; + } else { + delete memStream; + } + + } break; default: error("SndRes::load Unknown sound type"); } - if (_vm->getGameId() == GID_IHNM && _vm->isMacResources()) { delete file; } - - // In ITE CD De some voices are absent and contain just 5 bytes header - // Round it to even number so soundmanager will not crash. - // See bug #1256701 - buffer.size &= ~(0x1); + if (onlyHeader) { + delete buffer.stream; + buffer.stream = 0; + } return result; } +#undef READ_STREAM + int SndRes::getVoiceLength(uint32 resourceId) { - double msDouble; SoundBuffer buffer; if (!(_vm->_voiceFilesExist)) return -1; - if (!load(_voiceContext, resourceId, buffer, true)) { + if (!load(_voiceContext, resourceId, buffer, true)) return -1; - } - - if (!_voiceContext->isCompressed() || buffer.originalSize == 0) - msDouble = (double)buffer.size; - else - msDouble = (double)buffer.originalSize; - - if (buffer.flags & Audio::FLAG_16BITS) - msDouble /= 2.0; - - if (buffer.flags & Audio::FLAG_STEREO) - msDouble /= 2.0; - msDouble = msDouble / buffer.frequency * 1000.0; - return (int)msDouble; + return buffer.streamLength.msecs(); } } // End of namespace Saga diff --git a/engines/saga/sndres.h b/engines/saga/sndres.h index 9b0eebc834..979c0288f6 100644 --- a/engines/saga/sndres.h +++ b/engines/saga/sndres.h @@ -52,8 +52,6 @@ public: private: bool load(ResourceContext *context, uint32 resourceId, SoundBuffer &buffer, bool onlyHeader); - bool loadVocSound(byte *soundResource, size_t soundResourceLength, SoundBuffer &buffer); - bool loadWavSound(byte *soundResource, size_t soundResourceLength, SoundBuffer &buffer); ResourceContext *_sfxContext; ResourceContext *_voiceContext; diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 3408125f73..67be499bc7 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -63,42 +63,11 @@ SndHandle *Sound::getHandle() { void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffer, int volume, sndHandleType handleType, bool loop) { - Audio::RewindableAudioStream *stream = 0; - Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ? Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType; - if (!buffer.isCompressed) { - stream = Audio::makeRawStream(buffer.buffer, buffer.size, buffer.frequency, buffer.flags); - } else { - Common::SeekableReadStream *memStream = new Common::MemoryReadStream(buffer.buffer, buffer.size, DisposeAfterUse::YES); - - switch (buffer.soundType) { -#ifdef USE_MAD - case kSoundMP3: - stream = Audio::makeMP3Stream(memStream, DisposeAfterUse::YES); - break; -#endif -#ifdef USE_VORBIS - case kSoundOGG: - stream = Audio::makeVorbisStream(memStream, DisposeAfterUse::YES); - break; -#endif -#ifdef USE_FLAC - case kSoundFLAC: - stream = Audio::makeFLACStream(memStream, DisposeAfterUse::YES); - break; -#endif - default: - // Unknown compression, ignore sample - delete memStream; - warning("Unknown compression, ignoring sound"); - break; - } - } - - if (stream != NULL) - _mixer->playStream(soundType, handle, Audio::makeLoopingAudioStream(stream, loop ? 0 : 1), -1, volume); + if (buffer.stream) + _mixer->playStream(soundType, handle, Audio::makeLoopingAudioStream(buffer.stream, loop ? 0 : 1), -1, volume); } void Sound::playSound(SoundBuffer &buffer, int volume, bool loop, int resId) { diff --git a/engines/saga/sound.h b/engines/saga/sound.h index 15624a9da5..e2163dfb0e 100644 --- a/engines/saga/sound.h +++ b/engines/saga/sound.h @@ -27,9 +27,11 @@ #include "common/file.h" #include "audio/mixer.h" -#include "audio/decoders/mp3.h" -#include "audio/decoders/vorbis.h" -#include "audio/decoders/flac.h" +#include "audio/timestamp.h" + +namespace Audio { +class RewindableAudioStream; +} namespace Saga { @@ -40,15 +42,8 @@ enum SOUND_FLAGS { }; struct SoundBuffer { - uint16 frequency; - bool isCompressed; - byte flags; - - byte *buffer; - size_t size; - size_t originalSize; - GameSoundTypes soundType; - size_t fileOffset; + Audio::RewindableAudioStream *stream; + Audio::Timestamp streamLength; }; enum sndHandleType { diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index cd055a5b78..c75089f8ca 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -717,6 +717,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "pajama", "Pajama Sam", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "pajama", "PajamaNHD", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama", "PJS-DEMO", kGenHEPC, UNK_LANG, UNK, 0 }, + { "pajama", "PJS-DEMO", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "pajama", "pjsam", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama", "PjSamDemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "pajama", "PYJAMA", kGenHEPC, Common::DE_DEU, UNK, 0 }, diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 42ce74ec29..cb36743ee2 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Nov 28 01:09:07 2011 + This file was generated by the md5table tool on Thu Dec 22 23:21:30 2011 DO NOT EDIT MANUALLY! */ @@ -16,7 +16,7 @@ struct MD5Table { static const MD5Table md5table[] = { { "008e76ec3ae58d0add637ea7aa299a2c", "freddi3", "", "", -1, Common::FR_FRA, Common::kPlatformMacintosh }, { "02cae0e7ff8504f73618391873d5781a", "freddi3", "HE 98.5", "", -1, Common::DE_DEU, Common::kPlatformWindows }, - { "0305e850382b812fec6e5998ef88a966", "pajama", "", "Demo", -1, Common::NL_NLD, Common::kPlatformWindows }, + { "0305e850382b812fec6e5998ef88a966", "pajama", "", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown }, { "035deab53b47bc43abc763560d0f8d4b", "atlantis", "Floppy", "Demo", -1, Common::EN_ANY, Common::kPlatformPC }, { "037385a953789190298494d92b89b3d0", "catalog", "HE 72", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "03d3b18ee3fd68114e2a687c871e38d5", "freddi4", "HE 99", "Mini Game", -1, Common::EN_USA, Common::kPlatformWindows }, diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index f5a3938f2b..65cea8efae 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -338,10 +338,8 @@ public: class NamedHotspot : public SceneHotspot { public: - int _resNum, _lookLineNum, _useLineNum, _talkLineNum; NamedHotspot(); - virtual bool startAction(CursorType action, Event &event); virtual Common::String getClassName() { return "NamedHotspot"; } virtual void synchronize(Serializer &s); diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index c243624608..f894d2d33a 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -34,6 +34,7 @@ #include "tsage/globals.h" #include "tsage/sound.h" #include "tsage/blue_force/blueforce_logic.h" +#include "tsage/ringworld2/ringworld2_logic.h" namespace TsAGE { @@ -1533,25 +1534,30 @@ bool SceneItem::startAction(CursorType action, Event &event) { void SceneItem::doAction(int action) { const char *msg = NULL; - switch ((int)action) { - case CURSOR_LOOK: - msg = LOOK_SCENE_HOTSPOT; - break; - case CURSOR_USE: - msg = USE_SCENE_HOTSPOT; - break; - case CURSOR_TALK: - msg = TALK_SCENE_HOTSPOT; - break; - case 0x1000: - msg = SPECIAL_SCENE_HOTSPOT; - break; - default: - msg = DEFAULT_SCENE_HOTSPOT; - break; - } + if (g_vm->getGameID() == GType_Ringworld2) { + Event dummyEvent; + ((Ringworld2::SceneExt *)GLOBALS._sceneManager._scene)->display((CursorType)action, dummyEvent); + } else { + switch ((int)action) { + case CURSOR_LOOK: + msg = LOOK_SCENE_HOTSPOT; + break; + case CURSOR_USE: + msg = USE_SCENE_HOTSPOT; + break; + case CURSOR_TALK: + msg = TALK_SCENE_HOTSPOT; + break; + case 0x1000: + msg = SPECIAL_SCENE_HOTSPOT; + break; + default: + msg = DEFAULT_SCENE_HOTSPOT; + break; + } - GUIErrorMessage(msg); + GUIErrorMessage(msg); + } } bool SceneItem::contains(const Common::Point &pt) { @@ -1762,6 +1768,22 @@ void SceneItem::display(const Common::String &msg) { /*--------------------------------------------------------------------------*/ +SceneHotspot::SceneHotspot(): SceneItem() { + _lookLineNum = _useLineNum = _talkLineNum = 0; +} + +void SceneHotspot::synchronize(Serializer &s) { + SceneItem::synchronize(s); + + if (g_vm->getGameID() == GType_Ringworld2) { + // In R2R, the following fields were moved into the SceneItem class + s.syncAsSint16LE(_resNum); + s.syncAsSint16LE(_lookLineNum); + s.syncAsSint16LE(_useLineNum); + s.syncAsSint16LE(_talkLineNum); + } +} + bool SceneHotspot::startAction(CursorType action, Event &event) { switch (g_vm->getGameID()) { case GType_BlueForce: { @@ -1769,6 +1791,32 @@ bool SceneHotspot::startAction(CursorType action, Event &event) { assert(scene); return scene->display(action); } + case GType_Ringworld2: { + switch (action) { + case CURSOR_LOOK: + if (_lookLineNum != -1) { + SceneItem::display2(_resNum, _lookLineNum); + return true; + } + break; + case CURSOR_USE: + if (_useLineNum != -1) { + SceneItem::display2(_resNum, _useLineNum); + return true; + } + break; + case CURSOR_TALK: + if (_talkLineNum != -1) { + SceneItem::display2(_resNum, _talkLineNum); + return true; + } + break; + default: + break; + } + + return ((Ringworld2::SceneExt *)GLOBALS._sceneManager._scene)->display(action, event); + } default: return SceneItem::startAction(action, event); } @@ -1805,6 +1853,58 @@ void SceneHotspot::doAction(int action) { } } +void SceneHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { + setBounds(ys, xe, ye, xs); + _resNum = resnum; + _lookLineNum = lookLineNum; + _useLineNum = useLineNum; + _talkLineNum = -1; + g_globals->_sceneItems.addItems(this, NULL); +} + +void SceneHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { + setBounds(bounds); + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + switch (mode) { + case 2: + g_globals->_sceneItems.push_front(this); + break; + case 4: + g_globals->_sceneItems.addBefore(item, this); + break; + case 5: + g_globals->_sceneItems.addAfter(item, this); + break; + default: + g_globals->_sceneItems.push_back(this); + break; + } +} + +void SceneHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { + _sceneRegionId = sceneRegionId; + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + // Handle adding hotspot to scene items list as necessary + switch (mode) { + case 2: + GLOBALS._sceneItems.push_front(this); + break; + case 3: + break; + default: + GLOBALS._sceneItems.push_back(this); + break; + } +} + /*--------------------------------------------------------------------------*/ void SceneObjectWrapper::setSceneObject(SceneObject *so) { @@ -3073,9 +3173,22 @@ void Player::enableControl() { } } -void Player::enableControl(CursorType cursor) { +void Player::disableControl(CursorType cursorId, CursorType objectId) { + if (cursorId != -1) + R2_GLOBALS._events.setCursor(cursorId); + else if (objectId != CURSOR_NONE) + R2_GLOBALS._events.setCursor(objectId); + + disableControl(); +} + +void Player::enableControl(CursorType cursorId, CursorType objectId) { enableControl(); - R2_GLOBALS._events.setCursor(cursor); + + if (cursorId != -1) + R2_GLOBALS._events.setCursor(cursorId); + else if (objectId != CURSOR_NONE) + R2_GLOBALS._events.setCursor(objectId); } void Player::process(Event &event) { diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 060ffee121..bd27a942a4 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -443,10 +443,17 @@ public: class SceneHotspot : public SceneItem { public: - SceneHotspot() : SceneItem() {} + int _resNum, _lookLineNum, _useLineNum, _talkLineNum; +public: + SceneHotspot(); + virtual void synchronize(Serializer &s); virtual bool startAction(CursorType action, Event &event); virtual Common::String getClassName() { return "SceneHotspot"; } virtual void doAction(int action); + + virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); + virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); + virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode = 0); }; enum AnimateMode {ANIM_MODE_NONE = 0, ANIM_MODE_1 = 1, ANIM_MODE_2 = 2, ANIM_MODE_3 = 3, @@ -646,7 +653,8 @@ public: void disableControl(); void enableControl(); - void enableControl(CursorType cursor); + void disableControl(CursorType cursorId, CursorType objectId = CURSOR_NONE); + void enableControl(CursorType cursorId, CursorType objectId = CURSOR_NONE); }; /*--------------------------------------------------------------------------*/ diff --git a/engines/tsage/events.h b/engines/tsage/events.h index fe4d3ecde6..dcff1b45b8 100644 --- a/engines/tsage/events.h +++ b/engines/tsage/events.h @@ -95,6 +95,7 @@ enum CursorType { R2_36 = 36, R2_37 = 37, R2_38 = 38, R2_39 = 39, R2_40 = 40, R2_41 = 41, R2_42 = 42, R2_43 = 43, R2_44 = 44, R2_45 = 45, R2_46 = 46, R2_47 = 47, R2_48 = 48, R2_49 = 49, R2_50 = 50, R2_51 = 51, R2_52 = 52, + R2_LAST_INVENT = 53, // Ringworld 2 cursors R2CURSORS_START = 0x8000, EXITCURSOR_N = 0x8007, EXITCURSOR_S = 0x8008, EXITCURSOR_W = 0x8009, diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index da40485617..d30d585c09 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -381,12 +381,15 @@ void Ringworld2Globals::reset() { T2_GLOBALS._uiElements._active = false; // Reset fields + _v558B6.set(0, 0, 0, 0); _v5657C = 0; _v565F5 = 0; _v565AE = 0; for (int i = 0; i < 14; i++) _v56605[i] = 0; _v56AA0 = 0; + _v56AA1 = 0; + _v56AAB = 0; _v57C2C = 0; _v58CE2 = 0; Common::fill(&_v565F1[0], &_v565F1[MAX_CHARACTERS], 0); @@ -417,8 +420,11 @@ void Ringworld2Globals::synchronize(Serializer &s) { TsAGE2Globals::synchronize(s); int i; + _v558B6.synchronize(s); + s.syncAsSint16LE(_v5657C); s.syncAsSint16LE(_v565F5); + s.syncAsSint16LE(_v56AAB); s.syncAsSint16LE(_v57C2C); s.syncAsSint16LE(_v58CE2); s.syncAsSint16LE(_speechSubtitles); @@ -428,6 +434,8 @@ void Ringworld2Globals::synchronize(Serializer &s) { s.syncAsByte(_v565AE); s.syncAsByte(_v56AA0); + s.syncAsByte(_v56AA1); + for (i = 0; i < 14; ++i) s.syncAsByte(_v56605[i]); diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index 7e40276fcf..498659d3ae 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -248,11 +248,14 @@ public: PlayStream _playStream; StripProxy _stripProxy; int _insetUp; + Rect _v558B6; int _v565F5; int _v5657C; byte _v565AE; byte _v56605[14]; byte _v56AA0; + byte _v56AA1; + int _v56AAB; int _v57C2C; int _v58CE2; int _speechSubtitles; diff --git a/engines/tsage/ringworld/ringworld_logic.h b/engines/tsage/ringworld/ringworld_logic.h index 6f6a66cc26..b3f103f293 100644 --- a/engines/tsage/ringworld/ringworld_logic.h +++ b/engines/tsage/ringworld/ringworld_logic.h @@ -161,7 +161,6 @@ public: class NamedHotspot : public SceneHotspot { public: - int _resNum, _lookLineNum, _useLineNum, _talkLineNum; NamedHotspot(); virtual void doAction(int action); diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 0844a48ed8..4462122a4d 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -81,7 +81,8 @@ Scene *Ringworld2Game::createScene(int sceneNumber) { // Sick bay return new Scene800(); case 825: - error("Missing scene %d from group 0", sceneNumber); + // Autodoc + return new Scene825(); case 850: // Deck #5 - By Lift return new Scene850(); @@ -184,24 +185,43 @@ Scene *Ringworld2Game::createScene(int sceneNumber) { // Autopsy room return new Scene3175(); case 3200: - // Cutscene : Cutscene : Rocko & co - Discussion + // Cutscene : Guards - Discussion return new Scene3200(); case 3210: // Cutscene : Captain and Private - Discussion return new Scene3210(); case 3220: + // Cutscene : Guards in cargo zone + return new Scene3220(); case 3230: + // Cutscene : Guards on duty + return new Scene3230(); case 3240: + // Cutscene : Teal monolog + return new Scene3240(); case 3245: + // Cutscene : Discussions with Dr. Tomko + return new Scene3245(); case 3250: + // Room with large stasis field negator + return new Scene3250(); case 3255: + return new Scene3255(); case 3260: + // Computer room + return new Scene3260(); case 3275: + // Hall + return new Scene3275(); case 3350: + // Cutscene - Ship landing + return new Scene3350(); case 3375: case 3385: case 3395: + error("Missing scene %d from group 3", sceneNumber); case 3400: + return new Scene3400(); case 3500: case 3600: case 3700: @@ -303,7 +323,7 @@ void SceneExt::loadScene(int sceneNum) { } } -bool SceneExt::display(CursorType action) { +bool SceneExt::display(CursorType action, Event &event) { switch (action) { case CURSOR_CROSSHAIRS: return false; @@ -316,10 +336,41 @@ bool SceneExt::display(CursorType action) { case CURSOR_TALK: SceneItem::display2(1, R2_GLOBALS._randomSource.getRandomNumber(4) + 10); break; + case R2_NEGATOR_GUN: + if (R2_GLOBALS.getFlag(1)) + SceneItem::display2(2, action); + else + SceneItem::display2(5, 0); + break; + case R2_7: + if ((R2_GLOBALS._v565F1[1] == 2) || ((R2_GLOBALS._v565F1[1] == 1) && + (R2_GLOBALS._v565F1[2] == 2) && (R2_GLOBALS._sceneManager._previousScene == 300))) { + R2_GLOBALS._sound4.stop(); + R2_GLOBALS._sound3.play(46); + SceneItem::display2(5, 15); + } else { + R2_GLOBALS._sound3.play(43, 0); + SceneItem::display2(2, 0); + } + + R2_GLOBALS._sound4.play(45); + break; + case R2_9: + case R2_39: + R2_GLOBALS._sound3.play(44); + SceneItem::display2(2, action); + R2_GLOBALS._sound3.stop(); + break; + case R2_44: + R2_GLOBALS._sound3.play(99); + SceneItem::display2(2, action); + break; default: - return false; + SceneItem::display2(2, action); + break; } + event.handled = true; return true; } @@ -840,68 +891,6 @@ bool NamedHotspot::startAction(CursorType action, Event &event) { } } -void NamedHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { - setBounds(ys, xe, ye, xs); - _resNum = resnum; - _lookLineNum = lookLineNum; - _useLineNum = useLineNum; - _talkLineNum = -1; - g_globals->_sceneItems.addItems(this, NULL); -} - -void NamedHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { - setBounds(bounds); - _resNum = resNum; - _lookLineNum = lookLineNum; - _talkLineNum = talkLineNum; - _useLineNum = useLineNum; - - switch (mode) { - case 2: - g_globals->_sceneItems.push_front(this); - break; - case 4: - g_globals->_sceneItems.addBefore(item, this); - break; - case 5: - g_globals->_sceneItems.addAfter(item, this); - break; - default: - g_globals->_sceneItems.push_back(this); - break; - } -} - -void NamedHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { - _sceneRegionId = sceneRegionId; - _resNum = resNum; - _lookLineNum = lookLineNum; - _talkLineNum = talkLineNum; - _useLineNum = useLineNum; - - // Handle adding hotspot to scene items list as necessary - switch (mode) { - case 2: - GLOBALS._sceneItems.push_front(this); - break; - case 3: - break; - default: - GLOBALS._sceneItems.push_back(this); - break; - } -} - -void NamedHotspot::synchronize(Serializer &s) { - SceneHotspot::synchronize(s); - s.syncAsSint16LE(_resNum); - s.syncAsSint16LE(_lookLineNum); - s.syncAsSint16LE(_useLineNum); - - if (g_vm->getGameID() == GType_BlueForce) - s.syncAsSint16LE(_talkLineNum); -} - void SceneActor::postInit(SceneObjectList *OwnerList) { _lookLineNum = _talkLineNum = _useLineNum = -1; SceneObject::postInit(); @@ -943,7 +932,7 @@ bool SceneActor::startAction(CursorType action, Event &event) { } if (!handled) - handled = ((SceneExt *)R2_GLOBALS._sceneManager._scene)->display(action); + handled = ((SceneExt *)R2_GLOBALS._sceneManager._scene)->display(action, event); return handled; } diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 9eaa1b0cd1..67346bcc80 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -102,7 +102,7 @@ public: virtual void refreshBackground(int xAmount, int yAmount); virtual void saveCharacter(int characterIndex); - bool display(CursorType action); + bool display(CursorType action, Event &event); void fadeOut(); void clearScreen(); }; @@ -233,15 +233,10 @@ public: class NamedHotspot : public SceneHotspot { public: - int _resNum, _lookLineNum, _useLineNum, _talkLineNum; NamedHotspot(); virtual bool startAction(CursorType action, Event &event); virtual Common::String getClassName() { return "NamedHotspot"; } - virtual void synchronize(Serializer &s); - virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); - virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); - virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode = 0); }; class NamedHotspotExt : public NamedHotspot { diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index ceca8915d8..a58740394b 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -3183,6 +3183,364 @@ void Scene800::signal() { } } +/*-------------------------------------------------------------------------- + * Scene 825 - Autodoc + * + *--------------------------------------------------------------------------*/ + +Scene825::Button::Button(): SceneObject() { + _buttonId = 0; + _v2 = 0; + _buttonDown = false; +} + +void Scene825::Button::synchronize(Serializer &s) { + SceneObject::synchronize(s); + s.syncAsSint16LE(_buttonId); + s.syncAsSint16LE(_v2); + s.syncAsSint16LE(_buttonDown); +} + +void Scene825::Button::process(Event &event) { + Scene825 *scene = (Scene825 *)R2_GLOBALS._sceneManager._scene; + + if (!event.handled) { + if ((event.eventType == EVENT_BUTTON_DOWN) && _bounds.contains(event.mousePos) && !_buttonDown) { + scene->_sound1.play(14); + setFrame(2); + _buttonDown = true; + event.handled = true; + } + + if ((event.eventType == EVENT_BUTTON_UP) && _buttonDown) { + setFrame(1); + _buttonDown = false; + event.handled = true; + + scene->doButtonPress(_buttonId); + } + } +} + +bool Scene825::Button::startAction(CursorType action, Event &event) { + if (action == CURSOR_USE) + return false; + else + return SceneObject::startAction(action, event); +} + +void Scene825::Button::setButton(int buttonId) { + SceneObject::postInit(); + _v2 = buttonId; + _buttonDown = 0; + _sceneText._color1 = 92; + _sceneText._color2 = 0; + _sceneText._width = 200; + _sceneText.fixPriority(20); + _sceneText._fontNumber = 50; + + switch (buttonId) { + case 1: + _sceneText.setPosition(Common::Point(95, 58)); + break; + case 2: + _sceneText.setPosition(Common::Point(98, 75)); + break; + case 3: + _sceneText.setPosition(Common::Point(102, 95)); + break; + case 4: + _sceneText.setPosition(Common::Point(180, 58)); + _sceneText._textMode = ALIGN_RIGHT; + break; + case 5: + _sceneText.setPosition(Common::Point(177, 75)); + _sceneText._textMode = ALIGN_RIGHT; + break; + case 6: + _sceneText.setPosition(Common::Point(175, 95)); + _sceneText._textMode = ALIGN_RIGHT; + break; + default: + break; + } + + setDetails(825, 6, 7, -1, 2, NULL); +} + +void Scene825::Button::setText(int textId) { + _buttonId = textId; + _lookLineNum = textId; + + _sceneText.remove(); + if (_buttonId != 0) + _sceneText.setup(AUTODOC_ITEMS[textId - 1]); +} + +/*--------------------------------------------------------------------------*/ + +Scene825::Scene825(): SceneExt() { + _menuId = _frame1 = _frame2 = 0; +} + +void Scene825::postInit(SceneObjectList *OwnerList) { + SceneExt::postInit(); + loadScene(825); + R2_GLOBALS._player._uiEnabled = false; + BF_GLOBALS._interfaceY = 200; + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player._effect = 0; + R2_GLOBALS._player.setVisage(10); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _item2.setDetails(1, 825, 3, 4, 5); + _background.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 825, 0, -1, -1, 1, NULL); + + _sceneMode = 10; + signal(); +} + +void Scene825::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_menuId); + s.syncAsSint16LE(_frame1); + s.syncAsSint16LE(_frame2); +} + +void Scene825::remove() { + SceneExt::remove(); + R2_GLOBALS._player._uiEnabled = true; +} + +void Scene825::signal() { + switch (_sceneMode) { + case 10: + _button1.setButton(1); + _button1.setup(825, 1, 1); + _button1.setPosition(Common::Point(71, 71)); + _button2.setButton(2); + _button2.setup(825, 3, 1); + _button2.setPosition(Common::Point(74, 90)); + _button3.setButton(3); + _button3.setup(825, 5, 1); + _button3.setPosition(Common::Point(78, 109)); + _button4.setButton(4); + _button4.setup(825, 2, 1); + _button4.setPosition(Common::Point(248, 71)); + _button5.setButton(5); + _button5.setup(825, 4, 1); + _button5.setPosition(Common::Point(245, 90)); + _button6.setButton(6); + _button6.setup(825, 6, 1); + _button6.setPosition(Common::Point(241, 109)); + + doButtonPress(1); + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + break; + case 825: + _object5.remove(); + _sceneText._color1 = 92; + _sceneText._color2 = 0; + _sceneText._width = 200; + _sceneText.fixPriority(20); + _sceneText._fontNumber = 50; + _sceneText.setPosition(Common::Point(120, 75)); + _sceneText.setup(NO_MALADY_DETECTED); + _sceneMode = 826; + setAction(&_sequenceManager1, this, 826, &R2_GLOBALS._player, NULL); + break; + case 826: + _sceneText.remove(); + doButtonPress(1); + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + break; + case 827: + _object5.remove(); + R2_INVENTORY.setObjectScene(R2_OPTO_DISK, 825); + _sceneText.setPosition(Common::Point(108, 75)); + _sceneText.setup(FOREIGN_OBJECT_EXTRACTED); + _sceneMode = 826; + setAction(&_sequenceManager1, this, 826, &R2_GLOBALS._player, NULL); + break; + default: + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + break; + } +} + +void Scene825::process(Event &event) { + SceneExt::process(event); + + if (R2_GLOBALS._player._uiEnabled) { + _button1.process(event); + _button2.process(event); + _button3.process(event); + _button4.process(event); + _button5.process(event); + _button6.process(event); + } +} + +void Scene825::dispatch() { + if (R2_GLOBALS._sceneObjects->contains(&_object4) && + ((_object4._frame == 1) || (_object4._frame == 3)) && + (_object4._frame != _frame1)) { + _sound2.play(25); + } + + if (R2_GLOBALS._sceneObjects->contains(&_object1) && + (_object1._frame == 3) && (_object1._frame != _frame2)) { + _sound3.play(26); + } + + _frame1 = _object4._frame; + _frame2 = _object1._frame; + + Scene::dispatch(); +} + +void Scene825::doButtonPress(int buttonId) { + if ((_menuId != 4) || (buttonId == 5)) { + _button1.setText(0); + _button2.setText(0); + _button3.setText(0); + _button4.setText(0); + _button5.setText(0); + _button6.setText(0); + + switch (buttonId) { + case 2: + R2_GLOBALS._player.disableControl(); + _object5.postInit(); + _sceneMode = 825; + setAction(&_sequenceManager1, this, 825, &R2_GLOBALS._player, &_object5, NULL); + break; + case 3: + R2_GLOBALS._player.disableControl(); + _sceneText._color1 = 92; + _sceneText._color2 = 0; + _sceneText._width = 200; + _sceneText.fixPriority(20); + _sceneText._fontNumber = 50; + _sceneText.setPosition(Common::Point(115, 75)); + + if (R2_GLOBALS.getFlag(4)) { + if ((R2_INVENTORY.getObjectScene(R2_READER) != 800) || + (R2_INVENTORY.getObjectScene(R2_OPTICAL_FIBRE) != 800)) { + _sceneText.setPosition(Common::Point(116, 75)); + _sceneText.setup(ACCESS_CODE_REQUIRED); + } else if (R2_INVENTORY.getObjectScene(R2_OPTO_DISK) != 800) { + _sceneText.setPosition(Common::Point(115, 75)); + _sceneText.setup(NO_TREATMENT_REQUIRED); + } else { + _button6._buttonId = 5; + + _object5.postInit(); + setAction(&_sequenceManager1, this, 827, &_object5, NULL); + } + } else { + R2_GLOBALS.setFlag(2); + + if ((R2_INVENTORY.getObjectScene(R2_READER) != 800) || + (R2_INVENTORY.getObjectScene(R2_OPTICAL_FIBRE) != 800)) { + _sceneText.setPosition(Common::Point(116, 75)); + _sceneText.setup(ACCESS_CODE_REQUIRED); + } else { + _sceneText.setPosition(Common::Point(119, 75)); + _sceneText.setup(INVALID_ACCESS_CODE); + } + } + + if (_sceneMode != 827) { + _sceneMode = 826; + setAction(&_sequenceManager1, this, 826, &R2_GLOBALS._player, NULL); + } + break; + case 4: + _sound4.play(27); + _button6._buttonId = 5; + + _object1.postInit(); + _object1.setup(826, 7, 1); + _object1.setPosition(Common::Point(112, 67)); + _object1._numFrames = 1; + _object1.animate(ANIM_MODE_2); + + _object2.postInit(); + _object2.setup(826, 5, 1); + _object2.setPosition(Common::Point(158, 67)); + _object2._numFrames = 5; + _object2.animate(ANIM_MODE_2); + + _object3.postInit(); + _object3.setup(826, 6, 1); + _object3.setPosition(Common::Point(206, 67)); + _object3._numFrames = 1; + _object3.animate(ANIM_MODE_2); + + _object4.postInit(); + _object4.setup(826, 8, 1); + _object4.setPosition(Common::Point(158, 84)); + _object4._numFrames = 1; + _object4.animate(ANIM_MODE_2); + + _object5.postInit(); + _object5.setup(826, 4, 1); + _object5.setPosition(Common::Point(161, 110)); + break; + case 5: + R2_GLOBALS._player.disableControl(); + if (_menuId == 4) { + _menuId = 0; + + _object1.remove(); + _object2.remove(); + _object3.remove(); + _object4.remove(); + _object5.remove(); + + _sound2.stop(); + _sound3.stop(); + _sound4.stop(); + + doButtonPress(1); + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + } else { + R2_GLOBALS._sceneManager.changeScene(800); + } + break; + case 6: + R2_GLOBALS._player.disableControl(); + _sceneText._color1 = 92; + _sceneText._color2 = 0; + _sceneText._width = 200; + _sceneText.fixPriority(20); + _sceneText._fontNumber = 50; + _sceneText.setPosition(Common::Point(115, 75)); + _sceneText.setup(NO_TREATMENT_REQUIRED); + + _sceneMode = 826; + setAction(&_sequenceManager1, this, 826, &R2_GLOBALS._player, NULL); + break; + default: + _button1.setText(2); + _button2.setText(3); + _button3.setText(4); + _button4.setText(6); + _button6.setText(5); + break; + } + + _menuId = buttonId; + } +} /*-------------------------------------------------------------------------- * Scene 850 - Deck #5 - By Lift diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h index 6810b5d85a..7a36b8f15f 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.h +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -419,6 +419,42 @@ public: virtual void signal(); }; +class Scene825: public SceneExt { + /* Objects */ + class Button: public SceneObject { + public: + int _buttonId, _v2; + bool _buttonDown; + SceneText _sceneText; + public: + Button(); + void setButton(int buttonId); + void setText(int textId); + + virtual void synchronize(Serializer &s); + virtual void process(Event &event); + virtual bool startAction(CursorType action, Event &event); + }; +public: + NamedHotspot _background, _item2; + SceneActor _object1, _object2, _object3, _object4, _object5; + Button _button1, _button2, _button3, _button4, _button5, _button6; + ASoundExt _sound1, _sound2, _sound3, _sound4; + SequenceManager _sequenceManager1; + SceneText _sceneText; + int _menuId, _frame1, _frame2; +public: + Scene825(); + virtual void synchronize(Serializer &s); + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); + virtual void process(Event &event); + virtual void dispatch(); + + void doButtonPress(int buttonId); +}; + class Scene850: public SceneExt { /* Items */ class Indicator: public NamedHotspot { diff --git a/engines/tsage/ringworld2/ringworld2_scenes2.cpp b/engines/tsage/ringworld2/ringworld2_scenes2.cpp index b851ed4e22..1fe920e65c 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes2.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes2.cpp @@ -35,9 +35,7 @@ namespace Ringworld2 { *--------------------------------------------------------------------------*/ void Scene2000::initPlayer() { R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); - warning("initPlayer: %d", _mazePlayerMode); switch (_mazePlayerMode) { case 0: R2_GLOBALS._player.setStrip(5); @@ -49,7 +47,6 @@ void Scene2000::initPlayer() { } else R2_GLOBALS._player.setPosition(Common::Point(245, 129)); R2_GLOBALS._player.enableControl(); - warning("EnableControl, with 2 arguments?"); break; case 1: if (R2_GLOBALS._player._characterIndex == 1) @@ -179,8 +176,6 @@ void Scene2000::initExits() { _object1.remove(); - warning("initExits: %d", R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex]); - switch (R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex]) { case 3: case 10: @@ -395,7 +390,6 @@ void Scene2000::Action1::signal() { case 0: { _actionIndex = 1; Common::Point pt(-20, 127); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); scene->_objList1[_state].addMover(mover, &pt, scene); break; @@ -439,7 +433,6 @@ void Scene2000::Action1::signal() { case 5: { _actionIndex = 6; Common::Point pt(340, 127); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); scene->_objList1[_state].addMover(mover, &pt, this); break; @@ -482,7 +475,6 @@ void Scene2000::Action1::signal() { break; case 10: { Common::Point pt(290, 127); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); scene->_objList1[_state].addMover(mover, &pt, this); _actionIndex = 11; @@ -508,13 +500,11 @@ void Scene2000::Action1::signal() { case 15: if ((R2_GLOBALS._v56605[3 + _state] == 13) || (R2_GLOBALS._v56605[3 + _state] == 22) || (R2_GLOBALS._v56605[3 + _state] == 27)) { Common::Point pt(30, 127); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); scene->_objList1[_state].addMover(mover, &pt, this); _actionIndex = 16; } else { Common::Point pt(120, 127); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); scene->_objList1[_state].addMover(mover, &pt, this); _actionIndex = 16; @@ -546,15 +536,12 @@ void Scene2000::Action1::signal() { void Scene2000::Exit1::changeScene() { Scene2000 *scene = (Scene2000 *)R2_GLOBALS._sceneManager._scene; - warning("exit1"); scene->_exitingFlag = true; scene->_sceneMode = 0; - R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); + R2_GLOBALS._player.disableControl(CURSOR_ARROW); scene->_sceneMode = 10; - warning("TODO: Check sub_22D26"); Common::Point pt(-10, 129); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -564,15 +551,12 @@ void Scene2000::Exit1::changeScene() { void Scene2000::Exit2::changeScene() { Scene2000 *scene = (Scene2000 *)R2_GLOBALS._sceneManager._scene; - warning("exit2"); scene->_exitingFlag = true; scene->_sceneMode = 0; - R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); + R2_GLOBALS._player.disableControl(CURSOR_ARROW); scene->_sceneMode = 11; - warning("TODO: Check sub_22D26"); Common::Point pt(330, 129); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -580,12 +564,10 @@ void Scene2000::Exit2::changeScene() { void Scene2000::Exit3::changeScene() { Scene2000 *scene = (Scene2000 *)R2_GLOBALS._sceneManager._scene; - warning("exit13"); scene->_exitingFlag = true; scene->_sceneMode = 0; - R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); + R2_GLOBALS._player.disableControl(CURSOR_ARROW); scene->_sceneMode = 12; switch (R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex]) { @@ -650,12 +632,10 @@ void Scene2000::Exit3::changeScene() { } void Scene2000::Exit4::changeScene() { Scene2000 *scene = (Scene2000 *)R2_GLOBALS._sceneManager._scene; - warning("exit4"); scene->_exitingFlag = true; scene->_sceneMode = 0; - R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); + R2_GLOBALS._player.disableControl(CURSOR_ARROW); scene->_sceneMode = 13; switch (R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex]) { @@ -709,11 +689,9 @@ void Scene2000::Exit4::changeScene() { void Scene2000::Exit5::changeScene() { Scene2000 *scene = (Scene2000 *)R2_GLOBALS._sceneManager._scene; - warning("exit5"); scene->_sceneMode = 0; - R2_GLOBALS._player.disableControl(); - warning("DisableControl, with arguments?"); + R2_GLOBALS._player.disableControl(CURSOR_ARROW); scene->_sceneMode = 14; switch (R2_GLOBALS._v56605[R2_GLOBALS._player._characterIndex]) { @@ -1009,6 +987,9 @@ void Scene2000::signal() { g_globals->_sceneManager.changeScene(2535); break; default: + if (R2_GLOBALS._v56AAB != 0) + R2_GLOBALS._v56AAB = 0; + R2_GLOBALS._player.enableControl(CURSOR_ARROW); break; } break; @@ -1024,7 +1005,6 @@ void Scene2000::signal() { void Scene2000::process(Event &event) { if ((R2_GLOBALS._player._canWalk) && (event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_CROSSHAIRS)) { - warning("TODO: Check sub_22D26"); Common::Point pt(event.mousePos.x, 129); PlayerMover *mover = new PlayerMover(); @@ -1069,7 +1049,7 @@ bool Scene2350::Actor3::startAction(CursorType action, Event &event) { void Scene2350::ExitUp::changeScene() { Scene2350 *scene = (Scene2350 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.disableControl(CURSOR_CROSSHAIRS); scene->_sceneMode = 12; if (R2_GLOBALS._player._characterIndex == 1) scene->setAction(&scene->_sequenceManager, scene, 2350, &R2_GLOBALS._player, NULL); @@ -1080,11 +1060,10 @@ void Scene2350::ExitUp::changeScene() { void Scene2350::ExitWest::changeScene() { Scene2350 *scene = (Scene2350 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.disableControl(CURSOR_CROSSHAIRS); scene->_sceneMode = 11; Common::Point pt(-10, 129); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, scene); @@ -1157,7 +1136,6 @@ void Scene2350::postInit(SceneObjectList *OwnerList) { _sceneMode = 10; R2_GLOBALS._player.setPosition(Common::Point(-20, 129)); Common::Point pt(20, 129); - warning("TODO: Check sub_22D26"); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, this); diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp index 8ea83a2527..adcd86e391 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp @@ -43,7 +43,7 @@ void Scene3100::synchronize(Serializer &s) { s.syncAsSint16LE(_field412); } -bool Scene3100::Actor6::startAction(CursorType action, Event &event) { +bool Scene3100::Guard::startAction(CursorType action, Event &event) { if (action != CURSOR_TALK) return SceneActor::startAction(action, event); @@ -98,11 +98,11 @@ void Scene3100::postInit(SceneObjectList *OwnerList) { _sound1.fadeSound(130); setAction(&_sequenceManager, this, 3102, &_actor1, &R2_GLOBALS._player, &_actor3, &_actor4, &_actor5, NULL); } else { - _actor6.postInit(); - _actor6.setup(3110, 5, 1); - _actor6.changeZoom(50); - _actor6.setPosition(Common::Point(10, 149)); - _actor6.setDetails(3100, 6, -1, -1, 2, NULL); + _guard.postInit(); + _guard.setup(3110, 5, 1); + _guard.changeZoom(50); + _guard.setPosition(Common::Point(10, 149)); + _guard.setDetails(3100, 6, -1, -1, 2, NULL); _actor4.postInit(); _actor4.setup(3103, 1, 1); @@ -126,11 +126,11 @@ void Scene3100::postInit(SceneObjectList *OwnerList) { setAction(&_sequenceManager, this, 3101, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor3, NULL); } else { - _actor6.postInit(); - _actor6.setup(3110, 5, 1); - _actor6.changeZoom(50); - _actor6.setPosition(Common::Point(10, 149)); - _actor6.setDetails(3100, 6, -1, -1, 2, NULL); + _guard.postInit(); + _guard.setup(3110, 5, 1); + _guard.changeZoom(50); + _guard.setPosition(Common::Point(10, 149)); + _guard.setDetails(3100, 6, -1, -1, 2, NULL); _actor4.postInit(); _actor4.setup(3103, 1, 1); @@ -167,8 +167,7 @@ void Scene3100::remove() { void Scene3100::signal() { switch (_sceneMode) { case 10: - warning("TODO: Unknown cursor used (6/-6)"); - R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player.enableControl(CURSOR_TALK); break; case 3100: R2_GLOBALS._player._moveDiff = Common::Point(3, 2); @@ -233,8 +232,7 @@ bool Scene3125::Item1::startAction(CursorType action, Event &event) { SceneItem::display(_resNum, _talkLineNum, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, -999); break; default: - warning("scene->display() called with two parameters"); - return scene->display(action); + return scene->display(action, event); break; } @@ -822,8 +820,8 @@ bool Scene3175::Item1::startAction(CursorType action, Event &event) { default: break; } - warning("scene->display() called with two parameters"); - return scene->display(action); + + return scene->display(action, event); } bool Scene3175::Actor3::startAction(CursorType action, Event &event) { @@ -851,8 +849,8 @@ bool Scene3175::Actor3::startAction(CursorType action, Event &event) { default: break; } - warning("scene->display() called with two parameters"); - return scene->display(action); + + return scene->display(action, event); } bool Scene3175::Actor1::startAction(CursorType action, Event &event) { @@ -924,7 +922,7 @@ void Scene3175::signal() { } /*-------------------------------------------------------------------------- - * Scene 3200 - Cutscene : Rocko & co - Discussion + * Scene 3200 - Cutscene : Guards - Discussion * *--------------------------------------------------------------------------*/ void Scene3200::postInit(SceneObjectList *OwnerList) { @@ -976,5 +974,976 @@ void Scene3210::postInit(SceneObjectList *OwnerList) { void Scene3210::signal() { R2_GLOBALS._sceneManager.changeScene(1200); } + +/*-------------------------------------------------------------------------- + * Scene 3220 - Cutscene : Guards in cargo zone + * + *--------------------------------------------------------------------------*/ +void Scene3220::postInit(SceneObjectList *OwnerList) { + loadScene(3220); + R2_GLOBALS._v58CE2 = 0; + SceneExt::postInit(); + + _stripManager.addSpeaker(&_rockoSpeaker); + _stripManager.addSpeaker(&_jockoSpeaker); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + _actor2.postInit(); + + setAction(&_sequenceManager, this, 3220 + R2_GLOBALS._randomSource.getRandomNumber(1), &_actor1, &_actor2, NULL); +} + +void Scene3220::signal() { + R2_GLOBALS._sceneManager.changeScene(1200); +} + +/*-------------------------------------------------------------------------- + * Scene 3230 - Cutscene : Guards on duty + * + *--------------------------------------------------------------------------*/ +void Scene3230::postInit(SceneObjectList *OwnerList) { + loadScene(3230); + R2_GLOBALS._v58CE2 = 0; + SceneExt::postInit(); + + _stripManager.addSpeaker(&_rockoSpeaker); + _stripManager.addSpeaker(&_jockoSpeaker); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + _actor2.postInit(); + _actor3.postInit(); + + setAction(&_sequenceManager, this, 3230 + R2_GLOBALS._randomSource.getRandomNumber(1), &_actor1, &_actor2, &_actor3, NULL); +} + +void Scene3230::signal() { + R2_GLOBALS._sceneManager.changeScene(1200); +} + +/*-------------------------------------------------------------------------- + * Scene 3240 - Cutscene : Teal monolog + * + *--------------------------------------------------------------------------*/ +void Scene3240::postInit(SceneObjectList *OwnerList) { + loadScene(3240); + R2_GLOBALS._v58CE2 = 0; + SceneExt::postInit(); + + _stripManager.addSpeaker(&_tealSpeaker); + _stripManager.addSpeaker(&_webbsterSpeaker); + _stripManager.addSpeaker(&_mirandaSpeaker); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + _actor2.postInit(); + + setAction(&_sequenceManager, this, 3240 + R2_GLOBALS._randomSource.getRandomNumber(1), &_actor1, &_actor2, NULL); +} + +void Scene3240::signal() { + R2_GLOBALS._sceneManager.changeScene(1200); +} + +/*-------------------------------------------------------------------------- + * Scene 3245 - Cutscene : Discussions with Dr. Tomko + * + *--------------------------------------------------------------------------*/ +void Scene3245::postInit(SceneObjectList *OwnerList) { + loadScene(3245); + R2_GLOBALS._v58CE2 = 0; + SceneExt::postInit(); + + _stripManager.addSpeaker(&_ralfSpeaker); + _stripManager.addSpeaker(&_tomkoSpeaker); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + _actor2.postInit(); + + if (R2_GLOBALS._v56AA1 < 4) + ++R2_GLOBALS._v56AA1; + + if (R2_GLOBALS._v56AA1 >= 4) { + SceneItem::display(1200, 7, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); + signal(); + } else { + setAction(&_sequenceManager, this, 3244 + R2_GLOBALS._v56AA1, &_actor1, &_actor2, NULL); + } +} + +void Scene3245::signal() { + R2_GLOBALS._sceneManager.changeScene(1200); +} + +/*-------------------------------------------------------------------------- + * Scene 3250 - Room with large stasis field negator + * + *--------------------------------------------------------------------------*/ +bool Scene3250::Item::startAction(CursorType action, Event &event) { + Scene3250 *scene = (Scene3250 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + if (_useLineNum != -1) { + SceneItem::display(_resNum, _useLineNum, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, -999); + return true; + } + break; + case CURSOR_LOOK: + if (_lookLineNum != -1) { + SceneItem::display(_resNum, _lookLineNum, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, -999); + return true; + } + break; + case CURSOR_TALK: + if (_talkLineNum != -1) { + SceneItem::display(_resNum, _talkLineNum, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, -999); + return true; + } + break; + default: + break; + } + + return scene->display(action, event); +} + +bool Scene3250::Actor::startAction(CursorType action, Event &event) { + Scene3250 *scene = (Scene3250 *)R2_GLOBALS._sceneManager._scene; + + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + + switch(_position.x) { + case 25: + scene->_sceneMode = 3262; + scene->setAction(&scene->_sequenceManager, scene, 3262, &R2_GLOBALS._player, &scene->_actor1, NULL); + break; + case 259: + scene->_sceneMode = 3260; + scene->setAction(&scene->_sequenceManager, scene, 3260, &R2_GLOBALS._player, &scene->_actor2, NULL); + break; + case 302: + scene->_sceneMode = 3261; + scene->setAction(&scene->_sequenceManager, scene, 3261, &R2_GLOBALS._player, &scene->_actor3, NULL); + break; + default: + break; + } + return true; +} + +void Scene3250::postInit(SceneObjectList *OwnerList) { + loadScene(3250); + + if (R2_GLOBALS._sceneManager._previousScene == -1) { + R2_GLOBALS._player._oldCharacterScene[3] = 1200; + R2_GLOBALS._player._characterIndex = R2_MIRANDA; + } + + SceneExt::postInit(); + _actor1.postInit(); + _actor1.setup(3250, 6, 1); + _actor1.setPosition(Common::Point(25, 148)); + _actor1.fixPriority(10); + _actor1.setDetails(3250, 9, 10, -1, 1, NULL); + + _actor2.postInit(); + _actor2.setup(3250, 4, 1); + _actor2.setPosition(Common::Point(259, 126)); + _actor2.fixPriority(10); + _actor2.setDetails(3250, 9, 10, -1, 1, NULL); + + _actor3.postInit(); + _actor3.setup(3250, 5, 1); + _actor3.setPosition(Common::Point(302, 138)); + _actor3.fixPriority(10); + _actor3.setDetails(3250, 9, 10, -1, 1, NULL); + + _item3.setDetails(Rect(119, 111, 149, 168), 3250, 6, 7, 2, 1, NULL); + _item2.setDetails(Rect(58, 85, 231, 138), 3250, 12, 7, 2, 1, NULL); + _item4.setDetails(12, 3250, 3, 1, 2); + _item1.setDetails(Rect(0, 0, 320, 200), 3250, 0, 1, 2, 1, NULL); + + R2_GLOBALS._player.postInit(); + + switch (R2_GLOBALS._player._oldCharacterScene[3]) { + case 1200: + _sceneMode = 3250; + _actor4.postInit(); + R2_GLOBALS._player._effect = 0; + setAction(&_sequenceManager, this, 3250, &R2_GLOBALS._player, &_actor4, NULL); + break; + case 3125: + if (R2_GLOBALS.getFlag(79)) { + _sceneMode = 3254; + _actor5.postInit(); + _actor5._effect = 1; + _actor6.postInit(); + _actor6._effect = 1; + _actor7.postInit(); + _actor7._effect = 1; + setAction(&_sequenceManager, this, 3254, &R2_GLOBALS._player, &_actor3, &_actor5, &_actor6, &_actor7, &_actor1, NULL); + } else { + _sceneMode = 3252; + setAction(&_sequenceManager, this, 3252, &R2_GLOBALS._player, &_actor3, NULL); + } + break; + case 3175: + _sceneMode = 3251; + setAction(&_sequenceManager, this, 3251, &R2_GLOBALS._player, &_actor2, NULL); + break; + case 3255: + _sceneMode = 3253; + setAction(&_sequenceManager, this, 3253, &R2_GLOBALS._player, &_actor1, NULL); + break; + default: + R2_GLOBALS._player.setup(31, 3, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setPosition(Common::Point(185, 150)); + R2_GLOBALS._player.enableControl(); + break; + } + + R2_GLOBALS._player._oldCharacterScene[3] = 3250; +} + +void Scene3250::signal() { + switch(_sceneMode) { + case 3250: + R2_GLOBALS._player._effect = 1; + R2_GLOBALS._player.enableControl(); + break; + case 3254: + //No break on purpose + case 3262: + R2_GLOBALS._sceneManager.changeScene(3255); + break; + case 3260: + R2_GLOBALS._sceneManager.changeScene(3175); + break; + case 3261: + R2_GLOBALS._sceneManager.changeScene(3125); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +void Scene3250::dispatch() { + if ((R2_GLOBALS._player._visage == 3250) && (R2_GLOBALS._player._strip == 3) && (R2_GLOBALS._player._effect == 0)) { + R2_GLOBALS._player._effect = 6; + R2_GLOBALS._player._shade = 6; + } + + Scene::dispatch(); +} + +/*-------------------------------------------------------------------------- + * Scene 3255 - + * + *--------------------------------------------------------------------------*/ +void Scene3255::postInit(SceneObjectList *OwnerList) { + loadScene(3255); + SceneExt::postInit(); + + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_mirandaSpeaker); + + if (R2_GLOBALS._sceneManager._previousScene == -1) + R2_GLOBALS.setFlag(79); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.disableControl(); + + if (R2_GLOBALS.getFlag(79)) { + R2_GLOBALS._sound1.play(267); + R2_GLOBALS._sound2.play(268); + _sceneMode = 3257; + _actor3.postInit(); + _actor4.postInit(); + _actor4._effect = 1; + setAction(&_sequenceManager, this, 3257, &R2_GLOBALS._player, &_actor4, &_actor3, NULL); + } else { + _actor1.postInit(); + _actor1.setup(303, 1, 1); + _actor1.setPosition(Common::Point(208, 128)); + _actor2.postInit(); + _actor2.setup(3107, 3, 1); + _actor2.setPosition(Common::Point(230, 127)); + _sceneMode = 3255; + setAction(&_sequenceManager, this, 3255, &R2_GLOBALS._player, NULL); + } + R2_GLOBALS._player._oldCharacterScene[3] = 3255; +} + +void Scene3255::signal() { + switch (_sceneMode) { + case 10: + _sceneMode = 3258; + _actor5.postInit(); + _actor6.postInit(); + _actor7.postInit(); + setAction(&_sequenceManager, this, 3258, &R2_GLOBALS._player, &_actor4, &_actor3, &_actor5, &_actor6, &_actor7, NULL); + break; + case 3256: + R2_GLOBALS._sceneManager.changeScene(3250); + break; + case 3257: + _sceneMode = 10; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(607, this); + break; + case 3258: + R2_GLOBALS._sceneManager.changeScene(3100); + break; + default: + SceneItem::display(3255, 0, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); + _sceneMode = 3256; + setAction(&_sequenceManager, this, 3256, &R2_GLOBALS._player, NULL); + } +} + +void Scene3255::dispatch() { + if (R2_GLOBALS.getFlag(79)) { + if (_actor5._position.y >= 95) { + if (_actor5._position.y <= 110) + _actor5._shade = 6 - (_actor5._position.y - 95) / 3; + else + _actor5._effect = 1; + } else { + _actor5._effect = 6; + _actor5._shade = 6; + } + + if (_actor6._position.y >= 95) { + if (_actor6._position.y <= 110) + _actor6._shade = 6 - (_actor6._position.y - 95) / 3; + else + _actor6._effect = 1; + } else { + _actor6._effect = 6; + _actor6._shade = 6; + } + + if (_actor7._position.y >= 95) { + if (_actor7._position.y <= 110) + _actor7._shade = 6 - (_actor7._position.y - 95) / 3; + else + _actor7._effect = 1; + } else { + _actor7._effect = 6; + _actor7._shade = 6; + } + } + + if ((R2_GLOBALS._player._position.x > 250) && (R2_GLOBALS._player._shade == 1)) { + R2_GLOBALS._player._effect = 6; + _actor4._effect = 6; + } + Scene::dispatch(); +} + +/*-------------------------------------------------------------------------- + * Scene 3260 - Computer room + * + *--------------------------------------------------------------------------*/ +bool Scene3260::Actor13::startAction(CursorType action, Event &event) { + Scene3260 *scene = (Scene3260 *)R2_GLOBALS._sceneManager._scene; + + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 3271; + scene->setAction(&scene->_sequenceManager, scene, 3271, &R2_GLOBALS._player, &scene->_actor13, NULL); + return true; +} + +bool Scene3260::Actor14::startAction(CursorType action, Event &event) { + Scene3260 *scene = (Scene3260 *)R2_GLOBALS._sceneManager._scene; + + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 3272; + scene->setAction(&scene->_sequenceManager, scene, 3272, &R2_GLOBALS._player, &scene->_actor14, NULL); + return true; +} + +void Scene3260::Action1::signal() { + SceneObjectExt *fmtObj = (SceneObjectExt *) _endHandler; + + fmtObj->setFrame(R2_GLOBALS._randomSource.getRandomNumber(6)); + setDelay(120 + R2_GLOBALS._randomSource.getRandomNumber(179)); +} + +void Scene3260::postInit(SceneObjectList *OwnerList) { + loadScene(3260); + R2_GLOBALS._player._characterIndex = R2_MIRANDA; + SceneExt::postInit(); + R2_GLOBALS._sound1.play(285); + + _actor13.postInit(); + _actor13.setup(3260, 6, 1); + _actor13.setPosition(Common::Point(40, 106)); + _actor13.setDetails(3260, 18, 1, -1, 1, NULL); + + if (R2_INVENTORY.getObjectScene(52) == 3260) { + _actor14.postInit(); + _actor14.setup(3260, 7, 1); + _actor14.setPosition(Common::Point(202, 66)); + _actor14.setDetails(3260, 12, 1, -1, 1, NULL); + } + + _actor1.postInit(); + _actor1.setup(3260, 1, 1); + _actor1.setPosition(Common::Point(93, 73)); + _actor1.setDetails(3260, 3, 1, 5, 1, NULL); + _actor1.setAction(&_action1, &_actor1); + + _actor2.postInit(); + _actor2.setup(3260, 2, 1); + _actor2.setPosition(Common::Point(142, 63)); + _actor2.setDetails(3260, 3, 1, 5, 1, NULL); + _actor2.setAction(&_action2, &_actor2); + + _actor3.postInit(); + _actor3.setup(3260, 2, 1); + _actor3.setPosition(Common::Point(166, 54)); + _actor3.setDetails(3260, 3, 1, 5, 1, NULL); + _actor3.setAction(&_action3, &_actor3); + + _actor4.postInit(); + _actor4.setup(3260, 2, 1); + _actor4.setPosition(Common::Point(190, 46)); + _actor4.setDetails(3260, 3, 1, 5, 1, NULL); + _actor4.setAction(&_action4, &_actor4); + + _actor5.postInit(); + _actor5.setup(3260, 2, 1); + _actor5.setPosition(Common::Point(142, 39)); + _actor5.setDetails(3260, 3, 1, 5, 1, NULL); + _actor5.setAction(&_action5, &_actor5); + + _actor6.postInit(); + _actor6.setup(3260, 2, 1); + _actor6.setPosition(Common::Point(166, 30)); + _actor6.setDetails(3260, 3, 1, 5, 1, NULL); + _actor6.setAction(&_action6, &_actor6); + + _actor7.postInit(); + _actor7.setup(3260, 2, 1); + _actor7.setPosition(Common::Point(190, 22)); + _actor7.setDetails(3260, 3, 1, 5, 1, NULL); + _actor7.setAction(&_action7, &_actor7); + + _actor8.postInit(); + _actor8.setup(3260, 2, 1); + _actor8.setPosition(Common::Point(142, 14)); + _actor8.setDetails(3260, 3, 1, 5, 1, NULL); + _actor8.setAction(&_action8, &_actor8); + + _actor9.postInit(); + _actor9.setup(3260, 2, 1); + _actor9.setPosition(Common::Point(166, 6)); + _actor9.setDetails(3260, 3, 1, 5, 1, NULL); + _actor9.setAction(&_action9, &_actor9); + + _actor10.postInit(); + _actor10.setup(3260, 3, 1); + _actor10.setPosition(Common::Point(265, 163)); + _actor10.fixPriority(180); + _actor10._numFrames = 10; + _actor10.setDetails(3260, 6, 1, 8, 1, NULL); + _actor10.animate(ANIM_MODE_2, NULL); + + _actor11.postInit(); + _actor11.setup(3260, 4, 1); + _actor11.setPosition(Common::Point(127, 108)); + _actor11.fixPriority(120); + _actor11.setAction(&_action11, &_actor11); + _actor11._numFrames = 15; + _actor11.setDetails(3260, 6, 1, 8, 1, NULL); + _actor11.animate(ANIM_MODE_2, NULL); + + _actor12.postInit(); + _actor12.setup(3260, 5, 1); + _actor12.setPosition(Common::Point(274, 65)); + _actor12.setAction(&_action12, &_actor12); + _actor12._numFrames = 5; + _actor12.setDetails(3260, 9, 1, 11, 1, NULL); + _actor12.animate(ANIM_MODE_2, NULL); + + _item1.setDetails(Rect(0, 0, 320, 200), 3260, 0, 1, 2, 1, NULL); + R2_GLOBALS._player.postInit(); + + if (R2_GLOBALS._player._oldCharacterScene[3] == 3275) { + _sceneMode = 3270; + setAction(&_sequenceManager, this, 3270, &R2_GLOBALS._player, &_actor13, NULL); + } else { + R2_GLOBALS._player.setup(30, 5, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setPosition(Common::Point(53, 113)); + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + R2_GLOBALS._player.enableControl(); + } + R2_GLOBALS._player._oldCharacterScene[3] = 3260; +} + +void Scene3260::remove() { + R2_GLOBALS._sound1.fadeOut2(NULL); + SceneExt::remove(); +} + +void Scene3260::signal() { + switch (_sceneMode) { + case 3271: + R2_GLOBALS._sceneManager.changeScene(3275); + break; + case 3272: + _sceneMode = 3273; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + SceneItem::display(3260, 15, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, -999); + R2_GLOBALS._player.disableControl(); + R2_INVENTORY.setObjectScene(52, 3); + R2_INVENTORY.setObjectScene(43, 3); + setAction(&_sequenceManager, this, 3273, &R2_GLOBALS._player, &_actor14, NULL); + break; + case 3273: + _actor4.remove(); + R2_GLOBALS._player.enableControl(); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +/*-------------------------------------------------------------------------- + * Scene 3275 - Hall + * + *--------------------------------------------------------------------------*/ +bool Scene3275::Actor2::startAction(CursorType action, Event &event) { + Scene3275 *scene = (Scene3275 *)R2_GLOBALS._sceneManager._scene; + + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 3275; + scene->setAction(&scene->_sequenceManager, scene, 3275, &R2_GLOBALS._player, &scene->_actor2, NULL); + return true; +} + +void Scene3275::Exit1::changeScene() { + Scene3275 *scene = (Scene3275 *)R2_GLOBALS._sceneManager._scene; + + scene->_sceneMode = 0; + g_globals->_events.setCursor(CURSOR_ARROW); + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 10; + Common::Point pt(418, 118); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} + +void Scene3275::postInit(SceneObjectList *OwnerList) { + loadScene(3275); + + if (R2_GLOBALS._sceneManager._previousScene == -1) + R2_GLOBALS._sceneManager._previousScene = 3260; + + if (R2_GLOBALS._sceneManager._previousScene == 3150) + g_globals->gfxManager()._bounds.moveTo(Common::Point(160, 0)); + else + g_globals->gfxManager()._bounds.moveTo(Common::Point(0, 0)); + + SceneExt::postInit(); + _exit1.setDetails(Rect(398, 60, 439, 118), SHADECURSOR_UP, 3150); + _exit1.setDest(Common::Point(418, 128)); + + _actor1.postInit(); + _actor1.setup(3275, 1, 7); + _actor1.setPosition(Common::Point(419, 119)); + + _actor2.postInit(); + _actor2.setup(3275, 2, 1); + _actor2.setPosition(Common::Point(56, 118)); + _actor2.setDetails(3275, 3, 4, -1, 1, NULL); + + _item2.setDetails(Rect(153, 58, 200, 120), 3275, 6, 7, 8, 1, NULL); + _item3.setDetails(Rect(275, 58, 331, 120), 3275, 6, 7, 8, 1, NULL); + _item4.setDetails(Rect(0, 66, 22, 127), 3275, 9, 10, 11, 1, NULL); + _item5.setDetails(Rect(457, 66, 480, 127), 3275, 9, 10, 11, 1, NULL); + _item1.setDetails(Rect(0, 0, 480, 200), 3275, 0, 1, 2, 1, NULL); + + R2_GLOBALS._scrollFollower = &R2_GLOBALS._player; + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._oldCharacterScene[3] == 3150) { + _sceneMode = 11; + R2_GLOBALS._player.setup(30, 3, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setPosition(Common::Point(418, 118)); + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + Common::Point pt(418, 128); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else if (R2_GLOBALS._player._oldCharacterScene[3] == 3260) { + _sceneMode = 3276; + setAction(&_sequenceManager, this, 3276, &R2_GLOBALS._player, &_actor2, NULL); + } else { + R2_GLOBALS._player.setup(30, 3, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setPosition(Common::Point(245, 135)); + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + R2_GLOBALS._player.enableControl(); + } + R2_GLOBALS._player._oldCharacterScene[3] = 3275; +} + +void Scene3275::signal() { + switch (_sceneMode) { + case 10: + R2_GLOBALS._sceneManager.changeScene(3150); + break; + case 3275: + R2_GLOBALS._sceneManager.changeScene(3260); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +/*-------------------------------------------------------------------------- + * Scene 3350 - Cutscene - Ship landing + * + *--------------------------------------------------------------------------*/ +void Scene3350::postInit(SceneObjectList *OwnerList) { + loadScene(3350); + R2_GLOBALS._v58CE2 = 0; + SceneExt::postInit(); + R2_GLOBALS._sound2.play(310); + + _rotation = R2_GLOBALS._scenePalette.addRotation(176, 203, 1); + _rotation->setDelay(3); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + _actor1.hide(); + _actor2.postInit(); + _actor2.hide(); + _actor3.postInit(); + _actor3.hide(); + _actor4.postInit(); + _actor4.hide(); + _actor9.postInit(); + _actor9.hide(); + _actor8.postInit(); + _actor8.hide(); + _actor5.postInit(); + _actor5.hide(); + _actor6.postInit(); + _actor6.hide(); + _actor7.postInit(); + _actor7.hide(); + + _sceneMode = 3350; + setAction(&_sequenceManager, this, _sceneMode, &_actor5, &_actor6, &_actor7, NULL); +} + +void Scene3350::remove() { + R2_GLOBALS._sound2.fadeOut2(NULL); + SceneExt::remove(); +} + +void Scene3350::signal() { + switch (_sceneMode) { + case 3350: + _sceneMode = 3351; + setAction(&_sequenceManager, this, 3351, &_actor4, &_actor9, &_actor8, NULL); + break; + case 3351: + _sceneMode = 3352; + setAction(&_sequenceManager, this, 3352, &_actor4, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor3, NULL); + case 3352: + R2_GLOBALS._sceneManager.changeScene(3395); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +/*-------------------------------------------------------------------------- + * Scene 3400 - + * + *--------------------------------------------------------------------------*/ +Scene3400::Scene3400() { + _field157C = 0; +} + +void Scene3400::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_field157C); +} + +void Scene3400::postInit(SceneObjectList *OwnerList) { + R2_GLOBALS._scrollFollower = &R2_GLOBALS._player; + g_globals->gfxManager()._bounds.moveTo(Common::Point(160, 0)); + loadScene(3400); + _field157C = 0; + R2_GLOBALS._v558B6.set(60, 0, 260, 200); + SceneExt::postInit(); + R2_GLOBALS._sound1.play(317); + + _stripManager.setColors(60, 255); + _stripManager.setFontNumber(3); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); + _stripManager.addSpeaker(&_mirandaSpeaker); + _stripManager.addSpeaker(&_webbsterSpeaker); + _stripManager.addSpeaker(&_tealSpeaker); + + setZoomPercents(51, 46, 180, 200); + R2_GLOBALS._player._characterScene[1] = 3400; + R2_GLOBALS._player._characterScene[2] = 3400; + R2_GLOBALS._player._characterScene[3] = 3400; + + _actor7.postInit(); + _actor7.setup(3403, 1, 1); + _actor7.setPosition(Common::Point(190, 103)); + _actor7.fixPriority(89); + + R2_GLOBALS._player.postInit(); + if (R2_GLOBALS._player._characterIndex == 2) + R2_GLOBALS._player._moveDiff = Common::Point(5, 3); + else + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + R2_GLOBALS._player.changeZoom(-1); + R2_GLOBALS._player.setPosition(Common::Point(239, 64)); + + if (R2_GLOBALS._player._characterIndex == 2) + R2_GLOBALS._player.setup(20, 5, 1); + else if (R2_GLOBALS._player._characterIndex == 3) + R2_GLOBALS._player.setup(30, 5, 1); + else + R2_GLOBALS._player.setup(10, 5, 1); + + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.disableControl(); + + _actor1.postInit(); + if (R2_GLOBALS._player._characterIndex == 2) { + _actor1._numFrames = 10; + _actor1._moveDiff = Common::Point(3, 2); + } else { + _actor1._numFrames = 7; + _actor1._moveDiff = Common::Point(5, 3); + } + _actor1.changeZoom(-1); + _actor1._effect = 1; + _actor1.setPosition(Common::Point(247, 63)); + if (R2_GLOBALS._player._characterIndex == 2) + _actor1.setup(10, 5, 1); + else + _actor1.setup(20, 5, 1); + _actor1.animate(ANIM_MODE_1, NULL); + + _actor2.postInit(); + _actor2._moveDiff = Common::Point(3, 2); + _actor2.changeZoom(-1); + _actor2._effect = 1; + _actor2.setPosition(Common::Point(225, 63)); + if (R2_GLOBALS._player._characterIndex == 3) + _actor2.setup(10, 5, 1); + else + _actor2.setup(30, 5, 1); + _actor2.animate(ANIM_MODE_1, NULL); + + _actor3.postInit(); + _actor3._numFrames = 7; + _actor3._moveDiff = Common::Point(5, 3); + _actor3.changeZoom(-1); + _actor3._effect = 1; + _actor3.setPosition(Common::Point(235, 61)); + _actor3.setup(40, 3, 1); + _actor3.animate(ANIM_MODE_1, NULL); + + _actor6.postInit(); + _actor6.setup(3400, 1, 6); + _actor6.setPosition(Common::Point(236, 51)); + _actor6.fixPriority(51); + _actor6.animate(ANIM_MODE_6, NULL); + + R2_GLOBALS.clearFlag(71); + _sceneMode = 3400; + setAction(&_sequenceManager, this, 3400, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor3, NULL); +} + +void Scene3400::remove() { + R2_GLOBALS._sound2.fadeOut2(NULL); + R2_GLOBALS._sound1.fadeOut2(NULL); + SceneExt::remove(); +} + +void Scene3400::signal() { + switch (_sceneMode) { + case 3305: { + warning("STUB: sub_1D227()"); + _tealSpeaker._object1.hide(); + _actor4.show(); + _actor4.setStrip(1); + Common::Point pt(158, 190); + NpcMover *mover = new NpcMover(); + _actor4.addMover(mover, &pt, this); + _sceneMode = 3402; + setAction(&_sequenceManager, this, 3402, &R2_GLOBALS._player, &_actor1, &_actor2, &_actor3, NULL); + } + break; + case 3306: + R2_GLOBALS._sound2.play(318); + _actor1.setStrip(2); + R2_GLOBALS._player.setStrip(6); + _actor2.setStrip(6); + _actor3.setStrip(3); + _actor4.setStrip(1); + R2_INVENTORY.setObjectScene(34, 0); + _stripManager.start(3307, this); + if (R2_GLOBALS._player._characterIndex == 2) { + _sceneMode = 3400; + R2_GLOBALS._player.setAction(&_sequenceManager, this, 3400, &R2_GLOBALS._player, &_actor4, &_actor8, NULL); + } else { + _sceneMode = 3408; + _actor1.setAction(&_sequenceManager, this, 3408, &_actor1, &_actor4, &_actor8, NULL); + } + break; + case 3307: + case 3404: + case 3408: + if (_field157C == 0) { + R2_GLOBALS._sound2.fadeOut2(NULL); + _field157C = 1; + } else { + _sceneMode = 3308; + _stripManager.start(3308, this); + } + break; + case 3308: + warning("STUB: sub_1D227()"); + _actor1.setStrip(2); + R2_GLOBALS._player.setStrip(6); + _actor2.setStrip(6); + _actor3.setStrip(3); + _actor4.setStrip(1); + _sceneMode = 3403; + if (R2_GLOBALS._player._characterIndex == 2) + setAction(&_sequenceManager, this, 3403, &R2_GLOBALS._player, &_actor3, &_actor7, NULL); + else + setAction(&_sequenceManager, this, 3403, &_actor1, &_actor3, &_actor7, NULL); + break; + case 3309: + warning("STUB: sub_1D227()"); + _actor4.setStrip(1); + _sceneMode = 3405; + if (R2_GLOBALS._player._characterIndex == 3) + setAction(&_sequenceManager, this, 3405, &R2_GLOBALS._player, &_actor7, NULL); + else + setAction(&_sequenceManager, this, 3405, &_actor2, &_actor7, NULL); + break; + case 3310: + warning("STUB: sub_1D227()"); + _actor4.setStrip(1); + _sceneMode = 3406; + if (R2_GLOBALS._player._characterIndex == 1) + setAction(&_sequenceManager, this, 3406, &R2_GLOBALS._player, &_actor7, NULL); + else if (R2_GLOBALS._player._characterIndex == 2) + setAction(&_sequenceManager, this, 3406, &_actor1, &_actor7, NULL); + else if (R2_GLOBALS._player._characterIndex == 3) + setAction(&_sequenceManager, this, 3406, &_actor2, &_actor7, NULL); + break; + case 3311: + warning("STUB: sub_1D227()"); + _tealSpeaker._object1.hide(); + _actor4.show(); + _actor4.setStrip(1); + _sceneMode = 3407; + setAction(&_sequenceManager, this, 3407, &_actor4, &_actor7, NULL); + break; + case 3400: { + _actor8.postInit(); + _actor8.hide(); + _actor4.postInit(); + _actor4._numFrames = 7; + _actor4._moveDiff = Common::Point(3, 2); + _actor4.changeZoom(-1); + _actor4._effect = 1; + _actor4.setPosition(Common::Point(-15, 90)); + _actor4.setup(3402, 1, 1); + _actor4.animate(ANIM_MODE_1, NULL); + Common::Point pt1(115, 90); + NpcMover *mover1 = new NpcMover(); + _actor4.addMover(mover1, &pt1, this); + R2_GLOBALS._scrollFollower = &_actor4; + Common::Point pt2(203, 76); + NpcMover *mover2 = new NpcMover(); + _actor3.addMover(mover2, &pt2, NULL); + _sceneMode = 3401; + } + break; + case 3401: + _sceneMode = 3305; + _stripManager.start(3305, this); + break; + case 3402: + _sceneMode = 3306; + _stripManager.start(3306, this); + break; + case 3403: + R2_GLOBALS._scrollFollower = &R2_GLOBALS._player; + _sceneMode = 3309; + _stripManager.start(3309, this); + break; + case 3405: + _sceneMode = 3310; + _stripManager.start(3310, this); + break; + case 3406: + _sceneMode = 3311; + _stripManager.start(3311, this); + break; + case 3407: + R2_GLOBALS._sceneManager.changeScene(3600); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + } // End of namespace Ringworld2 } // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.h b/engines/tsage/ringworld2/ringworld2_scenes3.h index fbb6392be4..8968bddf1a 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.h +++ b/engines/tsage/ringworld2/ringworld2_scenes3.h @@ -41,7 +41,7 @@ using namespace TsAGE; class Scene3100 : public SceneExt { - class Actor6 : public SceneActor { + class Guard : public SceneActor { virtual bool startAction(CursorType action, Event &event); }; public: @@ -55,7 +55,7 @@ public: SceneActor _actor3; SceneActor _actor4; SceneActor _actor5; - Actor6 _actor6; + Guard _guard; ASoundExt _sound1; SequenceManager _sequenceManager; @@ -211,6 +211,219 @@ public: virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void signal(); }; + +class Scene3220 : public SceneExt { +public: + SpeakerRocko3220 _rockoSpeaker; + SpeakerJocko3220 _jockoSpeaker; + SceneActor _actor1; + SceneActor _actor2; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); +}; + +class Scene3230 : public SceneExt { +public: + SpeakerRocko3230 _rockoSpeaker; + SpeakerJocko3230 _jockoSpeaker; + SceneActor _actor1; + SceneActor _actor2; + SceneActor _actor3; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); +}; + +class Scene3240 : public SceneExt { +public: + SpeakerTeal3240 _tealSpeaker; + SpeakerWebbster3240 _webbsterSpeaker; + SpeakerMiranda2500 _mirandaSpeaker; + SceneActor _actor1; + SceneActor _actor2; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); +}; + +class Scene3245 : public SceneExt { +public: + SpeakerRalf3245 _ralfSpeaker; + SpeakerTomko3245 _tomkoSpeaker; + SceneActor _actor1; + SceneActor _actor2; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); +}; + +class Scene3250 : public SceneExt { + class Item : public NamedHotspot { + public: + virtual bool startAction(CursorType action, Event &event); + }; + + class Actor : public SceneActor { + virtual bool startAction(CursorType action, Event &event); + }; +public: + + Item _item1; + Item _item2; + Item _item3; + Item _item4; + Actor _actor1; + Actor _actor2; + Actor _actor3; + Actor _actor4; + SceneActor _actor5; + SceneActor _actor6; + SceneActor _actor7; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); + virtual void dispatch(); +}; + +class Scene3255 : public SceneExt { +public: + SceneActor _actor1; + SceneActor _actor2; + SceneActor _actor3; + SceneActor _actor4; + SceneActor _actor5; + SceneActor _actor6; + SceneActor _actor7; + SpeakerQuinn3255 _quinnSpeaker; + SpeakerMiranda3255 _mirandaSpeaker; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); + virtual void dispatch(); +}; + +class Scene3260 : public SceneExt { + class Actor13 : public SceneActor { + virtual bool startAction(CursorType action, Event &event); + }; + class Actor14 : public SceneActor { + virtual bool startAction(CursorType action, Event &event); + }; + + class Action1: public Action { + public: + void signal(); + }; +public: + + NamedHotspot _item1; + SceneActor _actor1; + SceneActor _actor2; + SceneActor _actor3; + SceneActor _actor4; + SceneActor _actor5; + SceneActor _actor6; + SceneActor _actor7; + SceneActor _actor8; + SceneActor _actor9; + SceneActor _actor10; + SceneActor _actor11; + SceneActor _actor12; + Actor13 _actor13; + Actor14 _actor14; + Action1 _action1; + Action1 _action2; + Action1 _action3; + Action1 _action4; + Action1 _action5; + Action1 _action6; + Action1 _action7; + Action1 _action8; + Action1 _action9; + Action1 _action10; + Action1 _action11; + Action1 _action12; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); +}; + +class Scene3275 : public SceneExt { + class Actor2 : public SceneActor { + virtual bool startAction(CursorType action, Event &event); + }; + + class Exit1 : public SceneExit { + public: + virtual void changeScene(); + }; +public: + NamedHotspot _item1; + NamedHotspot _item2; + NamedHotspot _item3; + NamedHotspot _item4; + NamedHotspot _item5; + SceneActor _actor1; + Actor2 _actor2; + Exit1 _exit1; + SequenceManager _sequenceManager; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); +}; + +class Scene3350 : public SceneExt { +public: + SceneActor _actor1; + SceneActor _actor2; + SceneActor _actor3; + SceneActor _actor4; + SceneActor _actor5; + SceneActor _actor6; + SceneActor _actor7; + SceneActor _actor8; + SceneActor _actor9; + SequenceManager _sequenceManager; + PaletteRotation *_rotation; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); +}; + +class Scene3400 : public SceneExt { +public: + SpeakerQuinn3400 _quinnSpeaker; + SpeakerSeeker3400 _seekerSpeaker; + SpeakerMiranda3400 _mirandaSpeaker; + SpeakerWebbster3400 _webbsterSpeaker; + SpeakerTeal3400 _tealSpeaker; + SceneActor _actor1; + SceneActor _actor2; + SceneActor _actor3; + SceneActor _actor4; + SceneActor _actor5; + SceneActor _actor6; + SceneActor _actor7; + SceneActor _actor8; + SequenceManager _sequenceManager; + int16 _field157C; + + Scene3400(); + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); + virtual void synchronize(Serializer &s); +}; } // End of namespace Ringworld2 } // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_speakers.cpp b/engines/tsage/ringworld2/ringworld2_speakers.cpp index 80ac04c403..edcf340e04 100644 --- a/engines/tsage/ringworld2/ringworld2_speakers.cpp +++ b/engines/tsage/ringworld2/ringworld2_speakers.cpp @@ -1228,5 +1228,692 @@ void SpeakerPrivate3210::proc15() { } } +SpeakerRocko3220::SpeakerRocko3220() { + _speakerName = "Rocko"; + _color1 = 5; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerRocko3220::proc15() { + int v = _fieldF6; + Scene3220 *scene = (Scene3220 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor1; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4060, (_object2->_strip * 2) - 1, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerJocko3220::SpeakerJocko3220() { + _speakerName = "Jocko"; + _color1 = 45; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerJocko3220::proc15() { + int v = _fieldF6; + Scene3220 *scene = (Scene3220 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor2; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4060, (_object2->_strip * 2) - 1, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerRocko3230::SpeakerRocko3230() { + _speakerName = "Rocko"; + _color1 = 5; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerRocko3230::proc15() { + int v = _fieldF6; + Scene3230 *scene = (Scene3230 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor1; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4111, (_object2->_strip * 2) - 1, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerJocko3230::SpeakerJocko3230() { + _speakerName = "Jocko"; + _color1 = 45; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerJocko3230::proc15() { + int v = _fieldF6; + Scene3230 *scene = (Scene3230 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor2; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4060, (_object2->_strip * 2) - 1, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerTeal3240::SpeakerTeal3240() { + _speakerName = "Teal"; + _color1 = 22; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerTeal3240::proc15() { + int v = _fieldF6; + Scene3240 *scene = (Scene3240 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor1; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4070, (_object2->_strip * 2) - 1, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerWebbster3240::SpeakerWebbster3240() { + _speakerName = "Webbster"; + _color1 = 10; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerWebbster3240::proc15() { + int v = _fieldF6; + Scene3240 *scene = (Scene3240 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor2; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4110, 5, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerRalf3245::SpeakerRalf3245() { + _speakerName = "Ralf"; + _color1 = 5; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerRalf3245::proc15() { + int v = _fieldF6; + Scene3245 *scene = (Scene3245 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor1; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + switch (_object2->_visage) { + case 3100: + _object1.setup(4105, (_object2->_strip * 2) - 1, 1); + break; + case 3101: + _object1.setup(4108, (_object2->_strip * 2) - 1, 1); + break; + case 3102: + _object1.setup(4109, (_object2->_strip * 2) - 1, 1); + break; + default: + break; + } + + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerTomko3245::SpeakerTomko3245() { + _speakerName = "Tomko"; + _color1 = 10; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerTomko3245::proc15() { + int v = _fieldF6; + Scene3245 *scene = (Scene3245 *)R2_GLOBALS._sceneManager._scene; + + if (!_object2) { + _object2 = &scene->_actor2; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + switch (_object2->_visage) { + case 3100: + _object1.setup(4105, (_object2->_strip * 2) - 1, 1); + break; + case 3101: + _object1.setup(4108, (_object2->_strip * 2) - 1, 1); + break; + case 3102: + _object1.setup(4109, (_object2->_strip * 2) - 1, 1); + break; + default: + break; + } + + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerQuinn3255::SpeakerQuinn3255() { + _speakerName = "QUINN"; + _color1 = 60; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerQuinn3255::proc15() { + Scene3255 *scene = (Scene3255 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + _object2 = &scene->_actor4; + _object2->hide(); + _object1.postInit(); + _object1._effect = _object2->_effect; + _object1._shade = _object2->_shade; + _object1.setPosition(_object2->_position); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(3257, 3, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerMiranda3255::SpeakerMiranda3255() { + _speakerName = "MIRANDA"; + _color1 = 154; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerMiranda3255::proc15() { + int v = _fieldF6; + + if (!_object2) { + _object2 = &R2_GLOBALS._player; + _object2->hide(); + _object1.postInit(); + _object1._effect = _object2->_effect; + _object1._shade = _object2->_shade; + _object1.setPosition(_object2->_position); + } + + if (v == 0) { + _object1.animate(ANIM_MODE_2, NULL); + } else { + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(3257, 5, 1); + _object1.animate(ANIM_MODE_5, this); + } +} + +SpeakerQuinn3400::SpeakerQuinn3400() { + _speakerName = "QUINN"; + _color1 = 60; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} +void SpeakerQuinn3400::proc15() { + Scene3400 *scene = (Scene3400 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + if (R2_GLOBALS._player._characterIndex == 1) + _object2 = &R2_GLOBALS._player; + else if (R2_GLOBALS._player._characterIndex == 2) + _object2 = &scene->_actor1; + else + _object2 = &scene->_actor2; + + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + _object1._numFrames = 7; + _object1._effect = 1; + _object1.changeZoom(-1); + R2_GLOBALS._player.disableControl(); + if (_object2->_mover) + _object2->addMover(NULL); + } + + switch (v) { + case 0: + _object1.animate(ANIM_MODE_2, NULL); + break; + case 1: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4010, 5, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 2: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4010, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 3: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4012, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + default: + signal(); + break; + } +} + +SpeakerSeeker3400::SpeakerSeeker3400() { + _speakerName = "SEEKER"; + _color1 = 35; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerSeeker3400::proc15() { + Scene3400 *scene = (Scene3400 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + if (R2_GLOBALS._player._characterIndex == 2) + _object2 = &R2_GLOBALS._player; + else + _object2 = &scene->_actor1; + + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + _object1._numFrames = 7; + _object1._effect = 1; + _object1.changeZoom(-1); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + switch (v) { + case 0: + _object1.animate(ANIM_MODE_2, NULL); + break; + case 1: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4031, 1, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 2: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4031, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 3: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4030, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 4: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4031, 7, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 5: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4033, 1, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + default: + signal(); + break; + } +} + +SpeakerMiranda3400::SpeakerMiranda3400() { + _speakerName = "MIRANDA"; + _color1 = 154; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerMiranda3400::proc15() { + Scene3400 *scene = (Scene3400 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + if (R2_GLOBALS._player._characterIndex == 3) + _object2 = &R2_GLOBALS._player; + else + _object2 = &scene->_actor2; + + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + _object1._numFrames = 7; + _object1._effect = 1; + _object1.changeZoom(-1); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + switch (v) { + case 0: + _object1.animate(ANIM_MODE_2, NULL); + break; + case 1: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4051, 5, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 2: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4050, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + default: + signal(); + break; + } +} + +SpeakerWebbster3400::SpeakerWebbster3400() { + _speakerName = "WEBBSTER"; + _color1 = 27; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerWebbster3400::proc15() { + Scene3400 *scene = (Scene3400 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + _object2 = &scene->_actor3; + _object2->hide(); + _object1.postInit(); + _object1.setPosition(_object2->_position); + _object1._numFrames = 7; + _object1._effect = 1; + _object1.changeZoom(-1); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + + if (_object2->_mover) + _object2->addMover(NULL); + } + + switch (v) { + case 0: + _object1.animate(ANIM_MODE_2, NULL); + break; + case 1: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4110, 5, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 2: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4110, 7, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 3: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4110, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + default: + signal(); + break; + } +} + +SpeakerTeal3400::SpeakerTeal3400() { + _speakerName = "TEAL"; + _color1 = 22; + _color2 = 0; + _fieldF6 = 0; + _textWidth = 300; + _hideObjects = false; + _object2 = NULL; + _displayMode = 1; + _numFrames = 0; +} + +void SpeakerTeal3400::proc15() { + Scene3400 *scene = (Scene3400 *)R2_GLOBALS._sceneManager._scene; + + int v = _fieldF6; + + if (!_object2) { + _object2 = &scene->_actor4; + _object2->hide(); + _object1.postInit(); + _object1._numFrames = 7; + _object1._effect = 1; + _object1.changeZoom(-1); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + + if (_object2->_mover) + _object2->addMover(NULL); + } + _object1.setPosition(_object2->_position); + _object1.show(); + + if (scene ->_sceneMode == 3305) { + R2_GLOBALS._player.setStrip(6); + scene->_actor1.setStrip(6); + scene->_actor2.setStrip(6); + } + + switch (v) { + case 0: + _object1.animate(ANIM_MODE_2, NULL); + break; + case 1: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4107, 5, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 2: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4107, 1, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 3: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4107, 7, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + case 4: + ((SceneItem *)_action)->_sceneRegionId = 0; + _object1.setup(4107, 3, 1); + _object1.animate(ANIM_MODE_5, NULL); + break; + default: + signal(); + break; + } +} + } // End of namespace Ringworld2 } // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_speakers.h b/engines/tsage/ringworld2/ringworld2_speakers.h index 66edd67276..f85b412f9c 100644 --- a/engines/tsage/ringworld2/ringworld2_speakers.h +++ b/engines/tsage/ringworld2/ringworld2_speakers.h @@ -309,6 +309,125 @@ public: virtual void proc15(); }; +class SpeakerRocko3220 : public VisualSpeaker { +public: + SpeakerRocko3220(); + + virtual Common::String getClassName() { return "SpeakerRocko3220"; } + virtual void proc15(); +}; + +class SpeakerJocko3220 : public VisualSpeaker { +public: + SpeakerJocko3220(); + + virtual Common::String getClassName() { return "SpeakerJocko3220"; } + virtual void proc15(); +}; + +class SpeakerRocko3230 : public VisualSpeaker { +public: + SpeakerRocko3230(); + + virtual Common::String getClassName() { return "SpeakerRocko3230"; } + virtual void proc15(); +}; + +class SpeakerJocko3230 : public VisualSpeaker { +public: + SpeakerJocko3230(); + + virtual Common::String getClassName() { return "SpeakerJocko3230"; } + virtual void proc15(); +}; + +class SpeakerTeal3240 : public VisualSpeaker { +public: + SpeakerTeal3240(); + + virtual Common::String getClassName() { return "SpeakerTeal3240"; } + virtual void proc15(); +}; + +class SpeakerWebbster3240 : public VisualSpeaker { +public: + SpeakerWebbster3240(); + + virtual Common::String getClassName() { return "SpeakerWebbster3240"; } + virtual void proc15(); +}; + +class SpeakerRalf3245 : public VisualSpeaker { +public: + SpeakerRalf3245(); + + virtual Common::String getClassName() { return "SpeakerRalf3245"; } + virtual void proc15(); +}; + +class SpeakerTomko3245 : public VisualSpeaker { +public: + SpeakerTomko3245(); + + virtual Common::String getClassName() { return "SpeakerTomko3245"; } + virtual void proc15(); +}; + +class SpeakerQuinn3255 : public VisualSpeaker { +public: + SpeakerQuinn3255(); + + virtual Common::String getClassName() { return "SpeakerQuinn3255"; } + virtual void proc15(); +}; + +class SpeakerMiranda3255 : public VisualSpeaker { +public: + SpeakerMiranda3255(); + + virtual Common::String getClassName() { return "SpeakerMiranda3255"; } + virtual void proc15(); +}; + +class SpeakerQuinn3400 : public VisualSpeaker { +public: + SpeakerQuinn3400(); + + virtual Common::String getClassName() { return "SpeakerQuinn3400"; } + virtual void proc15(); +}; + +class SpeakerSeeker3400 : public VisualSpeaker { +public: + SpeakerSeeker3400(); + + virtual Common::String getClassName() { return "SpeakerSeeker3400"; } + virtual void proc15(); +}; + +class SpeakerMiranda3400 : public VisualSpeaker { +public: + SpeakerMiranda3400(); + + virtual Common::String getClassName() { return "SpeakerMiranda3400"; } + virtual void proc15(); +}; + +class SpeakerWebbster3400 : public VisualSpeaker { +public: + SpeakerWebbster3400(); + + virtual Common::String getClassName() { return "SpeakerWebbster3400"; } + virtual void proc15(); +}; + +class SpeakerTeal3400 : public VisualSpeaker { +public: + SpeakerTeal3400(); + + virtual Common::String getClassName() { return "SpeakerTeal3400"; } + virtual void proc15(); +}; } // End of namespace Ringworld2 } // End of namespace TsAGE diff --git a/engines/tsage/staticres.cpp b/engines/tsage/staticres.cpp index 238e7b3049..3be719887f 100644 --- a/engines/tsage/staticres.cpp +++ b/engines/tsage/staticres.cpp @@ -192,6 +192,26 @@ const char *CONSOLE_MESSAGES[] = { "Mozart", "Bach", "Rossini" }; +// Scene 825 Autodoc messages +const char *MAIN_MENU = "main menu"; +const char *DIAGNOSIS = "diagnosis"; +const char *ADVANCED_PROCEDURES = "advanced procedures"; +const char *VITAL_SIGNS = "vital signs"; +const char *OPEN_DOOR = "open door"; +const char *TREATMENTS = "treatments"; +const char *NO_MALADY_DETECTED = "no malady detected"; +const char *NO_TREATMENT_REQUIRED = "no treatment required"; +const char *ACCESS_CODE_REQUIRED = "access code required"; +const char *INVALID_ACCESS_CODE = "invalid access code"; +const char *FOREIGN_OBJECT_EXTRACTED = "foreign object extracted"; + +const char *AUTODOC_ITEMS[11] = { + MAIN_MENU, DIAGNOSIS, ADVANCED_PROCEDURES, VITAL_SIGNS, OPEN_DOOR, TREATMENTS, + NO_MALADY_DETECTED, NO_TREATMENT_REQUIRED, ACCESS_CODE_REQUIRED, INVALID_ACCESS_CODE, + FOREIGN_OBJECT_EXTRACTED +}; + + const char *HELP_MSG = "\x1\rRETURN TO\r RINGWORLD\x14"; const char *CHAR_TITLE = "\x01Select Character:"; const char *CHAR_QUINN_MSG = " Quinn "; diff --git a/engines/tsage/staticres.h b/engines/tsage/staticres.h index faff3f4103..e2afb65b34 100644 --- a/engines/tsage/staticres.h +++ b/engines/tsage/staticres.h @@ -149,6 +149,20 @@ namespace Ringworld2 { // Scene 125 - Console messages extern const char *CONSOLE_MESSAGES[]; +// Scene 825 - Autodoc Messages +extern const char *MAIN_MENU; +extern const char *DIAGNOSIS; +extern const char *ADVANCED_PROCEDURES; +extern const char *VITAL_SIGNS; +extern const char *OPEN_DOOR; +extern const char *TREATMENTS; +extern const char *NO_MALADY_DETECTED; +extern const char *NO_TREATMENT_REQUIRED; +extern const char *ACCESS_CODE_REQUIRED; +extern const char *INVALID_ACCESS_CODE; +extern const char *FOREIGN_OBJECT_EXTRACTED; +extern const char *AUTODOC_ITEMS[11]; + // Dialog messages extern const char *HELP_MSG; extern const char *CHAR_TITLE; |