From 3bcc4ce1fdd22de41a2e772f8dedcb17c4a48347 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 2 Sep 2011 16:41:54 +0200 Subject: DREAMWEB: 'useroutine' ported to C++ --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreamgen.cpp | 86 ------------------- engines/dreamweb/dreamgen.h | 4 +- engines/dreamweb/module.mk | 1 + engines/dreamweb/stubs.h | 1 + engines/dreamweb/use.cpp | 169 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 173 insertions(+), 89 deletions(-) create mode 100644 engines/dreamweb/use.cpp diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index bf0f1343ae..78c2bb6418 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -191,6 +191,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'showryanpage', 'findallryan', 'fillryan', + 'useroutine', ], skip_output = [ # These functions are processed but not output 'dreamweb', diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 6e56a68369..958476512d 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -8162,91 +8162,6 @@ douse: useroutine(); } -void DreamGenContext::useroutine() { - STACK_CHECK; - _cmp(data.byte(kReallocation), 50); - if (flags.c()) - goto nodream7; - _cmp(data.byte(kPointerpower), 0); - if (!flags.z()) - goto powerok; - return; -powerok: - data.byte(kPointerpower) = 0; -nodream7: - getanyad(); - dx = data; - ds = dx; - si = offset_uselist; -checkuselist: - push(si); - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+12)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+13)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+14)); - if (!flags.z()) - goto failed; - _lodsb(); - _sub(al, 'A'); - _cmp(al, es.byte(bx+15)); - if (!flags.z()) - goto failed; - _lodsw(); - si = pop(); - __dispatch_call(ax); - return; -failed: - si = pop(); - _add(si, 6); - _cmp(ds.byte(si), 140); - if (!flags.z()) - goto checkuselist; - delpointer(); - getobtextstart(); - findnextcolon(); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - findnextcolon(); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - al = es.byte(si); - _cmp(al, 0); - if (flags.z()) - goto cantuse2; - usetext(); - cx = 400; - hangonp(); - putbackobstuff(); - return; -cantuse2: - createpanel(); - showpanel(); - showman(); - showexit(); - obicons(); - di = 33; - bx = 100; - al = 63; - dl = 241; - printmessage(); - worktoscreenm(); - cx = 50; - hangonp(); - putbackobstuff(); - data.byte(kCommandtype) = 255; -} - void DreamGenContext::wheelsound() { STACK_CHECK; al = 17; @@ -17326,7 +17241,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_printcurs: printcurs(); break; case addr_delcurs: delcurs(); break; case addr_useobject: useobject(); break; - case addr_useroutine: useroutine(); break; case addr_wheelsound: wheelsound(); break; case addr_runtap: runtap(); break; case addr_playguitar: playguitar(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 42beacb6f1..34c2ed9c5c 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -368,7 +368,6 @@ public: static const uint16 addr_playguitar = 0xc590; static const uint16 addr_runtap = 0xc58c; static const uint16 addr_wheelsound = 0xc588; - static const uint16 addr_useroutine = 0xc584; static const uint16 addr_useobject = 0xc580; static const uint16 addr_delcurs = 0xc57c; static const uint16 addr_printcurs = 0xc578; @@ -642,7 +641,6 @@ public: static const uint16 offset_openchangesize = 0x0a1c; static const uint16 offset_keys = 0x0b14; static const uint16 offset_mainlist2 = 0x1440; - static const uint16 offset_uselist = 0x0ba8; static const uint16 offset_gameerror2 = 0x0fb2; static const uint16 offset_loadlist = 0x0ef0; static const uint16 offset_gameerror6 = 0x10be; @@ -1817,7 +1815,7 @@ public: //void turnanypathon(); void restorereels(); void setwalk(); - void useroutine(); + //void useroutine(); void zoomicon(); //void findlen(); void findpathofpoint(); diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index bdacbe79f3..8cacbdc91e 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -11,6 +11,7 @@ MODULE_OBJS := \ saveload.o \ sprite.o \ stubs.o \ + use.o \ vgagrafx.o # This module can be built as a plugin diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index a2d25b905c..fc92e5744f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -230,4 +230,5 @@ void findallryan(); void findallryan(uint8 *inv); void fillryan(); + void useroutine(); diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp new file mode 100644 index 0000000000..237c8d4fad --- /dev/null +++ b/engines/dreamweb/use.cpp @@ -0,0 +1,169 @@ +/* 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 { + + +typedef void (DreamGenContext::*UseCallback)(void); + +struct UseListEntry { + uint8 id[5]; // 0-terminal because it is easier syntatically to initialize the array + UseCallback callback; +}; + +void DreamGenContext::useroutine() { + + static const UseListEntry kUseList[] = { + { "NETW", &DreamGenContext::usemon }, + { "ELVA", &DreamGenContext::useelevator1 }, + { "ELVB", &DreamGenContext::useelevator2 }, + { "ELVC", &DreamGenContext::useelevator3 }, + { "ELVE", &DreamGenContext::useelevator4 }, + { "ELVF", &DreamGenContext::useelevator5 }, + { "CGAT", &DreamGenContext::usechurchgate }, + { "REMO", &DreamGenContext::usestereo }, + { "BUTA", &DreamGenContext::usebuttona }, + { "CBOX", &DreamGenContext::usewinch }, + { "LITE", &DreamGenContext::uselighter }, + { "PLAT", &DreamGenContext::useplate }, + { "LIFT", &DreamGenContext::usecontrol }, + { "WIRE", &DreamGenContext::usewire }, + { "HNDL", &DreamGenContext::usehandle }, + { "HACH", &DreamGenContext::usehatch }, + { "DOOR", &DreamGenContext::useelvdoor }, + { "CSHR", &DreamGenContext::usecashcard }, + { "GUNA", &DreamGenContext::usegun }, + { "CRAA", &DreamGenContext::usecardreader1 }, + { "CRBB", &DreamGenContext::usecardreader2 }, + { "CRCC", &DreamGenContext::usecardreader3 }, + { "SEAT", &DreamGenContext::sitdowninbar }, + { "MENU", &DreamGenContext::usemenu }, + { "COOK", &DreamGenContext::usecooker }, + { "ELCA", &DreamGenContext::callhotellift }, + { "EDCA", &DreamGenContext::calledenslift }, + { "DDCA", &DreamGenContext::calledensdlift }, + { "ALTR", &DreamGenContext::usealtar }, + { "LOKA", &DreamGenContext::openhoteldoor }, + { "LOKB", &DreamGenContext::openhoteldoor2 }, + { "ENTA", &DreamGenContext::openlouis }, + { "ENTB", &DreamGenContext::openryan }, + { "ENTE", &DreamGenContext::openpoolboss }, + { "ENTC", &DreamGenContext::openyourneighbour }, + { "ENTD", &DreamGenContext::openeden }, + { "ENTH", &DreamGenContext::opensarters }, + { "WWAT", &DreamGenContext::wearwatch }, + { "POOL", &DreamGenContext::usepoolreader }, + { "WSHD", &DreamGenContext::wearshades }, + { "GRAF", &DreamGenContext::grafittidoor }, + { "TRAP", &DreamGenContext::trapdoor }, + { "CDPE", &DreamGenContext::edenscdplayer }, + { "DLOK", &DreamGenContext::opentvdoor }, + { "HOLE", &DreamGenContext::usehole }, + { "DRYR", &DreamGenContext::usedryer }, + { "HOLY", &DreamGenContext::usechurchhole }, + { "WALL", &DreamGenContext::usewall }, + { "BOOK", &DreamGenContext::usediary }, + { "AXED", &DreamGenContext::useaxe }, + { "SHLD", &DreamGenContext::useshield }, + { "BCNY", &DreamGenContext::userailing }, + { "LIDC", &DreamGenContext::usecoveredbox }, + { "LIDU", &DreamGenContext::useclearbox }, + { "LIDO", &DreamGenContext::useopenbox }, + { "PIPE", &DreamGenContext::usepipe }, + { "BALC", &DreamGenContext::usebalcony }, + { "WIND", &DreamGenContext::usewindow }, + { "PAPR", &DreamGenContext::viewfolder }, + { "UWTA", &DreamGenContext::usetrainer }, + { "UWTB", &DreamGenContext::usetrainer }, + { "STAT", &DreamGenContext::entersymbol }, + { "TLID", &DreamGenContext::opentomb }, + { "SLAB", &DreamGenContext::useslab }, + { "CART", &DreamGenContext::usecart }, + { "FCAR", &DreamGenContext::usefullcart }, + { "SLBA", &DreamGenContext::slabdoora }, + { "SLBB", &DreamGenContext::slabdoorb }, + { "SLBC", &DreamGenContext::slabdoorc }, + { "SLBD", &DreamGenContext::slabdoord }, + { "SLBE", &DreamGenContext::slabdoore }, + { "SLBF", &DreamGenContext::slabdoorf }, + { "PLIN", &DreamGenContext::useplinth }, + { "LADD", &DreamGenContext::useladder }, + { "LADB", &DreamGenContext::useladderb }, + { "GUMA", &DreamGenContext::chewy }, + { "SQEE", &DreamGenContext::wheelsound }, + { "TAPP", &DreamGenContext::runtap }, + { "GUIT", &DreamGenContext::playguitar }, + { "CONT", &DreamGenContext::hotelcontrol }, + { "BELL", &DreamGenContext::hotelbell }, + }; + + if (data.byte(kReallocation) >= 50) { + if (data.byte(kPointerpower) == 0) + return; + data.byte(kPointerpower) = 0; + } + + getanyad(); + const uint8 *id = es.ptr(bx + 12, 4); + + 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])) { + (this->*entry.callback)(); + return; + } + } + + delpointer(); + getobtextstart(); + findnextcolon(); + if (al != 0) { + findnextcolon(); + if (al != 0) { + al = es.byte(si); + if (al != 0) { + usetext(); + cx = 400; + hangonp(); + putbackobstuff(); + return; + } + } + } + + createpanel(); + showpanel(); + showman(); + showexit(); + obicons(); + printmessage(33, 100, 63, 241, true); + worktoscreenm(); + cx = 50; + hangonp(); + putbackobstuff(); + data.byte(kCommandtype) = 255; +} + +} /*namespace dreamgen */ + -- cgit v1.2.3