diff options
Diffstat (limited to 'engines/dreamweb/stubs.cpp')
-rw-r--r-- | engines/dreamweb/stubs.cpp | 433 |
1 files changed, 258 insertions, 175 deletions
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 7f8a511cde..a01949edfb 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -28,8 +28,19 @@ namespace DreamGen { void DreamGenContext::dreamweb() { STACK_CHECK; + + switch(engine->getLanguage()) { + case Common::EN_ANY: + case Common::EN_GRB: + case Common::EN_USA: + // Implicit data.byte(kForeignrelease) = 0 + break; + default: + data.byte(kForeignrelease) = 1; + break; + } + seecommandtail(); - checkbasemem(); soundstartup(); setkeyboardint(); setupemm(); @@ -140,6 +151,9 @@ void DreamGenContext::dreamweb() { screenupdate(); + if (data.byte(kQuitrequested)) + return; // exit game + if (data.byte(kWongame) != 0) { // "endofgame" clearbeforeload(); @@ -190,12 +204,8 @@ void DreamGenContext::dreamweb() { } static Common::String getFilename(Context &context) { - uint16 name_ptr = context.dx; - Common::String name; - uint8 c; - while((c = context.cs.byte(name_ptr++)) != 0) - name += (char)c; - return name; + const char *name = (const char *)context.cs.ptr(context.dx, 0); + return Common::String(name); } void DreamGenContext::seecommandtail() { @@ -502,15 +512,6 @@ void DreamGenContext::removeemm() { } void DreamGenContext::setupemm() { - //good place for early initialization - switch(engine->getLanguage()) { - case Common::EN_ANY: - case Common::EN_GRB: - case Common::EN_USA: - return; - default: - data.byte(kForeignrelease) = 1; - } } void DreamGenContext::pitinterupt() { @@ -669,7 +670,7 @@ void DreamGenContext::eraseoldobs() { return; Sprite *sprites = spritetable(); - for (size_t i=0; i < 16; ++i) { + for (size_t i = 0; i < 16; ++i) { Sprite &sprite = sprites[i]; if (sprite.objData() != 0xffff) { memset(&sprite, 0xff, sizeof(Sprite)); @@ -917,11 +918,7 @@ void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) { void DreamGenContext::plotreel() { Reel *reel = getreelstart(); - while (true) { - if (reel->x < 220) - break; - if (reel->x == 255) - break; + while (reel->x >= 220 && reel->x != 255) { dealwithspecial(reel->x, reel->y); ++data.word(kReelpointer); reel += 8; @@ -1144,29 +1141,24 @@ void DreamGenContext::findormake() { void DreamGenContext::findormake(uint8 index, uint8 value, uint8 type) { Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); - while (true) { - if (change->index == 0xff) { - change->index = index; - change->location = data.byte(kReallocation); - change->value = value; - change->type = type; - return; - } - if ((index == change->index) && (data.byte(kReallocation) == change->location) && (type == change->type)) { + for (; change->index != 0xff; ++change) { + if (index == change->index && data.byte(kReallocation) == change->location && type == change->type) { change->value = value; return; } - ++change; } + + change->index = index; + change->location = data.byte(kReallocation); + change->value = value; + change->type = type; } void DreamGenContext::setallchanges() { Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change)); - while (change->index != 0xff) { + for (; change->index != 0xff; ++change) if (change->location == data.byte(kReallocation)) dochange(change->index, change->value, change->type); - ++change; - } } DynObject *DreamGenContext::getfreead(uint8 index) { @@ -1301,7 +1293,7 @@ void DreamGenContext::getflagunderp(uint8 *flag, uint8 *flagEx) { } void DreamGenContext::walkandexamine() { - if (! finishedwalkingCPP()) + if (!finishedwalkingCPP()) return; data.byte(kCommandtype) = data.byte(kWalkexamtype); data.byte(kCommand) = data.byte(kWalkexamnum); @@ -1434,156 +1426,160 @@ void DreamGenContext::dumppointer() { } void DreamGenContext::checkcoords() { - checkcoords((const RectWithCallback *)cs.ptr(bx, 0)); + + // FIXME: Move all these lists to the callers + + switch ((uint16)bx) { + case offset_talklist: { + RectWithCallback talklist[] = { + { 273,320,157,198,&DreamGenContext::getback1 }, + { 240,290,2,44,&DreamGenContext::moretalk }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(talklist); + break; + } + case offset_quitlist: { + RectWithCallback quitlist[] = { + { 273,320,157,198,&DreamGenContext::getback1 }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(quitlist); + break; + } + case offset_destlist: { + 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,&DreamGenContext::getback1 }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(destlist); + break; + } + case offset_keypadlist: { + RectWithCallback keypadlist[] = { + { kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamGenContext::buttonone }, + { kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamGenContext::buttontwo }, + { kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamGenContext::buttonthree }, + { kKeypadx+9,kKeypadx+30,kKeypady+23,kKeypady+40,&DreamGenContext::buttonfour }, + { kKeypadx+31,kKeypadx+52,kKeypady+23,kKeypady+40,&DreamGenContext::buttonfive }, + { kKeypadx+53,kKeypadx+74,kKeypady+23,kKeypady+40,&DreamGenContext::buttonsix }, + { kKeypadx+9,kKeypadx+30,kKeypady+41,kKeypady+58,&DreamGenContext::buttonseven }, + { kKeypadx+31,kKeypadx+52,kKeypady+41,kKeypady+58,&DreamGenContext::buttoneight }, + { kKeypadx+53,kKeypadx+74,kKeypady+41,kKeypady+58,&DreamGenContext::buttonnine }, + { kKeypadx+9,kKeypadx+30,kKeypady+59,kKeypady+73,&DreamGenContext::buttonnought }, + { kKeypadx+31,kKeypadx+74,kKeypady+59,kKeypady+73,&DreamGenContext::buttonenter }, + { kKeypadx+72,kKeypadx+86,kKeypady+80,kKeypady+94,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(keypadlist); + break; + } + case offset_menulist: { + RectWithCallback menulist[] = { + { kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(menulist); + break; + } + case offset_folderlist: { + RectWithCallback folderlist[] = { + { 280,320,160,200,&DreamGenContext::quitkey }, + { 143,300,6,194,&DreamGenContext::nextfolder }, + { 0,143,6,194,&DreamGenContext::lastfolder }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(folderlist); + break; + } + case offset_symbollist: { + RectWithCallback symbollist[] = { + { kSymbolx+40,kSymbolx+64,kSymboly+2,kSymboly+16,&DreamGenContext::quitsymbol }, + { kSymbolx,kSymbolx+52,kSymboly+20,kSymboly+50,&DreamGenContext::settopleft }, + { kSymbolx+52,kSymbolx+104,kSymboly+20,kSymboly+50,&DreamGenContext::settopright }, + { kSymbolx,kSymbolx+52,kSymboly+50,kSymboly+80,&DreamGenContext::setbotleft }, + { kSymbolx+52,kSymbolx+104,kSymboly+50,kSymboly+80,&DreamGenContext::setbotright }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(symbollist); + + break; + } + case offset_diarylist: { + RectWithCallback diarylist[] = { + { kDiaryx+94,kDiaryx+110,kDiaryy+97,kDiaryy+113,&DreamGenContext::diarykeyn }, + { kDiaryx+151,kDiaryx+167,kDiaryy+71,kDiaryy+87,&DreamGenContext::diarykeyp }, + { kDiaryx+176,kDiaryx+192,kDiaryy+108,kDiaryy+124,&DreamGenContext::quitkey }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(diarylist); + break; + } + case offset_opslist: { + RectWithCallback opslist[] = { + { kOpsx+59,kOpsx+114,kOpsy+30,kOpsy+76,&DreamGenContext::getbackfromops }, + { kOpsx+10,kOpsx+77,kOpsy+10,kOpsy+59,&DreamGenContext::dosreturn }, + { kOpsx+128,kOpsx+190,kOpsy+16,kOpsy+100,&DreamGenContext::discops }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(opslist); + break; + } + case offset_discopslist: { + 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,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(discopslist); + break; + } + case offset_decidelist: { + RectWithCallback decidelist[] = { + { kOpsx+69,kOpsx+124,kOpsy+30,kOpsy+76,&DreamGenContext::newgame }, + { kOpsx+20,kOpsx+87,kOpsy+10,kOpsy+59,&DreamGenContext::dosreturn }, + { kOpsx+123,kOpsx+190,kOpsy+10,kOpsy+59,&DreamGenContext::loadold }, + { 0,320,0,200,&DreamGenContext::blank }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(decidelist); + break; + } + default: + ::error("Unimplemented checkcoords() call"); + } } + void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) { if (data.byte(kNewlocation) != 0xff) return; - const RectWithCallback *rectWithCallback = rectWithCallbacks; - while (rectWithCallback->xMin() != 0xffff) { - if (rectWithCallback->contains(data.word(kMousex), data.word(kMousey))) { - uint16 callback = rectWithCallback->callback(); - - // common - if(callback == addr_blank) - blank(); - else if(callback == addr_getbackfromob) - getbackfromob(); - else if(callback == addr_incryanpage) - incryanpage(); - else if(callback == addr_getback1) - getback1(); - else if(callback == addr_quitkey) - quitkey(); - else if(callback == addr_dosreturn) - dosreturn(); - else if(callback == addr_getbacktoops) - getbacktoops(); - else if(callback == addr_selectslot) - selectslot(); - // examlist - else if(callback == addr_useobject) - useobject(); - else if(callback == addr_selectopenob) - selectopenob(); - else if(callback == addr_setpickup) - setpickup(); - else if(callback == addr_examinventory) - examinventory(); - // invlist1 - else if(callback == addr_dropobject) - dropobject(); - else if(callback == addr_useopened) - useopened(); - else if(callback == addr_intoinv) - intoinv(); - // withlist1 - else if(callback == addr_selectob) - selectob(); - // talklist - else if(callback == addr_moretalk) - moretalk(); - // quitlist - // destlist - else if(callback == addr_nextdest) - nextdest(); - else if(callback == addr_lastdest) - lastdest(); - else if(callback == addr_lookatplace) - lookatplace(); - else if(callback == addr_destselect) - destselect(); - // keypadlist - else if(callback == addr_buttonone) - buttonone(); - else if(callback == addr_buttontwo) - buttontwo(); - else if(callback == addr_buttonthree) - buttonthree(); - else if(callback == addr_buttonfour) - buttonfour(); - else if(callback == addr_buttonfive) - buttonfive(); - else if(callback == addr_buttonsix) - buttonsix(); - else if(callback == addr_buttonseven) - buttonseven(); - else if(callback == addr_buttoneight) - buttoneight(); - else if(callback == addr_buttonnine) - buttonnine(); - else if(callback == addr_buttonnought) - buttonnought(); - else if(callback == addr_buttonenter) - buttonenter(); - // menulist - // folderlist - else if(callback == addr_nextfolder) - nextfolder(); - else if(callback == addr_lastfolder) - lastfolder(); - // symbollist - else if(callback == addr_quitsymbol) - quitsymbol(); - else if(callback == addr_settopleft) - settopleft(); - else if(callback == addr_settopright) - settopright(); - else if(callback == addr_setbotleft) - setbotleft(); - else if(callback == addr_setbotright) - setbotright(); - // diarylist - else if(callback == addr_diarykeyn) - diarykeyn(); - else if(callback == addr_diarykeyp) - diarykeyp(); - // opslist - else if(callback == addr_getbackfromops) - getbackfromops(); - else if(callback == addr_discops) - discops(); - // discopslist - else if(callback == addr_loadgame) - loadgame(); - else if(callback == addr_savegame) - savegame(); - // mainlist, mainlist2 - else if(callback == addr_look) - look(); - else if(callback == addr_inventory) - inventory(); - else if(callback == addr_zoomonoff) - zoomonoff(); - else if(callback == addr_saveload) - saveload(); - else if(callback == addr_madmanrun) - madmanrun(); - else if(callback == addr_identifyob) - identifyob(); - // decidelist - else if(callback == addr_newgame) - newgame(); - else if(callback == addr_loadold) - loadold(); - // loadlist - else if(callback == addr_actualload) - actualload(); - // savelist - else if(callback == addr_actualsave) - actualsave(); - else { - debug("__dispatch_call remaining in checkcoords! %d", (int)callback); - __dispatch_call(callback); - } + const RectWithCallback *r; + for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) { + if (r->contains(data.word(kMousex), data.word(kMousey))) { + (this->*(r->_callback))(); return; } - ++rectWithCallback; } } + void DreamGenContext::showpointer() { showblink(); const Frame *icons1 = ((const Frame *)segRef(data.word(kIcons1)).ptr(0, 0)); @@ -1721,6 +1717,25 @@ bool DreamGenContext::isCD() { return (data.byte(kSpeechloaded) == 1); } +void DreamGenContext::showicon() { + if (data.byte(kReallocation) < 50) { + showpanel(); + showman(); + roomname(); + panelicons1(); + zoomicon(); + } else { + Frame *tempSprites = (Frame *)segRef(data.word(kTempsprites)).ptr(0, 0); + showframe(tempSprites, 72, 2, 45, 0); + showframe(tempSprites, 72+47, 2, 46, 0); + showframe(tempSprites, 69-10, 21, 49, 0); + showframe(tempSprites, 160+88, 2, 45, 4 & 0xfe); + showframe(tempSprites, 160+43, 2, 46, 4 & 0xfe); + showframe(tempSprites, 160+101, 21, 49, 4 & 0xfe); + middlepanel(); + } +} + void DreamGenContext::checkifset() { flags._z = !checkifset(al, ah); } @@ -1882,5 +1897,73 @@ void DreamGenContext::zoomonoff() { worktoscreenm(); } +void DreamGenContext::sortoutmap() { + const uint8 *src = (const uint8 *)segRef(data.word(kWorkspace)).ptr(0, 0); + uint8 *dst = (uint8 *)segRef(data.word(kMapdata)).ptr(0, 0); + for (uint16 y = 0; y < kMaplength; ++y) { + memcpy(dst, src, kMapwidth); + dst += kMapwidth; + src += 132; + } +} + +void DreamGenContext::showcity() { + clearwork(); + Frame *tempGraphics = (Frame *)segRef(data.word(kTempgraphics)).ptr(0, 0); + 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[] = { + { 44,70,32,46,&DreamGenContext::look }, + { 0,50,0,180,&DreamGenContext::inventory }, + { 226,244,10,26,&DreamGenContext::zoomonoff }, + { 226,244,26,40,&DreamGenContext::saveload }, + { 240,260,100,124,&DreamGenContext::madmanrun }, + { 0,320,0,200,&DreamGenContext::identifyob }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(mainlist); + } else { + RectWithCallback mainlist2[] = { + { 44,70,32,46,&DreamGenContext::look }, + { 0,50,0,180,&DreamGenContext::inventory }, + { 226+48,244+48,10,26,&DreamGenContext::zoomonoff }, + { 226+48,244+48,26,40,&DreamGenContext::saveload }, + { 240,260,100,124,&DreamGenContext::madmanrun }, + { 0,320,0,200,&DreamGenContext::identifyob }, + { 0xFFFF,0,0,0,0 } + }; + checkcoords(mainlist2); + } + + if (data.byte(kWalkandexam) != 0) + walkandexamine(); +} + +void DreamGenContext::showwatch() { + if (data.byte(kWatchon)) { + showframe((Frame *)segRef(data.word(kIcons1)).ptr(0, 0), 250, 1, 6, 0); + showtime(); + } +} + +void DreamGenContext::roomname() { + printmessage(88, 18, 53, 240, false); + uint16 textIndex = data.byte(kRoomnum); + if (textIndex >= 32) + textIndex -= 32; + data.word(kLinespacing) = 7; + uint8 maxWidth = (data.byte(kWatchon) == 1) ? 120 : 160; + uint16 descOffset = segRef(data.word(kRoomdesc)).word(kIntextdat + textIndex * 2); + const uint8 *string = segRef(data.word(kRoomdesc)).ptr(kIntext + descOffset, 0); + printdirect(string, 88, 25, maxWidth, false); + data.word(kLinespacing) = 10; + usecharset1(); +} + } /*namespace dreamgen */ |