From c86a830c4a299b45549ee3a6f242995790013853 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 26 Dec 2011 16:57:27 +0100 Subject: [PATCH] DREAMWEB: Move openInvList, ryanInvList out of buffers --- devtools/tasmrecover/tasm-recover | 1 + engines/dreamweb/dreambase.h | 10 +- engines/dreamweb/dreamgen.cpp | 46 ++-- engines/dreamweb/dreamgen.h | 439 +++++++++++++++--------------- engines/dreamweb/object.cpp | 221 ++++++++------- engines/dreamweb/structs.h | 12 + engines/dreamweb/stubs.h | 2 - 7 files changed, 367 insertions(+), 364 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 0020950a60b..37963a39679 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -210,6 +210,7 @@ p = parser(skip_binary_data = [ 'timer1to', 'timer2to', 'timer3to', + 'oldsubject', # vgagrafx.asm 'cityname', 'extragraphics1', diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index 3f667e8757d..4b9919de7a2 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -69,6 +69,7 @@ protected: // from object.cpp uint16 _openChangeSize; + ObjectRef _oldSubject; // from pathfind.cpp Common::Point _lineData[200]; // Output of Bresenham @@ -86,8 +87,8 @@ protected: // from Buffers uint8 _textUnder[kUnderTextBufSize]; - // _openInvList (see fillOpen/findOpenPos) - // _ryanInvList (see findInvPos/findInvPosCPP) + ObjectRef _openInvList[16]; + ObjectRef _ryanInvList[30]; uint8 _pointerBack[32*32]; uint8 _mapFlags[11*10*3]; uint8 _startPal[3*256]; @@ -199,7 +200,7 @@ public: // from object.cpp void obIcons(); void fillRyan(); - void findAllRyan(uint8 *inv); + void findAllRyan(); void obToInv(uint8 index, uint8 flag, uint16 x, uint16 y); void obPicture(); void removeObFromInv(); @@ -211,12 +212,13 @@ public: void wornError(); void makeWorn(DynObject *object); void dropObject(); - uint16 findOpenPos(); + ObjectRef findOpenPos(); byte getOpenedSlotSize(); byte getOpenedSlotCount(); void openOb(); void findAllOpen(); void fillOpen(); + ObjectRef findInvPos(); // from pathfind.cpp void turnPathOn(uint8 param); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 0004c4fa3b8..eeb2d346d99 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -154,7 +154,7 @@ void DreamGenContext::read() { return; okcom: es = cs; - di = 422; + di = 420; ax = data.word(kTextfile1); data.word(kMonsource) = ax; ds = ax; @@ -284,7 +284,7 @@ keyok2: ds = cs; si = offset_operand1+1; es = cs; - di = 422+1; + di = 420+1; cx = 12; _movsb(cx, true); monitorLogo(); @@ -366,7 +366,7 @@ void DreamGenContext::parser() { al = '='; _stosb(); ds = cs; - si = 497; + si = 495; notspace1: _lodsw(); _cmp(al, 32); @@ -410,18 +410,18 @@ void DreamGenContext::__start() { //0x0050: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0060: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x0070: .... ...h .&.. .... + 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x0070: .... .h.& .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0080: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0090: .... .... .... .... - 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00a0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00b0: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x00c0: .... .. .... .... + 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x00c0: .... .. .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00d0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -436,26 +436,26 @@ void DreamGenContext::__start() { //0x0120: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0130: .... .... .... .... - 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0140: .... .... .... .... 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0150: .... .... .... .... - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, //0x0160: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0170: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, - //0x0180: .... .... ...D REAM - 0x57, 0x45, 0x42, 0x2e, 0x56, 0x39, 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - //0x0190: WEB. V99. - 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - //0x01a0: ." - 0x20, 0x20, 0x20, 0x00, 0x0d, 0x0a, 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, - //0x01b0: . .... $... .... - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - //0x01c0: .... .... .... .... - 0x02, 0x44, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - //0x01d0: .D:. .... .... .... + 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, 0x57, 0x45, + //0x0180: .... .... .DRE AMWE + 0x42, 0x2e, 0x56, 0x39, 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + //0x0190: B.V9 9. + 0x20, 0x20, 0x20, 0x00, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + //0x01a0: . " + 0x20, 0x00, 0x0d, 0x0a, 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, + //0x01b0: ... ..$. .... .... + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, + //0x01c0: .... .... .... ...D + 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + //0x01d0: :... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x01e0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -474,7 +474,7 @@ void DreamGenContext::__start() { //0x0250: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0260: .... .... .... .... - 0x00, 0x00, 0x00, 0x00, }; + 0x00, 0x00, }; ds.assign(src, src + sizeof(src)); dreamweb(); } diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 82550fe4ce1..155c24d7219 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -32,7 +32,7 @@ namespace DreamGen { -static const uint16 offset_operand1 = 0x0198; +static const uint16 offset_operand1 = 0x0196; static const uint16 kStartvars = 0; static const uint16 kProgresspoints = 1; static const uint16 kWatchon = 2; @@ -106,225 +106,224 @@ static const uint16 kIconleft = 86; static const uint16 kItemframe = 88; static const uint16 kItemtotran = 89; static const uint16 kRoomad = 90; -static const uint16 kOldsubject = 92; -static const uint16 kWithobject = 94; -static const uint16 kWithtype = 95; -static const uint16 kLookcounter = 96; -static const uint16 kCommand = 98; -static const uint16 kCommandtype = 99; -static const uint16 kOldcommandtype = 100; -static const uint16 kObjecttype = 101; -static const uint16 kGetback = 102; -static const uint16 kInvopen = 103; -static const uint16 kMainmode = 104; -static const uint16 kPickup = 105; -static const uint16 kLastinvpos = 106; -static const uint16 kExamagain = 107; -static const uint16 kNewtextline = 108; -static const uint16 kOpenedob = 109; -static const uint16 kOpenedtype = 110; -static const uint16 kOldmapadx = 111; -static const uint16 kOldmapady = 113; -static const uint16 kMapadx = 115; -static const uint16 kMapady = 117; -static const uint16 kMapoffsetx = 119; -static const uint16 kMapoffsety = 121; -static const uint16 kMapxstart = 123; -static const uint16 kMapystart = 125; -static const uint16 kMapxsize = 127; -static const uint16 kMapysize = 128; -static const uint16 kHavedoneobs = 129; -static const uint16 kManisoffscreen = 130; -static const uint16 kRainspace = 131; -static const uint16 kFacing = 132; -static const uint16 kLeavedirection = 133; -static const uint16 kTurntoface = 134; -static const uint16 kTurndirection = 135; -static const uint16 kMaintimer = 136; -static const uint16 kIntrocount = 138; -static const uint16 kArrowad = 139; -static const uint16 kCurrentkey = 141; -static const uint16 kOldkey = 142; -static const uint16 kUseddirection = 143; -static const uint16 kTimercount = 144; -static const uint16 kOldtimercount = 145; -static const uint16 kMapx = 146; -static const uint16 kMapy = 147; -static const uint16 kNewscreen = 148; -static const uint16 kRyanx = 149; -static const uint16 kRyany = 150; -static const uint16 kLastflag = 151; -static const uint16 kOffsetx = 152; -static const uint16 kOffsety = 154; -static const uint16 kCurrentob = 156; -static const uint16 kDestpos = 157; -static const uint16 kReallocation = 158; -static const uint16 kRoomnum = 159; -static const uint16 kNowinnewroom = 160; -static const uint16 kResetmanxy = 161; -static const uint16 kNewlocation = 162; -static const uint16 kAutolocation = 163; -static const uint16 kDoorcheck1 = 164; -static const uint16 kDoorcheck2 = 165; -static const uint16 kDoorcheck3 = 166; -static const uint16 kDoorcheck4 = 167; -static const uint16 kMousex = 168; -static const uint16 kMousey = 170; -static const uint16 kMousebutton = 172; -static const uint16 kMousebutton1 = 174; -static const uint16 kMousebutton2 = 176; -static const uint16 kMousebutton3 = 178; -static const uint16 kMousebutton4 = 180; -static const uint16 kOldbutton = 182; -static const uint16 kOldx = 184; -static const uint16 kOldy = 186; -static const uint16 kLastbutton = 188; -static const uint16 kOldpointerx = 190; -static const uint16 kOldpointery = 192; -static const uint16 kDelherex = 194; -static const uint16 kDelherey = 196; -static const uint16 kPointerxs = 198; -static const uint16 kPointerys = 199; -static const uint16 kDelxs = 200; -static const uint16 kDelys = 201; -static const uint16 kPointerframe = 202; -static const uint16 kPointerpower = 203; -static const uint16 kAuxpointerframe = 204; -static const uint16 kPointermode = 205; -static const uint16 kPointerspeed = 206; -static const uint16 kPointercount = 207; -static const uint16 kInmaparea = 208; -static const uint16 kTalkmode = 209; -static const uint16 kTalkpos = 210; -static const uint16 kCharacter = 211; -static const uint16 kWatchdump = 212; -static const uint16 kLogonum = 213; -static const uint16 kOldlogonum = 214; -static const uint16 kNetseg = 215; -static const uint16 kNetpoint = 217; -static const uint16 kCursorstate = 219; -static const uint16 kPressed = 220; -static const uint16 kPresspointer = 221; -static const uint16 kGraphicpress = 223; -static const uint16 kPresscount = 224; -static const uint16 kLightcount = 225; -static const uint16 kFolderpage = 226; -static const uint16 kDiarypage = 227; -static const uint16 kMenucount = 228; -static const uint16 kSymboltopx = 229; -static const uint16 kSymboltopnum = 230; -static const uint16 kSymboltopdir = 231; -static const uint16 kSymbolbotx = 232; -static const uint16 kSymbolbotnum = 233; -static const uint16 kSymbolbotdir = 234; -static const uint16 kSymboltolight = 235; -static const uint16 kSymbol1 = 236; -static const uint16 kSymbol2 = 237; -static const uint16 kSymbol3 = 238; -static const uint16 kSymbolnum = 239; -static const uint16 kDumpx = 240; -static const uint16 kDumpy = 242; -static const uint16 kWalkandexam = 244; -static const uint16 kWalkexamtype = 245; -static const uint16 kWalkexamnum = 246; -static const uint16 kCurslocx = 247; -static const uint16 kCurslocy = 249; -static const uint16 kCurpos = 251; -static const uint16 kMonadx = 253; -static const uint16 kMonady = 255; -static const uint16 kMonsource = 257; -static const uint16 kNumtodo = 259; -static const uint16 kTimecount = 261; -static const uint16 kCounttotimed = 263; -static const uint16 kTimedseg = 265; -static const uint16 kTimedoffset = 267; -static const uint16 kTimedy = 269; -static const uint16 kTimedx = 270; -static const uint16 kNeedtodumptimed = 271; -static const uint16 kLoadingorsave = 272; -static const uint16 kCurrentslot = 273; -static const uint16 kCursorpos = 274; -static const uint16 kColourpos = 275; -static const uint16 kFadedirection = 276; -static const uint16 kNumtofade = 277; -static const uint16 kFadecount = 278; -static const uint16 kAddtogreen = 279; -static const uint16 kAddtored = 280; -static const uint16 kAddtoblue = 281; -static const uint16 kLastsoundreel = 282; -static const uint16 kSpeechloaded = 284; -static const uint16 kSpeechlength = 285; -static const uint16 kVolume = 287; -static const uint16 kVolumeto = 288; -static const uint16 kVolumedirection = 289; -static const uint16 kVolumecount = 290; -static const uint16 kWongame = 291; -static const uint16 kLasthardkey = 292; -static const uint16 kBufferin = 293; -static const uint16 kBufferout = 295; -static const uint16 kExtras = 297; -static const uint16 kWorkspace = 299; -static const uint16 kMapstore = 301; -static const uint16 kCharset1 = 303; -static const uint16 kBuffers = 305; -static const uint16 kMainsprites = 307; -static const uint16 kBackdrop = 309; -static const uint16 kMapdata = 311; -static const uint16 kSounddata = 313; -static const uint16 kSounddata2 = 315; -static const uint16 kRecordspace = 317; -static const uint16 kFreedat = 319; -static const uint16 kSetdat = 321; -static const uint16 kReel1 = 323; -static const uint16 kReel2 = 325; -static const uint16 kReel3 = 327; -static const uint16 kRoomdesc = 329; -static const uint16 kFreedesc = 331; -static const uint16 kSetdesc = 333; -static const uint16 kBlockdesc = 335; -static const uint16 kSetframes = 337; -static const uint16 kFreeframes = 339; -static const uint16 kPeople = 341; -static const uint16 kReels = 343; -static const uint16 kCommandtext = 345; -static const uint16 kPuzzletext = 347; -static const uint16 kTraveltext = 349; -static const uint16 kTempgraphics = 351; -static const uint16 kTempgraphics2 = 353; -static const uint16 kTempgraphics3 = 355; -static const uint16 kTempsprites = 357; -static const uint16 kTextfile1 = 359; -static const uint16 kTextfile2 = 361; -static const uint16 kTextfile3 = 363; -static const uint16 kBlinkframe = 365; -static const uint16 kBlinkcount = 366; -static const uint16 kReasseschanges = 367; -static const uint16 kPointerspath = 368; -static const uint16 kManspath = 369; -static const uint16 kPointerfirstpath = 370; -static const uint16 kFinaldest = 371; -static const uint16 kDestination = 372; -static const uint16 kLinestartx = 373; -static const uint16 kLinestarty = 375; -static const uint16 kLineendx = 377; -static const uint16 kLineendy = 379; -static const uint16 kLinepointer = 381; -static const uint16 kLinedirection = 382; -static const uint16 kLinelength = 383; -static const uint16 kCh0blockstocopy = 384; -static const uint16 kCh0playing = 386; -static const uint16 kCh0repeat = 387; -static const uint16 kCh1playing = 388; -static const uint16 kCh1blockstocopy = 389; -static const uint16 kSoundbufferwrite = 391; -static const uint16 kCurrentsample = 393; -static const uint16 kRoomssample = 394; -static const uint16 kBasicsample = 395; -static const uint16 kCurrentfile = 422; -static const uint16 kInputline = 497; -static const uint16 kQuitrequested = 625; -static const uint16 kSubtitles = 626; -static const uint16 kForeignrelease = 627; +static const uint16 kWithobject = 92; +static const uint16 kWithtype = 93; +static const uint16 kLookcounter = 94; +static const uint16 kCommand = 96; +static const uint16 kCommandtype = 97; +static const uint16 kOldcommandtype = 98; +static const uint16 kObjecttype = 99; +static const uint16 kGetback = 100; +static const uint16 kInvopen = 101; +static const uint16 kMainmode = 102; +static const uint16 kPickup = 103; +static const uint16 kLastinvpos = 104; +static const uint16 kExamagain = 105; +static const uint16 kNewtextline = 106; +static const uint16 kOpenedob = 107; +static const uint16 kOpenedtype = 108; +static const uint16 kOldmapadx = 109; +static const uint16 kOldmapady = 111; +static const uint16 kMapadx = 113; +static const uint16 kMapady = 115; +static const uint16 kMapoffsetx = 117; +static const uint16 kMapoffsety = 119; +static const uint16 kMapxstart = 121; +static const uint16 kMapystart = 123; +static const uint16 kMapxsize = 125; +static const uint16 kMapysize = 126; +static const uint16 kHavedoneobs = 127; +static const uint16 kManisoffscreen = 128; +static const uint16 kRainspace = 129; +static const uint16 kFacing = 130; +static const uint16 kLeavedirection = 131; +static const uint16 kTurntoface = 132; +static const uint16 kTurndirection = 133; +static const uint16 kMaintimer = 134; +static const uint16 kIntrocount = 136; +static const uint16 kArrowad = 137; +static const uint16 kCurrentkey = 139; +static const uint16 kOldkey = 140; +static const uint16 kUseddirection = 141; +static const uint16 kTimercount = 142; +static const uint16 kOldtimercount = 143; +static const uint16 kMapx = 144; +static const uint16 kMapy = 145; +static const uint16 kNewscreen = 146; +static const uint16 kRyanx = 147; +static const uint16 kRyany = 148; +static const uint16 kLastflag = 149; +static const uint16 kOffsetx = 150; +static const uint16 kOffsety = 152; +static const uint16 kCurrentob = 154; +static const uint16 kDestpos = 155; +static const uint16 kReallocation = 156; +static const uint16 kRoomnum = 157; +static const uint16 kNowinnewroom = 158; +static const uint16 kResetmanxy = 159; +static const uint16 kNewlocation = 160; +static const uint16 kAutolocation = 161; +static const uint16 kDoorcheck1 = 162; +static const uint16 kDoorcheck2 = 163; +static const uint16 kDoorcheck3 = 164; +static const uint16 kDoorcheck4 = 165; +static const uint16 kMousex = 166; +static const uint16 kMousey = 168; +static const uint16 kMousebutton = 170; +static const uint16 kMousebutton1 = 172; +static const uint16 kMousebutton2 = 174; +static const uint16 kMousebutton3 = 176; +static const uint16 kMousebutton4 = 178; +static const uint16 kOldbutton = 180; +static const uint16 kOldx = 182; +static const uint16 kOldy = 184; +static const uint16 kLastbutton = 186; +static const uint16 kOldpointerx = 188; +static const uint16 kOldpointery = 190; +static const uint16 kDelherex = 192; +static const uint16 kDelherey = 194; +static const uint16 kPointerxs = 196; +static const uint16 kPointerys = 197; +static const uint16 kDelxs = 198; +static const uint16 kDelys = 199; +static const uint16 kPointerframe = 200; +static const uint16 kPointerpower = 201; +static const uint16 kAuxpointerframe = 202; +static const uint16 kPointermode = 203; +static const uint16 kPointerspeed = 204; +static const uint16 kPointercount = 205; +static const uint16 kInmaparea = 206; +static const uint16 kTalkmode = 207; +static const uint16 kTalkpos = 208; +static const uint16 kCharacter = 209; +static const uint16 kWatchdump = 210; +static const uint16 kLogonum = 211; +static const uint16 kOldlogonum = 212; +static const uint16 kNetseg = 213; +static const uint16 kNetpoint = 215; +static const uint16 kCursorstate = 217; +static const uint16 kPressed = 218; +static const uint16 kPresspointer = 219; +static const uint16 kGraphicpress = 221; +static const uint16 kPresscount = 222; +static const uint16 kLightcount = 223; +static const uint16 kFolderpage = 224; +static const uint16 kDiarypage = 225; +static const uint16 kMenucount = 226; +static const uint16 kSymboltopx = 227; +static const uint16 kSymboltopnum = 228; +static const uint16 kSymboltopdir = 229; +static const uint16 kSymbolbotx = 230; +static const uint16 kSymbolbotnum = 231; +static const uint16 kSymbolbotdir = 232; +static const uint16 kSymboltolight = 233; +static const uint16 kSymbol1 = 234; +static const uint16 kSymbol2 = 235; +static const uint16 kSymbol3 = 236; +static const uint16 kSymbolnum = 237; +static const uint16 kDumpx = 238; +static const uint16 kDumpy = 240; +static const uint16 kWalkandexam = 242; +static const uint16 kWalkexamtype = 243; +static const uint16 kWalkexamnum = 244; +static const uint16 kCurslocx = 245; +static const uint16 kCurslocy = 247; +static const uint16 kCurpos = 249; +static const uint16 kMonadx = 251; +static const uint16 kMonady = 253; +static const uint16 kMonsource = 255; +static const uint16 kNumtodo = 257; +static const uint16 kTimecount = 259; +static const uint16 kCounttotimed = 261; +static const uint16 kTimedseg = 263; +static const uint16 kTimedoffset = 265; +static const uint16 kTimedy = 267; +static const uint16 kTimedx = 268; +static const uint16 kNeedtodumptimed = 269; +static const uint16 kLoadingorsave = 270; +static const uint16 kCurrentslot = 271; +static const uint16 kCursorpos = 272; +static const uint16 kColourpos = 273; +static const uint16 kFadedirection = 274; +static const uint16 kNumtofade = 275; +static const uint16 kFadecount = 276; +static const uint16 kAddtogreen = 277; +static const uint16 kAddtored = 278; +static const uint16 kAddtoblue = 279; +static const uint16 kLastsoundreel = 280; +static const uint16 kSpeechloaded = 282; +static const uint16 kSpeechlength = 283; +static const uint16 kVolume = 285; +static const uint16 kVolumeto = 286; +static const uint16 kVolumedirection = 287; +static const uint16 kVolumecount = 288; +static const uint16 kWongame = 289; +static const uint16 kLasthardkey = 290; +static const uint16 kBufferin = 291; +static const uint16 kBufferout = 293; +static const uint16 kExtras = 295; +static const uint16 kWorkspace = 297; +static const uint16 kMapstore = 299; +static const uint16 kCharset1 = 301; +static const uint16 kBuffers = 303; +static const uint16 kMainsprites = 305; +static const uint16 kBackdrop = 307; +static const uint16 kMapdata = 309; +static const uint16 kSounddata = 311; +static const uint16 kSounddata2 = 313; +static const uint16 kRecordspace = 315; +static const uint16 kFreedat = 317; +static const uint16 kSetdat = 319; +static const uint16 kReel1 = 321; +static const uint16 kReel2 = 323; +static const uint16 kReel3 = 325; +static const uint16 kRoomdesc = 327; +static const uint16 kFreedesc = 329; +static const uint16 kSetdesc = 331; +static const uint16 kBlockdesc = 333; +static const uint16 kSetframes = 335; +static const uint16 kFreeframes = 337; +static const uint16 kPeople = 339; +static const uint16 kReels = 341; +static const uint16 kCommandtext = 343; +static const uint16 kPuzzletext = 345; +static const uint16 kTraveltext = 347; +static const uint16 kTempgraphics = 349; +static const uint16 kTempgraphics2 = 351; +static const uint16 kTempgraphics3 = 353; +static const uint16 kTempsprites = 355; +static const uint16 kTextfile1 = 357; +static const uint16 kTextfile2 = 359; +static const uint16 kTextfile3 = 361; +static const uint16 kBlinkframe = 363; +static const uint16 kBlinkcount = 364; +static const uint16 kReasseschanges = 365; +static const uint16 kPointerspath = 366; +static const uint16 kManspath = 367; +static const uint16 kPointerfirstpath = 368; +static const uint16 kFinaldest = 369; +static const uint16 kDestination = 370; +static const uint16 kLinestartx = 371; +static const uint16 kLinestarty = 373; +static const uint16 kLineendx = 375; +static const uint16 kLineendy = 377; +static const uint16 kLinepointer = 379; +static const uint16 kLinedirection = 380; +static const uint16 kLinelength = 381; +static const uint16 kCh0blockstocopy = 382; +static const uint16 kCh0playing = 384; +static const uint16 kCh0repeat = 385; +static const uint16 kCh1playing = 386; +static const uint16 kCh1blockstocopy = 387; +static const uint16 kSoundbufferwrite = 389; +static const uint16 kCurrentsample = 391; +static const uint16 kRoomssample = 392; +static const uint16 kBasicsample = 393; +static const uint16 kCurrentfile = 420; +static const uint16 kInputline = 495; +static const uint16 kQuitrequested = 623; +static const uint16 kSubtitles = 624; +static const uint16 kForeignrelease = 625; static const uint16 kBlocktextdat = (0); static const uint16 kPersonframes = (0); static const uint16 kDebuglevel1 = (0); diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp index b246323e9d4..2ca73054937 100644 --- a/engines/dreamweb/object.cpp +++ b/engines/dreamweb/object.cpp @@ -29,30 +29,28 @@ void DreamBase::showRyanPage() { showFrame(engine->icons1(), kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0); } -void DreamBase::findAllRyan(uint8 *inv) { - memset(inv, 0xff, 60); +void DreamBase::findAllRyan() { + memset(_ryanInvList, 0xff, 60); for (size_t i = 0; i < kNumexobjects; ++i) { - DynObject *extra = getExAd(i); - if (extra->mapad[0] != 4) + const DynObject *extra = getExAd(i); + if (extra->mapad[0] != kExObjectType) continue; if (extra->mapad[1] != 0xff) continue; uint8 slot = extra->mapad[2]; assert(slot < 30); - inv[2 * slot + 0] = i; - inv[2 * slot + 1] = 4; + _ryanInvList[slot]._index = i; + _ryanInvList[slot]._type = kExObjectType; } } void DreamBase::fillRyan() { - uint8 *inv = getSegment(data.word(kBuffers)).ptr(kRyaninvlist, 60); - findAllRyan(inv); - inv += data.byte(kRyanpage) * 2 * 10; + ObjectRef *inv = &_ryanInvList[data.byte(kRyanpage) * 10]; + findAllRyan(); for (size_t i = 0; i < 2; ++i) { for (size_t j = 0; j < 5; ++j) { - uint8 objIndex = *inv++; - uint8 objType = *inv++; - obToInv(objIndex, objType, kInventx + j * kItempicsize, kInventy + i * kItempicsize); + obToInv(inv->_index, inv->_type, kInventx + j * kItempicsize, kInventy + i * kItempicsize); + ++inv; } } showRyanPage(); @@ -350,35 +348,30 @@ void DreamGenContext::identifyOb() { blank(); } -uint16 DreamGenContext::findInvPosCPP() { +ObjectRef DreamBase::findInvPos() { uint16 x = data.word(kMousex) - kInventx; uint16 y = data.word(kMousey) - kInventy; - uint16 pos = (x / kItempicsize) + (y / kItempicsize) * 5; - uint16 invPos = data.byte(kRyanpage) * 10 + pos; - data.byte(kLastinvpos) = invPos & 0xFF; - return invPos * 2 + kRyaninvlist; -} - -void DreamGenContext::findInvPos() { - bx = findInvPosCPP(); - es = data.word(kBuffers); + uint8 pos = (x / kItempicsize) + (y / kItempicsize) * 5; + uint8 invPos = data.byte(kRyanpage) * 10 + pos; + data.byte(kLastinvpos) = invPos; + return _ryanInvList[invPos]; } void DreamGenContext::selectOb() { - uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); - if ((objectId & 0xFF) == 255) { + ObjectRef objectId = findInvPos(); + if (objectId._index == 255) { blank(); return; } - data.byte(kWithobject) = objectId & 0x00FF; - data.byte(kWithtype) = objectId >> 8; + data.byte(kWithobject) = objectId._index; + data.byte(kWithtype) = objectId._type; - if (objectId != data.word(kOldsubject) || data.byte(kCommandtype) != 221) { - if (objectId == data.word(kOldsubject)) + if (objectId != _oldSubject || data.byte(kCommandtype) != 221) { + if (objectId == _oldSubject) data.byte(kCommandtype) = 221; - data.word(kOldsubject) = objectId; - commandWithOb(0, data.byte(kWithtype), data.byte(kWithobject)); + _oldSubject = objectId; + commandWithOb(0, objectId._type, objectId._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -514,20 +507,21 @@ void DreamGenContext::inToInv() { return; } - uint16 subject = getSegment(data.word(kBuffers)).word(findInvPosCPP()); + ObjectRef subject = findInvPos(); - if ((subject & 0xFF) != 255) { + if (subject._index != 255) { swapWithInv(); return; } - subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); + subject._type = data.byte(kObjecttype); + subject._index = data.byte(kItemframe); - if (subject != data.word(kOldsubject) || data.byte(kCommandtype) != 220) { - if (subject == data.word(kOldsubject)) + if (subject != _oldSubject || data.byte(kCommandtype) != 220) { + if (subject == _oldSubject) data.byte(kCommandtype) = 220; - data.word(kOldsubject) = subject; - commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = subject; + commandWithOb(35, subject._type, subject._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -548,9 +542,9 @@ void DreamGenContext::inToInv() { } void DreamGenContext::outOfInv() { - uint16 subject = getSegment(data.word(kBuffers)).word(findInvPosCPP()); + ObjectRef subject = findInvPos(); - if ((subject & 0xFF) == 255) { + if (subject._index == 255) { blank(); return; } @@ -560,13 +554,11 @@ void DreamGenContext::outOfInv() { return; } - if (subject != data.word(kOldsubject) || data.byte(kCommandtype) != 221) { - if (subject == data.word(kOldsubject)) + if (subject != _oldSubject || data.byte(kCommandtype) != 221) { + if (subject == _oldSubject) data.byte(kCommandtype) = 221; - data.word(kOldsubject) = subject; - byte type = subject >> 8; - byte frame = subject & 0xFF; - commandWithOb(36, type, frame); + _oldSubject = subject; + commandWithOb(36, subject._type, subject._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -574,10 +566,11 @@ void DreamGenContext::outOfInv() { delPointer(); data.byte(kPickup) = 1; - subject = getSegment(data.word(kBuffers)).word(findInvPosCPP()); - data.byte(kObjecttype) = subject >> 8; - data.byte(kItemframe) = subject & 0xFF; - DynObject *object = getExAd(data.byte(kItemframe)); + subject = findInvPos(); + data.byte(kObjecttype) = subject._type; + data.byte(kItemframe) = subject._index; + assert(subject._type == kExObjectType); + DynObject *object = getExAd(subject._index); object->mapad[0] = 20; object->mapad[1] = 255; fillRyan(); @@ -782,24 +775,26 @@ void DreamGenContext::selectOpenOb() { } void DreamGenContext::reExFromInv() { - uint16 objectId = getSegment(data.word(kBuffers)).word(findInvPosCPP()); - data.byte(kCommandtype) = objectId >> 8; - data.byte(kCommand) = objectId & 0x00FF; + ObjectRef objectId = findInvPos(); + data.byte(kCommandtype) = objectId._type; + data.byte(kCommand) = objectId._index; 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)) { + ObjectRef subject; + subject._type = data.byte(kObjecttype); + subject._index = data.byte(kItemframe); + if (subject == _oldSubject) { if (data.byte(kCommandtype) != 243) { data.byte(kCommandtype) = 243; - data.word(kOldsubject) = subject; - commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = subject; + commandWithOb(34, subject._type, subject._index); } } else { - data.word(kOldsubject) = subject; - commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = subject; + commandWithOb(34, subject._type, subject._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -807,9 +802,9 @@ void DreamGenContext::swapWithInv() { 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; + ObjectRef objectId = findInvPos(); + data.byte(kItemframe) = objectId._index; + data.byte(kObjecttype) = objectId._type; DynObject *object = getEitherAdCPP(); object->mapad[0] = 20; object->mapad[1] = 255; @@ -817,7 +812,6 @@ void DreamGenContext::swapWithInv() { 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; @@ -841,9 +835,9 @@ void DreamGenContext::useOpened() { return; } - uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + ObjectRef objectId = findOpenPos(); - if ((objectId & 0x00FF) != 255) { + if (objectId._index != 255) { swapWithOpen(); return; } @@ -853,16 +847,17 @@ void DreamGenContext::useOpened() { return; } - objectId = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); - if (objectId == data.word(kOldsubject)) { + objectId._type = data.byte(kObjecttype); + objectId._index = data.byte(kItemframe); + if (objectId == _oldSubject) { if (data.byte(kCommandtype) != 227) { data.byte(kCommandtype) = 227; - data.word(kOldsubject) = objectId; - commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = objectId; + commandWithOb(35, objectId._type, objectId._index); } } else { - data.word(kOldsubject) = objectId; - commandWithOb(35, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = objectId; + commandWithOb(35, objectId._type, objectId._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -903,22 +898,22 @@ void DreamGenContext::outOfOpen() { if (data.byte(kOpenedob) == 255) return; // cannot use opened object - uint16 objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); + ObjectRef objectId = findOpenPos(); - if ((objectId & 0x00FF) == 255) { + if (objectId._index == 255) { blank(); return; } - if (objectId == data.word(kOldsubject)) { + if (objectId == _oldSubject) { if (data.byte(kCommandtype) != 228) { data.byte(kCommandtype) = 228; - data.word(kOldsubject) = objectId; - commandWithOb(36, objectId >> 8, objectId & 0x00FF); + _oldSubject = objectId; + commandWithOb(36, objectId._type, objectId._index); } } else { - data.word(kOldsubject) = objectId; - commandWithOb(36, objectId >> 8, objectId & 0x00FF); + _oldSubject = objectId; + commandWithOb(36, objectId._type, objectId._index); } if (data.word(kMousebutton) == data.word(kOldbutton)) @@ -934,13 +929,13 @@ void DreamGenContext::outOfOpen() { delPointer(); data.byte(kPickup) = 1; - objectId = getSegment(data.word(kBuffers)).word(findOpenPos()); - data.byte(kObjecttype) = objectId >> 8; - data.byte(kItemframe) = objectId & 0xFF; + objectId = findOpenPos(); + data.byte(kObjecttype) = objectId._type; + data.byte(kItemframe) = objectId._index; - if (data.byte(kObjecttype) != 4) { + if (data.byte(kObjecttype) != kExObjectType) { data.byte(kItemframe) = transferToEx(); - data.byte(kObjecttype) = 4; + data.byte(kObjecttype) = kExObjectType; } DynObject *object = getEitherAdCPP(); @@ -957,16 +952,18 @@ void DreamGenContext::outOfOpen() { } void DreamGenContext::swapWithOpen() { - uint16 subject = (data.byte(kObjecttype) << 8) | data.byte(kItemframe); - if (subject == data.word(kOldsubject)) { + ObjectRef subject; + subject._type = data.byte(kObjecttype); + subject._index = data.byte(kItemframe); + if (subject == _oldSubject) { if (data.byte(kCommandtype) != 242) { data.byte(kCommandtype) = 242; - data.word(kOldsubject) = subject; - commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = subject; + commandWithOb(34, subject._type, subject._index); } } else { - data.word(kOldsubject) = subject; - commandWithOb(34, data.byte(kObjecttype), data.byte(kItemframe)); + _oldSubject = subject; + commandWithOb(34, subject._type, subject._index); } if (data.word(kMousebutton) == data.word(kOldbutton) || !(data.word(kMousebutton) & 1)) @@ -990,13 +987,13 @@ void DreamGenContext::swapWithOpen() { 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; + ObjectRef objectId = findOpenPos(); + data.byte(kObjecttype) = objectId._type; + data.byte(kItemframe) = objectId._index; - if (data.byte(kObjecttype) != 4) { + if (data.byte(kObjecttype) != kExObjectType) { data.byte(kItemframe) = transferToEx(); - data.byte(kObjecttype) = 4; + data.byte(kObjecttype) = kExObjectType; } DynObject *object = getEitherAdCPP(); @@ -1007,7 +1004,6 @@ void DreamGenContext::swapWithOpen() { 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); @@ -1025,11 +1021,11 @@ void DreamGenContext::swapWithOpen() { delPointer(); } -uint16 DreamBase::findOpenPos() { - uint16 pos = (data.word(kMousex) - kInventx) / kItempicsize; - data.byte(kLastinvpos) = pos & 0xFF; +ObjectRef DreamBase::findOpenPos() { + uint8 pos = (data.word(kMousex) - kInventx) / kItempicsize; + data.byte(kLastinvpos) = pos; - return pos * 2 + kOpeninvlist; // return the object position in the inventory data + return _openInvList[pos]; } byte DreamGenContext::transferToEx() { @@ -1063,24 +1059,19 @@ void DreamBase::fillOpen() { if (size > 4) size = 4; findAllOpen(); - uint8 *openInvList = getSegment(data.word(kBuffers)).ptr(kOpeninvlist, 32); for (uint8 i = 0; i < size; ++i) { - uint8 index = openInvList[2*i]; - uint8 type = openInvList[2*i + 1]; + uint8 index = _openInvList[i]._index; + uint8 type = _openInvList[i]._type; obToInv(index, type, kInventx + i * kItempicsize, kInventy + 96); } underTextLine(); } void DreamBase::findAllOpen() { - uint8 *openInvList = getSegment(data.word(kBuffers)).ptr(kOpeninvlist, 32); + memset(_openInvList, 0xFF, 32); - memset(openInvList, 0xFF, 32); - - const DynObject *obj; - - obj = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0); - for (uint8 i = 0; i < kNumexobjects; ++i, ++obj) { + for (uint8 i = 0; i < kNumexobjects; ++i) { + const DynObject *obj = getExAd(i); if (obj->mapad[1] != data.byte(kOpenedob)) continue; if (obj->mapad[0] != data.byte(kOpenedtype)) @@ -1089,19 +1080,19 @@ void DreamBase::findAllOpen() { continue; uint8 slot = obj->mapad[2]; assert(slot < 16); - openInvList[2*slot] = i; - openInvList[2*slot + 1] = kExObjectType; + _openInvList[slot]._index = i; + _openInvList[slot]._type = kExObjectType; } - obj = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0); - for (uint8 i = 0; i < 80; ++i, ++obj) { + for (uint8 i = 0; i < 80; ++i) { + const DynObject *obj = getFreeAd(i); if (obj->mapad[1] != data.byte(kOpenedob)) continue; if (obj->mapad[0] != data.byte(kOpenedtype)) continue; - uint8 index = obj->mapad[2]; - openInvList[2*index] = i; - openInvList[2*index + 1] = kFreeObjectType; + uint8 slot = obj->mapad[2]; + _openInvList[slot]._index = i; + _openInvList[slot]._type = kFreeObjectType; } } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index b0a168930b5..fdc84536c0d 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -281,6 +281,18 @@ enum ObjectTypes { kExObjectType = 4 }; +struct ObjectRef { + uint8 _index; + uint8 _type; // enum ObjectTypes + + bool operator==(const ObjectRef &r) const { + return _index == r._index && _type == r._type; + } + bool operator!=(const ObjectRef &r) const { + return _index != r._index || _type != r._type; + } +}; + } // End of namespace DreamWeb #endif diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 14b8accea06..5577c772d55 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -121,8 +121,6 @@ bool checkObjectSizeCPP(); void identifyOb(); void selectOb(); - void findInvPos(); - uint16 findInvPosCPP(); void setPickup(); void getKeyAndLogo(); void signOn();