2011-07-19 10:26:40 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-06-15 21:03:00 +00:00
|
|
|
#include "dreamweb/dreamweb.h"
|
|
|
|
#include "engines/util.h"
|
2011-06-25 18:30:16 +00:00
|
|
|
#include "common/config-manager.h"
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-16 12:31:17 +00:00
|
|
|
namespace DreamGen {
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-26 10:06:16 +00:00
|
|
|
void DreamGenContext::dreamweb() {
|
|
|
|
STACK_CHECK;
|
2011-11-15 21:11:32 +00:00
|
|
|
|
|
|
|
switch(engine->getLanguage()) {
|
|
|
|
case Common::EN_ANY:
|
|
|
|
case Common::EN_GRB:
|
|
|
|
case Common::EN_USA:
|
2011-11-16 02:51:51 +00:00
|
|
|
// Implicit data.byte(kForeignrelease) = 0
|
|
|
|
break;
|
2011-11-15 21:11:32 +00:00
|
|
|
default:
|
|
|
|
data.byte(kForeignrelease) = 1;
|
2011-11-16 02:51:51 +00:00
|
|
|
break;
|
2011-11-15 21:11:32 +00:00
|
|
|
}
|
|
|
|
|
2011-06-26 10:06:16 +00:00
|
|
|
seecommandtail();
|
|
|
|
soundstartup();
|
|
|
|
setkeyboardint();
|
|
|
|
setupemm();
|
|
|
|
allocatebuffers();
|
|
|
|
setmouse();
|
|
|
|
fadedos();
|
|
|
|
gettime();
|
|
|
|
clearbuffers();
|
|
|
|
clearpalette();
|
|
|
|
set16colpalette();
|
|
|
|
readsetdata();
|
|
|
|
data.byte(kWongame) = 0;
|
2011-06-25 14:40:41 +00:00
|
|
|
|
2011-06-26 10:06:16 +00:00
|
|
|
dx = 1909;
|
|
|
|
loadsample();
|
|
|
|
setsoundoff();
|
|
|
|
|
2011-06-25 14:40:41 +00:00
|
|
|
bool firstLoop = true;
|
|
|
|
|
2011-06-25 18:30:16 +00:00
|
|
|
int savegameId = Common::ConfigManager::instance().getInt("save_slot");
|
|
|
|
|
2011-06-25 14:40:41 +00:00
|
|
|
while (true) {
|
|
|
|
|
|
|
|
scanfornames();
|
|
|
|
|
|
|
|
bool startNewGame = true;
|
|
|
|
|
2011-06-25 18:30:16 +00:00
|
|
|
if (firstLoop && savegameId >= 0) {
|
|
|
|
|
|
|
|
// loading a savegame requested from launcher/command line
|
|
|
|
|
|
|
|
cls();
|
|
|
|
setmode();
|
|
|
|
loadpalfromiff();
|
|
|
|
clearpalette();
|
|
|
|
|
|
|
|
ax = savegameId;
|
|
|
|
doload();
|
|
|
|
worktoscreen();
|
|
|
|
fadescreenup();
|
|
|
|
startNewGame = false;
|
|
|
|
|
|
|
|
} else if (al == 0 && firstLoop) {
|
2011-06-25 14:40:41 +00:00
|
|
|
|
|
|
|
// no savegames found, and we're not restarting.
|
|
|
|
|
|
|
|
setmode();
|
|
|
|
loadpalfromiff();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// "dodecisions"
|
|
|
|
|
|
|
|
// Savegames found, so ask if we should load one.
|
|
|
|
// (If we're restarting after game over, we also always show these
|
|
|
|
// options.)
|
|
|
|
|
|
|
|
cls();
|
|
|
|
setmode();
|
|
|
|
decide();
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-06-25 14:40:41 +00:00
|
|
|
return; // exit game
|
|
|
|
|
|
|
|
if (data.byte(kGetback) == 4)
|
|
|
|
startNewGame = false; // savegame has been loaded
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
firstLoop = false;
|
|
|
|
|
|
|
|
if (startNewGame) {
|
|
|
|
// "playgame"
|
|
|
|
|
|
|
|
titles();
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-06-25 14:40:41 +00:00
|
|
|
return; // exit game
|
|
|
|
credits();
|
|
|
|
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-06-25 14:40:41 +00:00
|
|
|
return; // exit game
|
|
|
|
|
|
|
|
clearchanges();
|
|
|
|
setmode();
|
|
|
|
loadpalfromiff();
|
|
|
|
data.byte(kLocation) = 255;
|
|
|
|
data.byte(kRoomafterdream) = 1;
|
|
|
|
data.byte(kNewlocation) = 35;
|
|
|
|
data.byte(kVolume) = 7;
|
|
|
|
loadroom();
|
|
|
|
clearsprites();
|
|
|
|
initman();
|
|
|
|
entrytexts();
|
|
|
|
entryanims();
|
|
|
|
data.byte(kDestpos) = 3;
|
|
|
|
initialinv();
|
|
|
|
data.byte(kLastflag) = 32;
|
|
|
|
startup1();
|
|
|
|
data.byte(kVolumeto) = 0;
|
2011-10-15 09:21:02 +00:00
|
|
|
data.byte(kVolumedirection) = (uint8)-1;
|
2011-06-25 14:40:41 +00:00
|
|
|
data.byte(kCommandtype) = 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// main loop
|
|
|
|
while (true) {
|
|
|
|
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-06-25 14:40:41 +00:00
|
|
|
return; // exit game
|
|
|
|
|
|
|
|
screenupdate();
|
|
|
|
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-11-15 19:59:03 +00:00
|
|
|
return; // exit game
|
|
|
|
|
2011-06-25 14:40:41 +00:00
|
|
|
if (data.byte(kWongame) != 0) {
|
|
|
|
// "endofgame"
|
|
|
|
clearbeforeload();
|
|
|
|
fadescreendowns();
|
2011-09-06 20:10:02 +00:00
|
|
|
hangon(200);
|
2011-06-25 14:40:41 +00:00
|
|
|
endgame();
|
|
|
|
quickquit2();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.byte(kMandead) == 1 || data.byte(kMandead) == 2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (data.word(kWatchingtime) > 0) {
|
|
|
|
if (data.byte(kFinaldest) == data.byte(kManspath))
|
|
|
|
data.word(kWatchingtime)--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.word(kWatchingtime) == 0) {
|
|
|
|
// "notwatching"
|
|
|
|
|
|
|
|
if (data.byte(kMandead) == 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (data.byte(kNewlocation) != 255) {
|
|
|
|
// "loadnew"
|
|
|
|
clearbeforeload();
|
|
|
|
loadroom();
|
|
|
|
clearsprites();
|
|
|
|
initman();
|
|
|
|
entrytexts();
|
|
|
|
entryanims();
|
|
|
|
data.byte(kNewlocation) = 255;
|
|
|
|
startup();
|
|
|
|
data.byte(kCommandtype) = 255;
|
|
|
|
worktoscreenm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// "gameover"
|
|
|
|
clearbeforeload();
|
|
|
|
showgun();
|
|
|
|
fadescreendown();
|
2011-09-06 20:10:02 +00:00
|
|
|
hangon(100);
|
2011-06-25 14:40:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2011-06-26 10:06:16 +00:00
|
|
|
|
2011-11-20 20:26:18 +00:00
|
|
|
bool DreamGenContext::quitRequested() {
|
|
|
|
return data.byte(kQuitrequested);
|
|
|
|
}
|
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
void DreamGenContext::screenupdate() {
|
|
|
|
newplace();
|
|
|
|
mainscreen();
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-11-20 20:13:46 +00:00
|
|
|
return;
|
|
|
|
animpointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
showpointer();
|
|
|
|
if ((data.word(kWatchingtime) == 0) && (data.byte(kNewlocation) != 0xff))
|
|
|
|
return;
|
|
|
|
vsync();
|
2011-11-20 18:54:19 +00:00
|
|
|
uint16 mouseState = 0;
|
|
|
|
mouseState |= readMouseState();
|
2011-11-20 20:13:46 +00:00
|
|
|
dumppointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
dumptextline();
|
|
|
|
delpointer();
|
|
|
|
autolook();
|
|
|
|
spriteupdate();
|
|
|
|
watchcount();
|
|
|
|
zoom();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
showpointer();
|
|
|
|
if (data.byte(kWongame))
|
|
|
|
return;
|
|
|
|
vsync();
|
2011-11-20 18:54:19 +00:00
|
|
|
mouseState |= readMouseState();
|
2011-11-20 20:13:46 +00:00
|
|
|
dumppointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
dumpzoom();
|
|
|
|
delpointer();
|
|
|
|
deleverything();
|
|
|
|
printsprites();
|
|
|
|
reelsonscreen();
|
|
|
|
afternewroom();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
showpointer();
|
|
|
|
vsync();
|
2011-11-20 18:54:19 +00:00
|
|
|
mouseState |= readMouseState();
|
2011-11-20 20:13:46 +00:00
|
|
|
dumppointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
dumpmap();
|
|
|
|
dumptimedtext();
|
|
|
|
delpointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
showpointer();
|
|
|
|
vsync();
|
2011-11-20 18:54:19 +00:00
|
|
|
data.word(kOldbutton) = data.word(kMousebutton);
|
|
|
|
mouseState |= readMouseState();
|
|
|
|
data.word(kMousebutton) = mouseState;
|
2011-11-20 20:13:46 +00:00
|
|
|
dumppointer();
|
2011-11-20 18:54:19 +00:00
|
|
|
|
2011-11-20 20:13:46 +00:00
|
|
|
dumpwatch();
|
|
|
|
delpointer();
|
|
|
|
}
|
|
|
|
|
2011-11-20 18:53:58 +00:00
|
|
|
void DreamGenContext::startup() {
|
|
|
|
data.byte(kCurrentkey) = 0;
|
|
|
|
data.byte(kMainmode) = 0;
|
|
|
|
createpanel();
|
|
|
|
data.byte(kNewobs) = 1;
|
|
|
|
drawfloor();
|
|
|
|
showicon();
|
|
|
|
getunderzoom();
|
|
|
|
spriteupdate();
|
|
|
|
printsprites();
|
|
|
|
undertextline();
|
|
|
|
reelsonscreen();
|
|
|
|
atmospheres();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::startup1() {
|
|
|
|
clearpalette();
|
|
|
|
data.byte(kThroughdoor) = 0;
|
2011-11-20 18:54:19 +00:00
|
|
|
|
|
|
|
startup();
|
|
|
|
|
2011-11-20 18:53:58 +00:00
|
|
|
worktoscreen();
|
|
|
|
fadescreenup();
|
|
|
|
}
|
|
|
|
|
2011-11-20 18:58:05 +00:00
|
|
|
void DreamGenContext::switchryanon() {
|
|
|
|
data.byte(kRyanon) = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::switchryanoff() {
|
|
|
|
data.byte(kRyanon) = 1;
|
|
|
|
}
|
|
|
|
|
2011-07-30 12:13:34 +00:00
|
|
|
static Common::String getFilename(Context &context) {
|
2011-11-15 21:11:53 +00:00
|
|
|
const char *name = (const char *)context.cs.ptr(context.dx, 0);
|
|
|
|
return Common::String(name);
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-18 05:30:12 +00:00
|
|
|
uint8 *DreamGenContext::textUnder() {
|
|
|
|
return segRef(data.word(kBuffers)).ptr(kTextunder, 0);
|
|
|
|
}
|
|
|
|
|
2011-11-17 17:21:34 +00:00
|
|
|
uint16 DreamGenContext::standardload(const char *fileName) {
|
|
|
|
engine->openFile(fileName);
|
|
|
|
engine->readFromFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
|
|
|
|
uint16 sizeInBytes = cs.word(kFiledata);
|
|
|
|
uint16 result = allocatemem((sizeInBytes + 15) / 16);
|
|
|
|
engine->readFromFile(segRef(result).ptr(0, 0), sizeInBytes);
|
|
|
|
engine->closeFile();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::standardload() {
|
|
|
|
ax = standardload((const char *)cs.ptr(dx, 0));
|
|
|
|
}
|
|
|
|
|
2011-11-17 23:01:24 +00:00
|
|
|
void DreamGenContext::loadintotemp() {
|
|
|
|
loadintotemp((const char *)cs.ptr(dx, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadintotemp2() {
|
|
|
|
loadintotemp2((const char *)cs.ptr(dx, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadintotemp3() {
|
|
|
|
loadintotemp3((const char *)cs.ptr(dx, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadintotemp(const char *fileName) {
|
|
|
|
data.word(kTempgraphics) = standardload(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadintotemp2(const char *fileName) {
|
|
|
|
data.word(kTempgraphics2) = standardload(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadintotemp3(const char *fileName) {
|
|
|
|
data.word(kTempgraphics3) = standardload(fileName);
|
|
|
|
}
|
|
|
|
|
2011-11-17 23:14:30 +00:00
|
|
|
void DreamGenContext::loadtempcharset() {
|
|
|
|
loadtempcharset((const char *)cs.ptr(dx, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::loadtempcharset(const char *fileName) {
|
|
|
|
data.word(kTempcharset) = standardload(fileName);
|
|
|
|
}
|
|
|
|
|
2011-11-20 13:14:58 +00:00
|
|
|
Frame *DreamGenContext::tempCharset() {
|
|
|
|
return (Frame *)segRef(data.word(kTempcharset)).ptr(0, 0);
|
|
|
|
}
|
|
|
|
|
2011-11-18 05:33:18 +00:00
|
|
|
void DreamGenContext::hangoncurs(uint16 frameCount) {
|
|
|
|
for (uint16 i = 0; i < frameCount; ++i) {
|
|
|
|
printcurs();
|
|
|
|
vsync();
|
|
|
|
delcurs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::seecommandtail() {
|
|
|
|
data.word(kSoundbaseadd) = 0x220;
|
|
|
|
data.byte(kSoundint) = 5;
|
|
|
|
data.byte(kSounddmachannel) = 1;
|
|
|
|
data.byte(kBrightness) = 1;
|
|
|
|
data.word(kHowmuchalloc) = 0x9360;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::randomnumber() {
|
|
|
|
al = engine->randomNumber();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::quickquit() {
|
|
|
|
engine->quit();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::quickquit2() {
|
|
|
|
engine->quit();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::keyboardread() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("keyboardread"); //this keyboard int handler, must never be called
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::resetkeyboard() {
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::setkeyboardint() {
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::readfromfile() {
|
|
|
|
uint16 dst_offset = dx;
|
|
|
|
uint16 size = cx;
|
|
|
|
debug(1, "readfromfile(%04x:%u, %u)", (uint16)ds, dst_offset, size);
|
|
|
|
ax = engine->readFromFile(ds.ptr(dst_offset, size), size);
|
|
|
|
flags._c = false;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::closefile() {
|
|
|
|
engine->closeFile();
|
|
|
|
data.byte(kHandle) = 0;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 15:38:06 +00:00
|
|
|
void DreamGenContext::openforsave(unsigned int slot) {
|
|
|
|
//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
|
|
|
|
Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
|
|
|
|
debug(1, "openforsave(%s)", filename.c_str());
|
|
|
|
engine->openSaveFileForWriting(filename);
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-26 16:07:40 +00:00
|
|
|
void DreamGenContext::openforload(unsigned int slot) {
|
|
|
|
//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
|
|
|
|
Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
|
|
|
|
debug(1, "openforload(%s)", filename.c_str());
|
|
|
|
engine->openSaveFileForReading(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::openfilenocheck() {
|
|
|
|
const char *name = (const char *)ds.ptr(dx, 13);
|
2011-06-15 21:03:00 +00:00
|
|
|
debug(1, "checksavefile(%s)", name);
|
2011-06-16 20:30:39 +00:00
|
|
|
bool ok = engine->openSaveFileForReading(name);
|
|
|
|
flags._c = !ok;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::openfilefromc() {
|
|
|
|
openfilenocheck();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::openfile() {
|
|
|
|
Common::String name = getFilename(*this);
|
2011-06-15 21:03:00 +00:00
|
|
|
debug(1, "opening file: %s", name.c_str());
|
2011-06-16 20:30:39 +00:00
|
|
|
engine->openFile(name);
|
|
|
|
cs.word(kHandle) = 1; //only one handle
|
|
|
|
flags._c = false;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::createfile() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("createfile");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::dontloadseg() {
|
|
|
|
ax = es.word(di);
|
|
|
|
_add(di, 2);
|
|
|
|
dx = ax;
|
|
|
|
cx = 0;
|
|
|
|
unsigned pos = engine->skipBytes(dx);
|
|
|
|
dx = pos >> 16;
|
|
|
|
ax = pos & 0xffff;
|
|
|
|
flags._c = false;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::mousecall() {
|
2011-08-25 05:46:23 +00:00
|
|
|
uint16 x, y, state;
|
|
|
|
engine->mouseCall(&x, &y, &state);
|
|
|
|
cx = x;
|
|
|
|
dx = y;
|
|
|
|
bx = state;
|
2011-08-25 05:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::readmouse() {
|
|
|
|
data.word(kOldbutton) = data.word(kMousebutton);
|
2011-11-20 18:54:19 +00:00
|
|
|
uint16 state = readMouseState();
|
2011-08-25 05:50:35 +00:00
|
|
|
data.word(kMousebutton) = state;
|
|
|
|
}
|
|
|
|
|
2011-11-20 18:54:19 +00:00
|
|
|
uint16 DreamGenContext::readMouseState() {
|
2011-08-25 05:50:35 +00:00
|
|
|
data.word(kOldx) = data.word(kMousex);
|
|
|
|
data.word(kOldy) = data.word(kMousey);
|
|
|
|
uint16 x, y, state;
|
|
|
|
engine->mouseCall(&x, &y, &state);
|
|
|
|
data.word(kMousex) = x;
|
|
|
|
data.word(kMousey) = y;
|
2011-11-20 18:54:19 +00:00
|
|
|
return state;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::setmouse() {
|
|
|
|
data.word(kOldpointerx) = 0xffff;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 20:46:16 +00:00
|
|
|
void DreamGenContext::dumptextline() {
|
|
|
|
if (data.byte(kNewtextline) != 1)
|
|
|
|
return;
|
|
|
|
data.byte(kNewtextline) = 0;
|
|
|
|
uint16 x = data.word(kTextaddressx);
|
|
|
|
uint16 y = data.word(kTextaddressy);
|
|
|
|
if (data.byte(kForeignrelease) != 0)
|
|
|
|
y -= 3;
|
|
|
|
multidump(x, y, 228, 13);
|
|
|
|
}
|
|
|
|
|
2011-07-23 17:18:10 +00:00
|
|
|
void DreamGenContext::getundertimed() {
|
|
|
|
uint16 y = data.byte(kTimedy);
|
|
|
|
if (data.byte(kForeignrelease))
|
|
|
|
y -= 3;
|
|
|
|
ds = data.word(kBuffers);
|
|
|
|
si = kUndertimedtext;
|
2011-08-03 14:44:29 +00:00
|
|
|
multiget(ds.ptr(si, 0), data.byte(kTimedx), y, 240, kUndertimedysize);
|
2011-07-23 17:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::putundertimed() {
|
|
|
|
uint16 y = data.byte(kTimedy);
|
|
|
|
if (data.byte(kForeignrelease))
|
|
|
|
y -= 3;
|
|
|
|
ds = data.word(kBuffers);
|
|
|
|
si = kUndertimedtext;
|
2011-08-03 14:44:29 +00:00
|
|
|
multiput(ds.ptr(si, 0), data.byte(kTimedx), y, 240, kUndertimedysize);
|
2011-07-23 17:18:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::usetimedtext() {
|
|
|
|
if (data.word(kTimecount) == 0)
|
|
|
|
return;
|
|
|
|
--data.word(kTimecount);
|
|
|
|
if (data.word(kTimecount) == 0) {
|
|
|
|
putundertimed();
|
|
|
|
data.byte(kNeedtodumptimed) = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.word(kTimecount) == data.word(kCounttotimed))
|
|
|
|
getundertimed();
|
|
|
|
else if (data.word(kTimecount) > data.word(kCounttotimed))
|
|
|
|
return;
|
|
|
|
|
|
|
|
es = data.word(kTimedseg);
|
|
|
|
si = data.word(kTimedoffset);
|
2011-08-10 15:12:26 +00:00
|
|
|
const uint8 *string = es.ptr(si, 0);
|
2011-07-23 17:18:10 +00:00
|
|
|
uint16 y = data.byte(kTimedy);
|
2011-08-10 15:12:26 +00:00
|
|
|
printdirect(&string, data.byte(kTimedx), &y, 237, true);
|
2011-07-23 17:18:10 +00:00
|
|
|
data.byte(kNeedtodumptimed) = 1;
|
|
|
|
}
|
|
|
|
|
2011-08-11 14:59:20 +00:00
|
|
|
void DreamGenContext::setuptimedtemp() {
|
|
|
|
setuptimedtemp(al, ah, bl, bh, cx, dx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::setuptimedtemp(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8 y, uint16 countToTimed, uint16 timeCount) {
|
|
|
|
#if 1 // if cd
|
|
|
|
if (voiceIndex != 0) {
|
|
|
|
push(ax);
|
|
|
|
push(bx);
|
|
|
|
push(cx);
|
|
|
|
push(dx);
|
|
|
|
dl = 'T';
|
|
|
|
dh = voiceIndex;
|
|
|
|
cl = 'T';
|
|
|
|
ah = 0;
|
2011-11-16 19:05:48 +00:00
|
|
|
al = textIndex;
|
2011-08-11 14:59:20 +00:00
|
|
|
loadspeech();
|
|
|
|
if (data.byte(kSpeechloaded) == 1) {
|
2011-11-21 13:33:36 +00:00
|
|
|
playchannel1(50+12);
|
2011-07-17 14:06:19 +00:00
|
|
|
}
|
2011-08-11 14:59:20 +00:00
|
|
|
dx = pop();
|
|
|
|
cx = pop();
|
|
|
|
bx = pop();
|
|
|
|
ax = pop();
|
2011-11-16 20:39:25 +00:00
|
|
|
|
|
|
|
// FIXME: This fallthrough does not properly support subtitles+speech
|
|
|
|
// mode. The parameters to setuptimedtemp() are sometimes different
|
|
|
|
// for speech and for subtitles. See e.g., madmantext()
|
2011-08-11 14:59:20 +00:00
|
|
|
if ((data.byte(kSpeechloaded) == 1) && (data.byte(kSubtitles) != 1))
|
|
|
|
return;
|
2011-07-17 14:06:19 +00:00
|
|
|
}
|
2011-08-11 14:59:20 +00:00
|
|
|
#endif
|
2011-07-17 14:06:19 +00:00
|
|
|
|
2011-08-11 14:59:20 +00:00
|
|
|
if (data.word(kTimecount) != 0)
|
|
|
|
return;
|
|
|
|
data.byte(kTimedy) = y;
|
|
|
|
data.byte(kTimedx) = x;
|
|
|
|
data.word(kCounttotimed) = countToTimed;
|
|
|
|
data.word(kTimecount) = timeCount + countToTimed;
|
|
|
|
data.word(kTimedseg) = data.word(kTextfile1);
|
|
|
|
data.word(kTimedoffset) = kTextstart + segRef(data.word(kTextfile1)).word(textIndex * 2);
|
|
|
|
const uint8 *string = segRef(data.word(kTextfile1)).ptr(data.word(kTimedoffset), 0);
|
|
|
|
debug(1, "setuptimedtemp: (%d, %d) => '%s'", textIndex, voiceIndex, string);
|
|
|
|
}
|
|
|
|
|
2011-08-11 13:24:06 +00:00
|
|
|
void DreamGenContext::dumptimedtext() {
|
|
|
|
if (data.byte(kNeedtodumptimed) != 1)
|
|
|
|
return;
|
|
|
|
uint8 y = data.byte(kTimedy);
|
|
|
|
if (data.byte(kForeignrelease) != 0)
|
|
|
|
y -= 3;
|
2011-07-17 12:38:30 +00:00
|
|
|
|
2011-08-11 13:24:06 +00:00
|
|
|
multidump(data.byte(kTimedx), y, 240, kUndertimedysize);
|
|
|
|
data.byte(kNeedtodumptimed) = 0;
|
2011-07-17 12:38:30 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::gettime() {
|
2011-06-15 21:03:00 +00:00
|
|
|
TimeDate t;
|
|
|
|
g_system->getTimeAndDate(t);
|
|
|
|
debug(1, "\tgettime: %02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
|
2011-06-16 20:30:39 +00:00
|
|
|
ch = t.tm_hour;
|
|
|
|
cl = t.tm_min;
|
|
|
|
dh = t.tm_sec;
|
|
|
|
data.byte(kSecondcount) = dh;
|
|
|
|
data.byte(kMinutecount) = cl;
|
|
|
|
data.byte(kHourcount) = ch;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::allocatemem() {
|
2011-07-30 20:03:28 +00:00
|
|
|
ax = allocatemem(bx);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 DreamGenContext::allocatemem(uint16 paragraphs) {
|
|
|
|
uint size = (paragraphs + 2) * 16;
|
2011-06-15 21:03:00 +00:00
|
|
|
debug(1, "allocate mem, %u bytes", size);
|
2011-06-16 20:30:39 +00:00
|
|
|
flags._c = false;
|
|
|
|
SegmentRef seg = allocateSegment(size);
|
2011-07-30 20:03:28 +00:00
|
|
|
uint16 result = (uint16)seg;
|
|
|
|
debug(1, "\tsegment address -> %04x", result);
|
|
|
|
return result;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::deallocatemem() {
|
2011-11-18 06:29:38 +00:00
|
|
|
deallocatemem((uint16)es);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::deallocatemem(uint16 segment) {
|
|
|
|
debug(1, "deallocating segment %04x", segment);
|
|
|
|
deallocateSegment(segment);
|
2011-06-15 21:03:00 +00:00
|
|
|
|
|
|
|
//fixing invalid entries in the sprite table
|
2011-06-16 20:30:39 +00:00
|
|
|
es = data;
|
2011-06-15 21:03:00 +00:00
|
|
|
uint tsize = 16 * 32;
|
2011-06-16 20:30:39 +00:00
|
|
|
uint16 bseg = data.word(kBuffers);
|
2011-06-15 21:03:00 +00:00
|
|
|
if (!bseg)
|
|
|
|
return;
|
2011-06-16 20:30:39 +00:00
|
|
|
SegmentRef buffers(this);
|
2011-06-15 21:03:00 +00:00
|
|
|
buffers = bseg;
|
|
|
|
uint8 *ptr = buffers.ptr(kSpritetable, tsize);
|
|
|
|
for(uint i = 0; i < tsize; i += 32) {
|
|
|
|
uint16 seg = READ_LE_UINT16(ptr + i + 6);
|
|
|
|
//debug(1, "sprite segment = %04x", seg);
|
2011-11-18 06:29:38 +00:00
|
|
|
if (seg == segment)
|
2011-06-15 21:03:00 +00:00
|
|
|
memset(ptr + i, 0xff, 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::removeemm() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("removeemm");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::setupemm() {
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::pitinterupt() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("pitinterupt");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::getridofpit() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("getridofpit");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::setuppit() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("setuppit");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::startdmablock() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("startdmablock");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::dmaend() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("dmaend");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::restoreems() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("restoreems");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::saveems() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("saveems");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::bothchannels() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("bothchannels");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::channel1only() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("channel1only");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::channel0only() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("channel0only");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::out22c() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("out22c");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::soundstartup() {}
|
|
|
|
void DreamGenContext::soundend() {}
|
2011-06-19 13:19:02 +00:00
|
|
|
void DreamGenContext::interupttest() {}
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::disablesoundint() {}
|
|
|
|
void DreamGenContext::enablesoundint() {}
|
|
|
|
void DreamGenContext::checksoundint() {
|
|
|
|
data.byte(kTestresult) = 1;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::setsoundoff() {
|
2011-06-15 21:03:00 +00:00
|
|
|
warning("setsoundoff: STUB");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::loadsample() {
|
|
|
|
engine->loadSounds(0, (const char *)data.ptr(dx, 13));
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::loadsecondsample() {
|
|
|
|
uint8 ch0 = data.byte(kCh0playing);
|
2011-06-15 21:03:00 +00:00
|
|
|
if (ch0 >= 12 && ch0 != 255)
|
2011-06-16 20:30:39 +00:00
|
|
|
cancelch0();
|
|
|
|
uint8 ch1 = data.byte(kCh1playing);
|
2011-06-15 21:03:00 +00:00
|
|
|
if (ch1 >= 12)
|
2011-06-16 20:30:39 +00:00
|
|
|
cancelch1();
|
|
|
|
engine->loadSounds(1, (const char *)data.ptr(dx, 13));
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::loadspeech() {
|
|
|
|
cancelch1();
|
|
|
|
data.byte(kSpeechloaded) = 0;
|
|
|
|
createname();
|
|
|
|
const char *name = (const char *)data.ptr(di, 13);
|
2011-06-15 21:03:00 +00:00
|
|
|
//warning("name = %s", name);
|
2011-06-16 20:30:39 +00:00
|
|
|
if (engine->loadSpeech(name))
|
|
|
|
data.byte(kSpeechloaded) = 1;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::savefileread() {
|
|
|
|
ax = engine->readFromSaveFile(ds.ptr(dx, cx), cx);
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::loadseg() {
|
|
|
|
ax = es.word(di);
|
|
|
|
di += 2;
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
uint16 dst_offset = dx;
|
|
|
|
uint16 size = ax;
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
debug(1, "loadseg(%04x:%u, %u)", (uint16)ds, dst_offset, size);
|
|
|
|
ax = engine->readFromFile(ds.ptr(dst_offset, size), size);
|
|
|
|
flags._c = false;
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::error() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("error");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::generalerror() {
|
2011-06-15 21:03:00 +00:00
|
|
|
::error("generalerror");
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::dosreturn() {
|
2011-06-19 11:24:31 +00:00
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
_cmp(data.byte(kCommandtype), 250);
|
2011-06-18 09:33:24 +00:00
|
|
|
if (!flags.z()) {
|
|
|
|
data.byte(kCommandtype) = 250;
|
|
|
|
al = 46;
|
|
|
|
commandonly();
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
ax = data.word(kMousebutton);
|
|
|
|
_and(ax, 1);
|
2011-06-19 22:59:48 +00:00
|
|
|
if (flags.z())
|
2011-06-18 09:33:24 +00:00
|
|
|
return;
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-18 09:33:24 +00:00
|
|
|
data.word(kMousebutton) = 0;
|
|
|
|
engine->quit();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-18 10:29:10 +00:00
|
|
|
void DreamGenContext::set16colpalette() {
|
|
|
|
}
|
2011-06-15 21:03:00 +00:00
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::mode640x480() {
|
2011-06-15 21:03:00 +00:00
|
|
|
// Video mode 12h: 640x480 pixels, 16 colors, I believe
|
2011-06-16 20:30:39 +00:00
|
|
|
al = 0x12 + 128;
|
|
|
|
ah = 0;
|
2011-06-15 21:03:00 +00:00
|
|
|
initGraphics(640, 480, true);
|
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::showgroup() {
|
|
|
|
engine->setPalette();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::fadedos() {
|
|
|
|
engine->fadeDos();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-26 13:17:19 +00:00
|
|
|
void DreamGenContext::eraseoldobs() {
|
|
|
|
if (data.byte(kNewobs) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Sprite *sprites = spritetable();
|
2011-11-15 21:30:31 +00:00
|
|
|
for (size_t i = 0; i < 16; ++i) {
|
2011-06-26 13:17:19 +00:00
|
|
|
Sprite &sprite = sprites[i];
|
2011-07-30 13:52:28 +00:00
|
|
|
if (sprite.objData() != 0xffff) {
|
2011-06-26 13:17:19 +00:00
|
|
|
memset(&sprite, 0xff, sizeof(Sprite));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-25 13:28:51 +00:00
|
|
|
void DreamGenContext::modifychar() {
|
|
|
|
al = engine->modifyChar(al);
|
|
|
|
}
|
|
|
|
|
2011-07-16 09:04:49 +00:00
|
|
|
void DreamGenContext::lockmon() {
|
|
|
|
// Pressing space pauses text output in the monitor. We use the "hard"
|
|
|
|
// key because calling readkey() drains characters from the input
|
|
|
|
// buffer, we we want the user to be able to type ahead while the text
|
|
|
|
// is being printed.
|
|
|
|
if (data.byte(kLasthardkey) == 57) {
|
|
|
|
// Clear the keyboard buffer. Otherwise the space that caused
|
2011-07-16 09:07:22 +00:00
|
|
|
// the pause will be read immediately unpause the game.
|
2011-07-16 09:04:49 +00:00
|
|
|
do {
|
|
|
|
readkey();
|
|
|
|
} while (data.byte(kCurrentkey) != 0);
|
|
|
|
|
|
|
|
locklighton();
|
|
|
|
while (!engine->shouldQuit()) {
|
|
|
|
engine->waitForVSync();
|
|
|
|
readkey();
|
|
|
|
if (data.byte(kCurrentkey) == ' ')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Forget the last "hard" key, otherwise the space that caused
|
|
|
|
// the unpausing will immediately re-pause the game.
|
|
|
|
data.byte(kLasthardkey) = 0;
|
|
|
|
locklightoff();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-20 11:15:30 +00:00
|
|
|
void DreamGenContext::cancelch0() {
|
|
|
|
data.byte(kCh0repeat) = 0;
|
|
|
|
data.word(kCh0blockstocopy) = 0;
|
|
|
|
data.byte(kCh0playing) = 255;
|
|
|
|
engine->stopSound(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::cancelch1() {
|
|
|
|
data.word(kCh1blockstocopy) = 0;
|
|
|
|
data.byte(kCh1playing) = 255;
|
|
|
|
engine->stopSound(1);
|
|
|
|
}
|
|
|
|
|
2011-08-23 12:41:28 +00:00
|
|
|
void DreamGenContext::makebackob(SetObject *objData) {
|
2011-07-27 15:53:50 +00:00
|
|
|
if (data.byte(kNewobs) == 0)
|
|
|
|
return;
|
2011-08-17 05:08:38 +00:00
|
|
|
uint8 priority = objData->priority;
|
|
|
|
uint8 type = objData->type;
|
2011-07-27 15:53:50 +00:00
|
|
|
Sprite *sprite = makesprite(data.word(kObjectx), data.word(kObjecty), addr_backobject, data.word(kSetframes), 0);
|
|
|
|
|
2011-08-17 05:08:38 +00:00
|
|
|
uint16 objDataOffset = (uint8 *)objData - segRef(data.word(kSetdat)).ptr(0, 0);
|
2011-08-23 12:41:28 +00:00
|
|
|
assert(objDataOffset % sizeof(SetObject) == 0);
|
|
|
|
assert(objDataOffset < 128 * sizeof(SetObject));
|
2011-08-17 05:08:38 +00:00
|
|
|
sprite->setObjData(objDataOffset);
|
2011-07-27 15:53:50 +00:00
|
|
|
if (priority == 255)
|
|
|
|
priority = 0;
|
|
|
|
sprite->priority = priority;
|
|
|
|
sprite->type = type;
|
|
|
|
sprite->b16 = 0;
|
|
|
|
sprite->delay = 0;
|
2011-11-18 21:34:46 +00:00
|
|
|
sprite->animFrame = 0;
|
2011-07-27 15:53:50 +00:00
|
|
|
}
|
|
|
|
|
2011-07-30 17:54:53 +00:00
|
|
|
void DreamGenContext::getroomdata() {
|
2011-11-17 10:29:15 +00:00
|
|
|
Room *room = getroomdata(al);
|
|
|
|
bx = (uint8 *)room - cs.ptr(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Room *DreamGenContext::getroomdata(uint8 room) {
|
|
|
|
return (Room *)cs.ptr(kRoomdata, 0) + room;
|
2011-07-30 17:54:53 +00:00
|
|
|
}
|
|
|
|
|
2011-07-30 19:56:33 +00:00
|
|
|
void DreamGenContext::readheader() {
|
|
|
|
ax = engine->readFromFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
|
|
|
|
es = cs;
|
|
|
|
di = kFiledata;
|
|
|
|
}
|
|
|
|
|
2011-11-26 19:36:56 +00:00
|
|
|
uint16 DreamGenContext::allocateAndLoad(unsigned int size) {
|
|
|
|
// allocatemem adds 32 bytes, so it doesn't matter that size/16 rounds down
|
|
|
|
uint16 result = allocatemem(size / 16);
|
|
|
|
engine->readFromFile(segRef(result).ptr(0, size), size);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::clearAndLoad(uint16 seg, uint8 c,
|
|
|
|
unsigned int size, unsigned int maxSize) {
|
|
|
|
assert(size <= maxSize);
|
|
|
|
uint8 *buf = segRef(seg).ptr(0, maxSize);
|
|
|
|
memset(buf, c, maxSize);
|
|
|
|
engine->readFromFile(buf, size);
|
|
|
|
}
|
|
|
|
|
2011-07-30 19:46:59 +00:00
|
|
|
void DreamGenContext::startloading(const Room *room) {
|
|
|
|
data.byte(kCombatcount) = 0;
|
|
|
|
data.byte(kRoomssample) = room->roomsSample;
|
|
|
|
data.byte(kMapx) = room->mapX;
|
|
|
|
data.byte(kMapy) = room->mapY;
|
|
|
|
data.byte(kLiftflag) = room->liftFlag;
|
|
|
|
data.byte(kManspath) = room->b21;
|
|
|
|
data.byte(kDestination) = room->b21;
|
|
|
|
data.byte(kFinaldest) = room->b21;
|
2011-11-26 11:29:09 +00:00
|
|
|
data.byte(kFacing) = room->facing;
|
|
|
|
data.byte(kTurntoface) = room->facing;
|
2011-07-30 19:46:59 +00:00
|
|
|
data.byte(kCounttoopen) = room->countToOpen;
|
|
|
|
data.byte(kLiftpath) = room->liftPath;
|
|
|
|
data.byte(kDoorpath) = room->doorPath;
|
2011-10-15 09:21:02 +00:00
|
|
|
data.byte(kLastweapon) = (uint8)-1;
|
2011-07-30 19:46:59 +00:00
|
|
|
ah = data.byte(kReallocation);
|
2011-11-26 11:29:09 +00:00
|
|
|
data.byte(kReallocation) = room->realLocation;
|
2011-11-26 19:36:56 +00:00
|
|
|
|
|
|
|
loadRoomData(room, false);
|
|
|
|
|
2011-07-30 19:46:59 +00:00
|
|
|
findroominloc();
|
|
|
|
deletetaken();
|
|
|
|
setallchanges();
|
|
|
|
autoappear();
|
2011-11-17 10:34:06 +00:00
|
|
|
Room *newRoom = getroomdata(data.byte(kNewlocation));
|
|
|
|
bx = (uint8 *)newRoom - cs.ptr(0, 0);
|
2011-10-15 09:21:02 +00:00
|
|
|
data.byte(kLastweapon) = (uint8)-1;
|
2011-07-30 19:46:59 +00:00
|
|
|
data.byte(kMandead) = 0;
|
|
|
|
data.word(kLookcounter) = 160;
|
|
|
|
data.byte(kNewlocation) = 255;
|
|
|
|
data.byte(kLinepointer) = 254;
|
2011-11-26 11:29:09 +00:00
|
|
|
if (room->b27 != 255) {
|
|
|
|
data.byte(kManspath) = room->b27;
|
2011-07-30 19:46:59 +00:00
|
|
|
push(bx);
|
|
|
|
autosetwalk();
|
|
|
|
bx = pop();
|
|
|
|
}
|
|
|
|
findxyfrompath();
|
|
|
|
}
|
|
|
|
|
2011-07-30 20:56:29 +00:00
|
|
|
void DreamGenContext::fillspace() {
|
|
|
|
memset(ds.ptr(dx, cx), al, cx);
|
|
|
|
}
|
|
|
|
|
2011-08-11 10:33:33 +00:00
|
|
|
void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) {
|
|
|
|
uint8 type = firstParam - 220;
|
2011-07-30 21:21:43 +00:00
|
|
|
if (type == 0) {
|
2011-08-20 11:23:47 +00:00
|
|
|
placesetobject(secondParam);
|
2011-07-30 21:21:43 +00:00
|
|
|
data.byte(kHavedoneobs) = 1;
|
|
|
|
} else if (type == 1) {
|
2011-08-20 11:23:47 +00:00
|
|
|
removesetobject(secondParam);
|
2011-07-30 21:21:43 +00:00
|
|
|
data.byte(kHavedoneobs) = 1;
|
|
|
|
} else if (type == 2) {
|
2011-08-11 10:33:33 +00:00
|
|
|
al = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
placefreeobject();
|
|
|
|
data.byte(kHavedoneobs) = 1;
|
|
|
|
} else if (type == 3) {
|
2011-08-11 10:33:33 +00:00
|
|
|
al = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
removefreeobject();
|
|
|
|
data.byte(kHavedoneobs) = 1;
|
|
|
|
} else if (type == 4) {
|
|
|
|
switchryanoff();
|
|
|
|
} else if (type == 5) {
|
2011-08-11 10:33:33 +00:00
|
|
|
data.byte(kTurntoface) = secondParam;
|
|
|
|
data.byte(kFacing) = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
switchryanon();
|
|
|
|
} else if (type == 6) {
|
2011-08-11 10:33:33 +00:00
|
|
|
data.byte(kNewlocation) = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
} else {
|
2011-08-16 23:16:05 +00:00
|
|
|
movemap(secondParam);
|
2011-07-30 21:21:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-30 21:37:18 +00:00
|
|
|
void DreamGenContext::plotreel() {
|
2011-08-15 11:49:11 +00:00
|
|
|
Reel *reel = getreelstart();
|
2011-11-15 21:30:31 +00:00
|
|
|
while (reel->x >= 220 && reel->x != 255) {
|
2011-08-11 10:33:33 +00:00
|
|
|
dealwithspecial(reel->x, reel->y);
|
2011-08-11 10:26:30 +00:00
|
|
|
++data.word(kReelpointer);
|
2011-08-03 16:11:19 +00:00
|
|
|
reel += 8;
|
2011-07-30 21:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 8; ++i) {
|
2011-08-11 10:26:30 +00:00
|
|
|
if (reel->frame() != 0xffff)
|
2011-08-03 16:11:19 +00:00
|
|
|
showreelframe(reel);
|
|
|
|
++reel;
|
2011-07-30 21:37:18 +00:00
|
|
|
}
|
2011-08-29 12:54:21 +00:00
|
|
|
push(es);
|
|
|
|
push(bx);
|
2011-07-30 21:37:18 +00:00
|
|
|
soundonreels();
|
2011-08-29 12:54:21 +00:00
|
|
|
bx = pop();
|
|
|
|
es = pop();
|
2011-07-30 21:37:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 11:54:03 +00:00
|
|
|
void DreamGenContext::crosshair() {
|
|
|
|
uint8 frame;
|
|
|
|
if ((data.byte(kCommandtype) != 3) && (data.byte(kCommandtype) < 10)) {
|
|
|
|
frame = 9;
|
|
|
|
} else {
|
|
|
|
frame = 29;
|
|
|
|
}
|
2011-08-11 10:26:30 +00:00
|
|
|
const Frame *src = (const Frame *)segRef(data.word(kIcons1)).ptr(0, 0);
|
2011-08-21 15:47:10 +00:00
|
|
|
showframe(src, kZoomx + 24, kZoomy + 19, frame, 0);
|
2011-08-03 11:54:03 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 14:19:27 +00:00
|
|
|
void DreamGenContext::deltextline() {
|
|
|
|
uint16 x = data.word(kTextaddressx);
|
|
|
|
uint16 y = data.word(kTextaddressy);
|
|
|
|
if (data.byte(kForeignrelease) != 0)
|
|
|
|
y -= 3;
|
2011-11-18 05:30:12 +00:00
|
|
|
multiput(textUnder(), x, y, kUndertextsizex, kUndertextsizey);
|
2011-08-03 14:19:27 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 22:35:10 +00:00
|
|
|
void DreamGenContext::commandonly() {
|
|
|
|
commandonly(al);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::commandonly(uint8 command) {
|
|
|
|
deltextline();
|
|
|
|
uint16 index = command * 2;
|
|
|
|
uint16 offset = kTextstart + segRef(data.word(kCommandtext)).word(index);
|
|
|
|
uint16 y = data.word(kTextaddressy);
|
|
|
|
const uint8 *string = segRef(data.word(kCommandtext)).ptr(offset, 0);
|
|
|
|
printdirect(&string, data.word(kTextaddressx), &y, data.byte(kTextlen), (bool)(data.byte(kTextlen) & 1));
|
|
|
|
data.byte(kNewtextline) = 1;
|
|
|
|
}
|
|
|
|
|
2011-08-11 21:13:17 +00:00
|
|
|
void DreamGenContext::checkifperson() {
|
2011-10-15 09:21:02 +00:00
|
|
|
flags._z = !checkifperson(al, ah);
|
2011-08-11 21:13:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::checkifperson(uint8 x, uint8 y) {
|
|
|
|
People *people = (People *)segRef(data.word(kBuffers)).ptr(kPeoplelist, 0);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < 12; ++i, ++people) {
|
|
|
|
if (people->b4 == 255)
|
|
|
|
continue;
|
2011-08-29 12:55:57 +00:00
|
|
|
data.word(kReelpointer) = people->reelPointer();
|
2011-08-15 11:49:11 +00:00
|
|
|
Reel *reel = getreelstart();
|
2011-08-11 21:13:17 +00:00
|
|
|
if (reel->frame() == 0xffff)
|
|
|
|
++reel;
|
|
|
|
const Frame *frame = getreelframeax(reel->frame());
|
|
|
|
uint8 xmin = reel->x + frame->x;
|
|
|
|
uint8 ymin = reel->y + frame->y;
|
|
|
|
uint8 xmax = xmin + frame->width;
|
|
|
|
uint8 ymax = ymin + frame->height;
|
|
|
|
if (x < xmin)
|
|
|
|
continue;
|
|
|
|
if (y < ymin)
|
|
|
|
continue;
|
|
|
|
if (x >= xmax)
|
|
|
|
continue;
|
|
|
|
if (y >= ymax)
|
|
|
|
continue;
|
2011-08-29 12:55:57 +00:00
|
|
|
data.word(kPersondata) = people->routinePointer();
|
2011-08-23 09:09:54 +00:00
|
|
|
obname(people->b4, 5);
|
2011-08-11 21:13:17 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-22 12:46:06 +00:00
|
|
|
void DreamGenContext::checkiffree() {
|
2011-10-15 09:21:02 +00:00
|
|
|
flags._z = !checkiffree(al, ah);
|
2011-08-22 12:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::checkiffree(uint8 x, uint8 y) {
|
|
|
|
const ObjPos *freeList = (const ObjPos *)segRef(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)
|
|
|
|
continue;
|
|
|
|
if (x < objPos->xMin)
|
|
|
|
continue;
|
|
|
|
if (x >= objPos->xMax)
|
|
|
|
continue;
|
|
|
|
if (y < objPos->yMin)
|
|
|
|
continue;
|
|
|
|
if (y >= objPos->yMax)
|
|
|
|
continue;
|
2011-08-23 09:09:54 +00:00
|
|
|
obname(objPos->index, 2);
|
2011-08-22 12:46:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-30 01:11:32 +00:00
|
|
|
void DreamGenContext::checkifex() {
|
2011-10-15 09:21:02 +00:00
|
|
|
flags._z = !checkifex(al, ah);
|
2011-08-30 01:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::checkifex(uint8 x, uint8 y) {
|
|
|
|
const ObjPos *exList = (const ObjPos *)segRef(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)
|
|
|
|
continue;
|
|
|
|
if (x < objPos->xMin)
|
|
|
|
continue;
|
|
|
|
if (x >= objPos->xMax)
|
|
|
|
continue;
|
|
|
|
if (y < objPos->yMin)
|
|
|
|
continue;
|
|
|
|
if (y >= objPos->yMax)
|
|
|
|
continue;
|
|
|
|
obname(objPos->index, 4);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-15 12:35:44 +00:00
|
|
|
const uint8 *DreamGenContext::findobname(uint8 type, uint8 index) {
|
2011-08-15 12:02:50 +00:00
|
|
|
if (type == 5) {
|
2011-08-15 12:35:44 +00:00
|
|
|
uint16 i = 64 * 2 * (index & 127);
|
|
|
|
uint16 offset = segRef(data.word(kPeople)).word(kPersontxtdat + i) + kPersontext;
|
|
|
|
return segRef(data.word(kPeople)).ptr(offset, 0);
|
2011-08-15 12:02:50 +00:00
|
|
|
} else if (type == 4) {
|
2011-08-15 12:35:44 +00:00
|
|
|
uint16 offset = segRef(data.word(kExtras)).word(kExtextdat + index * 2) + kExtext;
|
|
|
|
return segRef(data.word(kExtras)).ptr(offset, 0);
|
2011-08-15 12:02:50 +00:00
|
|
|
} else if (type == 2) {
|
2011-08-15 12:35:44 +00:00
|
|
|
uint16 offset = segRef(data.word(kFreedesc)).word(kFreetextdat + index * 2) + kFreetext;
|
|
|
|
return segRef(data.word(kFreedesc)).ptr(offset, 0);
|
2011-08-15 12:02:50 +00:00
|
|
|
} else if (type == 1) {
|
2011-08-15 12:35:44 +00:00
|
|
|
uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + index * 2) + kSettext;
|
|
|
|
return segRef(data.word(kSetdesc)).ptr(offset, 0);
|
2011-08-15 12:02:50 +00:00
|
|
|
} else {
|
2011-08-15 12:35:44 +00:00
|
|
|
uint16 offset = segRef(data.word(kBlockdesc)).word(kBlocktextdat + index * 2) + kBlocktext;
|
|
|
|
return segRef(data.word(kBlockdesc)).ptr(offset, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::copyname() {
|
|
|
|
copyname(ah, al, cs.ptr(di, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::copyname(uint8 type, uint8 index, uint8 *dst) {
|
|
|
|
const uint8 *src = findobname(type, index);
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < 28; ++i) {
|
|
|
|
char c = src[i];
|
|
|
|
if (c == ':')
|
|
|
|
break;
|
|
|
|
if (c == 0)
|
|
|
|
break;
|
|
|
|
dst[i] = c;
|
2011-08-15 12:02:50 +00:00
|
|
|
}
|
2011-08-15 12:35:44 +00:00
|
|
|
dst[i] = 0;
|
2011-08-15 12:02:50 +00:00
|
|
|
}
|
|
|
|
|
2011-08-15 13:42:09 +00:00
|
|
|
void DreamGenContext::commandwithob() {
|
|
|
|
commandwithob(al, bh, bl);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::commandwithob(uint8 command, uint8 type, uint8 index) {
|
|
|
|
uint8 commandLine[64] = "OBJECT NAME ONE ";
|
|
|
|
deltextline();
|
|
|
|
uint16 commandText = kTextstart + segRef(data.word(kCommandtext)).word(command * 2);
|
|
|
|
uint8 textLen = data.byte(kTextlen);
|
|
|
|
{
|
|
|
|
const uint8 *string = segRef(data.word(kCommandtext)).ptr(commandText, 0);
|
2011-09-07 01:58:04 +00:00
|
|
|
printdirect(string, data.word(kTextaddressx), data.word(kTextaddressy), textLen, (bool)(textLen & 1));
|
2011-08-15 13:42:09 +00:00
|
|
|
}
|
|
|
|
copyname(type, index, commandLine);
|
|
|
|
uint16 x = data.word(kLastxpos);
|
|
|
|
if (command != 0)
|
|
|
|
x += 5;
|
2011-09-07 01:58:04 +00:00
|
|
|
printdirect(commandLine, x, data.word(kTextaddressy), textLen, (bool)(textLen & 1));
|
2011-08-15 13:42:09 +00:00
|
|
|
data.byte(kNewtextline) = 1;
|
|
|
|
}
|
|
|
|
|
2011-09-04 05:44:14 +00:00
|
|
|
void DreamGenContext::examineobtext() {
|
|
|
|
commandwithob(1, data.byte(kCommandtype), data.byte(kCommand));
|
|
|
|
}
|
|
|
|
|
2011-08-15 15:00:20 +00:00
|
|
|
void DreamGenContext::showpanel() {
|
|
|
|
Frame *frame = (Frame *)segRef(data.word(kIcons1)).ptr(0, sizeof(Frame));
|
2011-08-21 15:47:10 +00:00
|
|
|
showframe(frame, 72, 0, 19, 0);
|
|
|
|
showframe(frame, 192, 0, 19, 0);
|
2011-08-15 15:00:20 +00:00
|
|
|
}
|
|
|
|
|
2011-08-18 20:09:28 +00:00
|
|
|
void DreamGenContext::blocknametext() {
|
|
|
|
commandwithob(0, data.byte(kCommandtype), data.byte(kCommand));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::personnametext() {
|
|
|
|
commandwithob(2, data.byte(kCommandtype), data.byte(kCommand) & 127);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::walktotext() {
|
|
|
|
commandwithob(3, data.byte(kCommandtype), data.byte(kCommand));
|
|
|
|
}
|
|
|
|
|
2011-08-19 08:35:29 +00:00
|
|
|
void DreamGenContext::findormake() {
|
|
|
|
uint8 b0 = al;
|
|
|
|
uint8 b2 = cl;
|
|
|
|
uint8 b3 = ch;
|
|
|
|
findormake(b0, b2, b3);
|
|
|
|
}
|
|
|
|
|
2011-08-20 10:26:10 +00:00
|
|
|
void DreamGenContext::findormake(uint8 index, uint8 value, uint8 type) {
|
2011-08-19 08:35:29 +00:00
|
|
|
Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change));
|
2011-11-15 21:30:31 +00:00
|
|
|
for (; change->index != 0xff; ++change) {
|
|
|
|
if (index == change->index && data.byte(kReallocation) == change->location && type == change->type) {
|
2011-08-20 10:26:10 +00:00
|
|
|
change->value = value;
|
2011-08-19 08:35:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-11-15 21:30:31 +00:00
|
|
|
|
|
|
|
change->index = index;
|
|
|
|
change->location = data.byte(kReallocation);
|
|
|
|
change->value = value;
|
|
|
|
change->type = type;
|
2011-08-19 08:35:29 +00:00
|
|
|
}
|
|
|
|
|
2011-08-19 09:42:13 +00:00
|
|
|
void DreamGenContext::setallchanges() {
|
|
|
|
Change *change = (Change *)segRef(data.word(kBuffers)).ptr(kListofchanges, sizeof(Change));
|
2011-11-15 21:30:31 +00:00
|
|
|
for (; change->index != 0xff; ++change)
|
2011-08-20 10:26:10 +00:00
|
|
|
if (change->location == data.byte(kReallocation))
|
|
|
|
dochange(change->index, change->value, change->type);
|
2011-08-19 09:42:13 +00:00
|
|
|
}
|
|
|
|
|
2011-08-23 12:41:28 +00:00
|
|
|
DynObject *DreamGenContext::getfreead(uint8 index) {
|
|
|
|
return (DynObject *)segRef(data.word(kFreedat)).ptr(0, 0) + index;
|
2011-08-20 10:26:10 +00:00
|
|
|
}
|
|
|
|
|
2011-08-23 12:41:28 +00:00
|
|
|
DynObject *DreamGenContext::getexad(uint8 index) {
|
|
|
|
return (DynObject *)segRef(data.word(kExtras)).ptr(kExdata, 0) + index;
|
2011-08-23 12:35:24 +00:00
|
|
|
}
|
|
|
|
|
2011-08-23 13:03:28 +00:00
|
|
|
DynObject *DreamGenContext::geteitheradCPP() {
|
|
|
|
if (data.byte(kObjecttype) == 4)
|
|
|
|
return getexad(data.byte(kItemframe));
|
|
|
|
else
|
|
|
|
return getfreead(data.byte(kItemframe));
|
|
|
|
}
|
|
|
|
|
2011-08-31 21:38:34 +00:00
|
|
|
void *DreamGenContext::getanyad(uint8 *value1, uint8 *value2) {
|
2011-08-31 09:24:34 +00:00
|
|
|
if (data.byte(kObjecttype) == 4) {
|
|
|
|
DynObject *exObject = getexad(data.byte(kCommand));
|
2011-08-31 21:38:34 +00:00
|
|
|
*value1 = exObject->b7;
|
|
|
|
*value2 = exObject->b8;
|
2011-08-31 09:24:34 +00:00
|
|
|
return exObject;
|
|
|
|
} else if (data.byte(kObjecttype) == 2) {
|
|
|
|
DynObject *freeObject = getfreead(data.byte(kCommand));
|
2011-08-31 21:38:34 +00:00
|
|
|
*value1 = freeObject->b7;
|
|
|
|
*value2 = freeObject->b8;
|
2011-08-31 09:24:34 +00:00
|
|
|
return freeObject;
|
|
|
|
} else {
|
|
|
|
SetObject *setObject = getsetad(data.byte(kCommand));
|
2011-08-31 21:38:34 +00:00
|
|
|
*value1 = setObject->b4;
|
|
|
|
*value2 = setObject->priority;
|
2011-08-31 09:24:34 +00:00
|
|
|
return setObject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:11:07 +00:00
|
|
|
void *DreamGenContext::getanyaddir(uint8 index, uint8 flag) {
|
|
|
|
if (flag == 4)
|
|
|
|
return getexad(index);
|
|
|
|
else if (flag == 2)
|
|
|
|
return getfreead(index);
|
|
|
|
else
|
|
|
|
return getsetad(index);
|
|
|
|
}
|
|
|
|
|
2011-08-23 12:41:28 +00:00
|
|
|
SetObject *DreamGenContext::getsetad(uint8 index) {
|
|
|
|
return (SetObject *)segRef(data.word(kSetdat)).ptr(0, 0) + index;
|
2011-08-20 10:26:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::dochange(uint8 index, uint8 value, uint8 type) {
|
|
|
|
if (type == 0) { //object
|
2011-08-30 01:26:19 +00:00
|
|
|
getsetad(index)->mapad[0] = value;
|
2011-08-20 10:26:10 +00:00
|
|
|
} else if (type == 1) { //freeobject
|
2011-08-23 12:41:28 +00:00
|
|
|
DynObject *freeObject = getfreead(index);
|
2011-08-30 01:26:19 +00:00
|
|
|
if (freeObject->mapad[0] == 0xff)
|
|
|
|
freeObject->mapad[0] = value;
|
2011-08-20 10:26:10 +00:00
|
|
|
} else { //path
|
|
|
|
bx = kPathdata + (type - 100) * 144 + index * 8;
|
|
|
|
es = data.word(kReels);
|
|
|
|
es.byte(bx+6) = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-20 10:33:21 +00:00
|
|
|
void DreamGenContext::deletetaken() {
|
2011-08-23 12:41:28 +00:00
|
|
|
const DynObject *extraObjects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, 0);
|
|
|
|
DynObject *freeObjects = (DynObject *)segRef(data.word(kFreedat)).ptr(0, 0);
|
2011-08-20 10:33:21 +00:00
|
|
|
for(size_t i = 0; i < kNumexobjects; ++i) {
|
2011-08-30 00:18:55 +00:00
|
|
|
uint8 location = extraObjects[i].initialLocation;
|
2011-08-20 10:33:21 +00:00
|
|
|
if (location == data.byte(kReallocation)) {
|
2011-08-23 12:41:28 +00:00
|
|
|
uint8 index = extraObjects[i].index;
|
2011-08-30 01:26:19 +00:00
|
|
|
freeObjects[index].mapad[0] = 0xfe;
|
2011-08-20 10:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-30 00:26:28 +00:00
|
|
|
void DreamGenContext::getexpos() {
|
2011-09-01 22:24:29 +00:00
|
|
|
es = data.word(kExtras);
|
2011-08-30 00:26:28 +00:00
|
|
|
const DynObject *objects = (const DynObject *)segRef(data.word(kExtras)).ptr(kExdata, sizeof(DynObject));
|
|
|
|
for (size_t i = 0; i < kNumexobjects; ++i) {
|
2011-08-30 01:26:19 +00:00
|
|
|
if (objects[i].mapad[0] == 0xff) {
|
2011-09-01 23:05:32 +00:00
|
|
|
data.byte(kExpos) = i;
|
2011-09-01 22:24:29 +00:00
|
|
|
di = kExdata + i * sizeof(DynObject);
|
2011-08-30 00:26:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-09-01 23:05:32 +00:00
|
|
|
data.byte(kExpos) = kNumexobjects;
|
2011-09-01 22:24:29 +00:00
|
|
|
di = kExdata + kNumexobjects * sizeof(DynObject);
|
2011-08-30 00:26:28 +00:00
|
|
|
}
|
|
|
|
|
2011-08-20 11:23:47 +00:00
|
|
|
void DreamGenContext::placesetobject() {
|
|
|
|
placesetobject(al);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::placesetobject(uint8 index) {
|
|
|
|
findormake(index, 0, 0);
|
2011-08-30 01:26:19 +00:00
|
|
|
getsetad(index)->mapad[0] = 0;
|
2011-08-20 11:23:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::removesetobject() {
|
|
|
|
removesetobject(al);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::removesetobject(uint8 index) {
|
|
|
|
findormake(index, 0xff, 0);
|
2011-08-30 01:26:19 +00:00
|
|
|
getsetad(index)->mapad[0] = 0xff;
|
2011-08-20 11:23:47 +00:00
|
|
|
}
|
|
|
|
|
2011-08-22 13:53:54 +00:00
|
|
|
void DreamGenContext::finishedwalking() {
|
|
|
|
flags._z = finishedwalkingCPP();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::finishedwalkingCPP() {
|
|
|
|
return (data.byte(kLinepointer) == 254) && (data.byte(kFacing) == data.byte(kTurntoface));
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:13:10 +00:00
|
|
|
void DreamGenContext::getflagunderp() {
|
|
|
|
uint8 flag, flagEx;
|
|
|
|
getflagunderp(&flag, &flagEx);
|
|
|
|
cl = flag;
|
|
|
|
ch = flagEx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::getflagunderp(uint8 *flag, uint8 *flagEx) {
|
|
|
|
uint8 type, flagX, flagY;
|
|
|
|
checkone(data.word(kMousex) - data.word(kMapadx), data.word(kMousey) - data.word(kMapady), flag, flagEx, &type, &flagX, &flagY);
|
|
|
|
cl = data.byte(kLastflag) = *flag;
|
|
|
|
ch = data.byte(kLastflagex) = *flagEx;
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:40:52 +00:00
|
|
|
void DreamGenContext::walkandexamine() {
|
2011-11-15 21:30:31 +00:00
|
|
|
if (!finishedwalkingCPP())
|
2011-08-23 08:40:52 +00:00
|
|
|
return;
|
|
|
|
data.byte(kCommandtype) = data.byte(kWalkexamtype);
|
|
|
|
data.byte(kCommand) = data.byte(kWalkexamnum);
|
|
|
|
data.byte(kWalkandexam) = 0;
|
|
|
|
if (data.byte(kCommandtype) != 5)
|
|
|
|
examineob();
|
|
|
|
}
|
|
|
|
|
2011-08-23 09:09:54 +00:00
|
|
|
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))) {
|
|
|
|
if (data.byte(kWalkandexam) == 1) {
|
|
|
|
walkandexamine();
|
|
|
|
return;
|
|
|
|
} else if (data.word(kMousebutton) == 0)
|
|
|
|
return;
|
|
|
|
else if ((data.byte(kCommandtype) == 3) && (data.byte(kLastflag) < 2))
|
|
|
|
return;
|
|
|
|
else if ((data.byte(kManspath) != data.byte(kPointerspath)) || (data.byte(kCommandtype) == 3)) {
|
|
|
|
setwalk();
|
|
|
|
data.byte(kReasseschanges) = 1;
|
|
|
|
return;
|
|
|
|
} else if (! finishedwalkingCPP())
|
|
|
|
return;
|
|
|
|
else if (data.byte(kCommandtype) == 5) {
|
|
|
|
if (data.word(kWatchingtime) == 0)
|
|
|
|
talk();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (data.word(kWatchingtime) == 0)
|
|
|
|
examineob();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
data.byte(kReasseschanges) = 0;
|
|
|
|
|
|
|
|
data.byte(kCommand) = command;
|
|
|
|
data.byte(kCommandtype) = commandType;
|
|
|
|
if ((data.byte(kLinepointer) != 254) || (data.word(kWatchingtime) != 0) || (data.byte(kFacing) != data.byte(kTurntoface))) {
|
|
|
|
blocknametext();
|
|
|
|
return;
|
|
|
|
} else if (data.byte(kCommandtype) != 3) {
|
|
|
|
if (data.byte(kManspath) != data.byte(kPointerspath)) {
|
|
|
|
walktotext();
|
|
|
|
return;
|
|
|
|
} else if (data.byte(kCommandtype) == 3) {
|
|
|
|
blocknametext();
|
|
|
|
return;
|
|
|
|
} else if (data.byte(kCommandtype) == 5) {
|
|
|
|
personnametext();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
examineobtext();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data.byte(kManspath) == data.byte(kPointerspath)) {
|
|
|
|
uint8 flag, flagEx, type, flagX, flagY;
|
|
|
|
checkone(data.byte(kRyanx) + 12, data.byte(kRyany) + 12, &flag, &flagEx, &type, &flagX, &flagY);
|
|
|
|
if (flag < 2) {
|
|
|
|
blocknametext();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getflagunderp();
|
|
|
|
if (data.byte(kLastflag) < 2) {
|
|
|
|
blocknametext();
|
|
|
|
return;
|
|
|
|
} else if (data.byte(kLastflag) >= 128) {
|
|
|
|
blocknametext();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
walktotext();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 10:15:17 +00:00
|
|
|
void DreamGenContext::delpointer() {
|
|
|
|
if (data.word(kOldpointerx) == 0xffff)
|
|
|
|
return;
|
|
|
|
data.word(kDelherex) = data.word(kOldpointerx);
|
|
|
|
data.word(kDelherey) = data.word(kOldpointery);
|
|
|
|
data.byte(kDelxs) = data.byte(kPointerxs);
|
|
|
|
data.byte(kDelys) = data.byte(kPointerys);
|
|
|
|
multiput(segRef(data.word(kBuffers)).ptr(kPointerback, 0), data.word(kDelherex), data.word(kDelherey), data.byte(kPointerxs), data.byte(kPointerys));
|
|
|
|
}
|
|
|
|
|
2011-08-24 11:20:18 +00:00
|
|
|
void DreamGenContext::showblink() {
|
|
|
|
if (data.byte(kManisoffscreen) == 1)
|
|
|
|
return;
|
|
|
|
++data.byte(kBlinkcount);
|
|
|
|
if (data.byte(kShadeson) != 0)
|
|
|
|
return;
|
|
|
|
if (data.byte(kReallocation) >= 50) // eyesshut
|
|
|
|
return;
|
|
|
|
if (data.byte(kBlinkcount) != 3)
|
|
|
|
return;
|
|
|
|
data.byte(kBlinkcount) = 0;
|
|
|
|
uint8 blinkFrame = data.byte(kBlinkframe);
|
|
|
|
++blinkFrame; // Implicit %256
|
|
|
|
data.byte(kBlinkframe) = blinkFrame;
|
|
|
|
if (blinkFrame > 6)
|
|
|
|
blinkFrame = 6;
|
|
|
|
static const uint8 blinkTab[] = { 16,18,18,17,16,16,16 };
|
|
|
|
uint8 width, height;
|
|
|
|
showframe((Frame *)segRef(data.word(kIcons1)).ptr(0, 0), 44, 32, blinkTab[blinkFrame], 0, &width, &height);
|
|
|
|
}
|
|
|
|
|
2011-08-24 11:22:11 +00:00
|
|
|
void DreamGenContext::dumpblink() {
|
|
|
|
if (data.byte(kShadeson) != 0)
|
|
|
|
return;
|
|
|
|
if (data.byte(kBlinkcount) != 0)
|
|
|
|
return;
|
|
|
|
if (data.byte(kBlinkframe) >= 6)
|
|
|
|
return;
|
|
|
|
multidump(44, 32, 16, 12);
|
|
|
|
}
|
|
|
|
|
2011-08-24 15:23:43 +00:00
|
|
|
void DreamGenContext::dumppointer() {
|
|
|
|
dumpblink();
|
|
|
|
multidump(data.word(kDelherex), data.word(kDelherey), data.byte(kDelxs), data.byte(kDelys));
|
|
|
|
if ((data.word(kOldpointerx) != data.word(kDelherex)) || (data.word(kOldpointery) != data.word(kDelherey)))
|
|
|
|
multidump(data.word(kOldpointerx), data.word(kOldpointery), data.byte(kPointerxs), data.byte(kPointerys));
|
|
|
|
}
|
|
|
|
|
2011-08-24 13:04:53 +00:00
|
|
|
void DreamGenContext::checkcoords() {
|
2011-11-14 20:38:40 +00:00
|
|
|
|
|
|
|
// 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");
|
|
|
|
}
|
2011-08-24 13:04:53 +00:00
|
|
|
}
|
|
|
|
|
2011-11-14 20:38:40 +00:00
|
|
|
|
2011-08-24 13:04:53 +00:00
|
|
|
void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) {
|
|
|
|
if (data.byte(kNewlocation) != 0xff)
|
|
|
|
return;
|
|
|
|
|
2011-11-14 20:38:40 +00:00
|
|
|
const RectWithCallback *r;
|
|
|
|
for (r = rectWithCallbacks; r->_xMin != 0xffff; ++r) {
|
|
|
|
if (r->contains(data.word(kMousex), data.word(kMousey))) {
|
|
|
|
(this->*(r->_callback))();
|
2011-08-24 13:04:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-14 20:38:40 +00:00
|
|
|
|
2011-08-24 21:01:53 +00:00
|
|
|
void DreamGenContext::showpointer() {
|
|
|
|
showblink();
|
|
|
|
const Frame *icons1 = ((const Frame *)segRef(data.word(kIcons1)).ptr(0, 0));
|
|
|
|
uint16 x = data.word(kMousex);
|
|
|
|
data.word(kOldpointerx) = data.word(kMousex);
|
|
|
|
uint16 y = data.word(kMousey);
|
|
|
|
data.word(kOldpointery) = data.word(kMousey);
|
|
|
|
if (data.byte(kPickup) == 1) {
|
|
|
|
const Frame *frames;
|
|
|
|
if (data.byte(kObjecttype) != 4)
|
|
|
|
frames = (const Frame *)segRef(data.word(kFreeframes)).ptr(0, 0);
|
|
|
|
else
|
|
|
|
frames = (const Frame *)segRef(data.word(kExtras)).ptr(0, 0);
|
|
|
|
const Frame *frame = frames + (3 * data.byte(kItemframe) + 1);
|
|
|
|
uint8 width = frame->width;
|
|
|
|
uint8 height = frame->height;
|
|
|
|
if (width < 12)
|
|
|
|
width = 12;
|
|
|
|
if (height < 12)
|
|
|
|
height = 12;
|
|
|
|
data.byte(kPointerxs) = width;
|
|
|
|
data.byte(kPointerys) = height;
|
2011-08-31 23:27:59 +00:00
|
|
|
uint16 xMin = (x >= width / 2) ? x - width / 2 : 0;
|
|
|
|
uint16 yMin = (y >= height / 2) ? y - height / 2 : 0;
|
|
|
|
data.word(kOldpointerx) = xMin;
|
|
|
|
data.word(kOldpointery) = yMin;
|
|
|
|
multiget(segRef(data.word(kBuffers)).ptr(kPointerback, 0), xMin, yMin, width, height);
|
2011-08-24 21:01:53 +00:00
|
|
|
showframe(frames, x, y, 3 * data.byte(kItemframe) + 1, 128);
|
|
|
|
showframe(icons1, x, y, 3, 128);
|
|
|
|
} else {
|
|
|
|
const Frame *frame = icons1 + (data.byte(kPointerframe) + 20);
|
|
|
|
uint8 width = frame->width;
|
|
|
|
uint8 height = frame->height;
|
|
|
|
if (width < 12)
|
|
|
|
width = 12;
|
|
|
|
if (height < 12)
|
|
|
|
height = 12;
|
|
|
|
data.byte(kPointerxs) = width;
|
|
|
|
data.byte(kPointerys) = height;
|
|
|
|
multiget(segRef(data.word(kBuffers)).ptr(kPointerback, 0), x, y, width, height);
|
|
|
|
showframe(icons1, x, y, data.byte(kPointerframe) + 20, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-25 05:02:57 +00:00
|
|
|
void DreamGenContext::animpointer() {
|
|
|
|
|
|
|
|
if (data.byte(kPointermode) == 2) {
|
|
|
|
data.byte(kPointerframe) = 0;
|
|
|
|
if ((data.byte(kReallocation) == 14) && (data.byte(kCommandtype) == 211))
|
|
|
|
data.byte(kPointerframe) = 5;
|
|
|
|
return;
|
|
|
|
} else if (data.byte(kPointermode) == 3) {
|
|
|
|
if (data.byte(kPointerspeed) != 0) {
|
|
|
|
--data.byte(kPointerspeed);
|
|
|
|
} else {
|
|
|
|
data.byte(kPointerspeed) = 5;
|
|
|
|
++data.byte(kPointercount);
|
|
|
|
if (data.byte(kPointercount) == 16)
|
|
|
|
data.byte(kPointercount) = 0;
|
|
|
|
}
|
|
|
|
static const uint8 flashMouseTab[] = { 1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2 };
|
|
|
|
data.byte(kPointerframe) = flashMouseTab[data.byte(kPointercount)];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (data.word(kWatchingtime) != 0) {
|
|
|
|
data.byte(kPointerframe) = 11;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data.byte(kPointerframe) = 0;
|
|
|
|
if (data.byte(kInmaparea) == 0)
|
|
|
|
return;
|
|
|
|
if (data.byte(kPointerfirstpath) == 0)
|
|
|
|
return;
|
|
|
|
uint8 flag, flagEx;
|
|
|
|
getflagunderp(&flag, &flagEx);
|
|
|
|
if (flag < 2)
|
|
|
|
return;
|
|
|
|
if (flag >= 128)
|
|
|
|
return;
|
|
|
|
if (flag & 4) {
|
|
|
|
data.byte(kPointerframe) = 3;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (flag & 16) {
|
|
|
|
data.byte(kPointerframe) = 4;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (flag & 2) {
|
|
|
|
data.byte(kPointerframe) = 5;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (flag & 8) {
|
|
|
|
data.byte(kPointerframe) = 6;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data.byte(kPointerframe) = 8;
|
|
|
|
}
|
|
|
|
|
2011-08-29 09:55:21 +00:00
|
|
|
void DreamGenContext::printmessage() {
|
|
|
|
printmessage(di, bx, al, dl, (bool)(dl & 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::printmessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered) {
|
|
|
|
uint16 offset = kTextstart + segRef(data.word(kCommandtext)).word(index * 2);
|
|
|
|
const uint8 *string = segRef(data.word(kCommandtext)).ptr(offset, 0);
|
|
|
|
printdirect(&string, x, &y, maxWidth, centered);
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:06:30 +00:00
|
|
|
void DreamGenContext::compare() {
|
|
|
|
char id[4] = { cl, ch, dl, dh };
|
|
|
|
flags._z = compare(al, ah, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) {
|
|
|
|
void *ptr = getanyaddir(index, flag);
|
|
|
|
const char *objId = (const char *)(((const uint8 *)ptr) + 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;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-02 01:55:52 +00:00
|
|
|
bool DreamGenContext::isitdescribed(const ObjPos *pos) {
|
2011-09-01 23:49:14 +00:00
|
|
|
uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + pos->index * 2);
|
|
|
|
uint8 result = segRef(data.word(kSetdesc)).byte(kSettext + offset);
|
|
|
|
return result != 0;
|
|
|
|
}
|
|
|
|
|
2011-08-16 01:15:43 +00:00
|
|
|
bool DreamGenContext::isCD() {
|
|
|
|
// The original sources has two codepaths depending if the game is 'if cd' or not
|
|
|
|
// This is a hack to guess which version to use with the assumption that if we have a cd version
|
|
|
|
// we managed to load the speech. At least it is isolated in this function and can be changed.
|
|
|
|
// Maybe detect the version during game id?
|
|
|
|
return (data.byte(kSpeechloaded) == 1);
|
|
|
|
}
|
2011-09-02 01:55:52 +00:00
|
|
|
|
2011-11-05 13:13:57 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-02 01:55:52 +00:00
|
|
|
void DreamGenContext::checkifset() {
|
|
|
|
flags._z = !checkifset(al, ah);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DreamGenContext::checkifset(uint8 x, uint8 y) {
|
|
|
|
const ObjPos *setList = (const ObjPos *)segRef(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)
|
|
|
|
continue;
|
|
|
|
if (x < pos->xMin)
|
|
|
|
continue;
|
|
|
|
if (x >= pos->xMax)
|
|
|
|
continue;
|
|
|
|
if (y < pos->yMin)
|
|
|
|
continue;
|
|
|
|
if (y >= pos->yMax)
|
|
|
|
continue;
|
|
|
|
if (! pixelcheckset(pos, x, y))
|
|
|
|
continue;
|
|
|
|
if (! isitdescribed(pos))
|
|
|
|
continue;
|
|
|
|
obname(pos->index, 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-05 18:45:41 +00:00
|
|
|
void DreamGenContext::showryanpage() {
|
|
|
|
Frame *icons1 = (Frame *)segRef(data.word(kIcons1)).ptr(0, 0);
|
|
|
|
showframe(icons1, kInventx + 167, kInventy - 12, 12, 0);
|
|
|
|
showframe(icons1, kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0);
|
|
|
|
}
|
|
|
|
|
2011-09-05 19:42:06 +00:00
|
|
|
void DreamGenContext::findallryan() {
|
|
|
|
findallryan(es.ptr(di, 60));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::findallryan(uint8 *inv) {
|
|
|
|
memset(inv, 0xff, 60);
|
|
|
|
for (size_t i = 0; i < kNumexobjects; ++i) {
|
|
|
|
DynObject *extra = getexad(i);
|
|
|
|
if (extra->mapad[0] != 4)
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-06 20:10:02 +00:00
|
|
|
void DreamGenContext::hangon() {
|
|
|
|
hangon(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::hangon(uint16 frameCount) {
|
|
|
|
while (frameCount) {
|
|
|
|
vsync();
|
|
|
|
--frameCount;
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-09-08 07:11:16 +00:00
|
|
|
break;
|
2011-09-06 20:10:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-26 16:13:44 +00:00
|
|
|
|
|
|
|
void DreamGenContext::hangonw() {
|
|
|
|
hangonw(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::hangonw(uint16 frameCount) {
|
|
|
|
while (frameCount) {
|
|
|
|
delpointer();
|
|
|
|
readmouse();
|
|
|
|
animpointer();
|
|
|
|
showpointer();
|
|
|
|
vsync();
|
|
|
|
dumppointer();
|
|
|
|
--frameCount;
|
|
|
|
if (quitRequested())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-06 20:10:02 +00:00
|
|
|
void DreamGenContext::hangonp() {
|
|
|
|
hangonp(cx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::hangonp(uint16 count) {
|
|
|
|
data.word(kMaintimer) = 0;
|
|
|
|
uint8 pointerFrame = data.byte(kPointerframe);
|
|
|
|
uint8 pickup = data.byte(kPickup);
|
|
|
|
data.byte(kPointermode) = 3;
|
|
|
|
data.byte(kPickup) = 0;
|
|
|
|
data.byte(kCommandtype) = 255;
|
|
|
|
readmouse();
|
|
|
|
animpointer();
|
|
|
|
showpointer();
|
|
|
|
vsync();
|
|
|
|
dumppointer();
|
2011-11-19 17:35:47 +00:00
|
|
|
|
|
|
|
count *= 3;
|
|
|
|
for (uint16 i = 0; i < count; ++i) {
|
2011-09-06 20:10:02 +00:00
|
|
|
delpointer();
|
|
|
|
readmouse();
|
|
|
|
animpointer();
|
|
|
|
showpointer();
|
|
|
|
vsync();
|
|
|
|
dumppointer();
|
2011-11-20 20:26:18 +00:00
|
|
|
if (quitRequested())
|
2011-09-08 07:11:16 +00:00
|
|
|
break;
|
2011-11-19 17:35:47 +00:00
|
|
|
if (data.word(kMousebutton) != 0 && data.word(kMousebutton) != data.word(kOldbutton))
|
2011-09-06 20:10:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
delpointer();
|
|
|
|
data.byte(kPointerframe) = pointerFrame;
|
|
|
|
data.byte(kPickup) = pickup;
|
|
|
|
data.byte(kPointermode) = 0;
|
|
|
|
}
|
|
|
|
|
2011-09-07 01:41:05 +00:00
|
|
|
void DreamGenContext::findnextcolon() {
|
|
|
|
uint8 *initialString = es.ptr(si, 0);
|
|
|
|
uint8 *string = initialString;
|
|
|
|
al = findnextcolon(&string);
|
|
|
|
si += (string - initialString);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 DreamGenContext::findnextcolon(uint8 **string) {
|
|
|
|
uint8 c;
|
|
|
|
do {
|
|
|
|
c = **string;
|
|
|
|
++(*string);
|
|
|
|
} while ((c != 0) && (c != ':'));
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2011-09-07 01:44:40 +00:00
|
|
|
uint8 *DreamGenContext::getobtextstartCPP() {
|
|
|
|
push(es);
|
|
|
|
push(si);
|
|
|
|
getobtextstart();
|
|
|
|
uint8 *result = es.ptr(si, 0);
|
|
|
|
si = pop();
|
|
|
|
es = pop();
|
|
|
|
return result;
|
|
|
|
}
|
2011-09-07 01:41:05 +00:00
|
|
|
|
2011-10-09 15:22:41 +00:00
|
|
|
void DreamGenContext::zoomonoff() {
|
|
|
|
if (data.word(kWatchingtime) != 0) {
|
|
|
|
blank();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (data.byte(kPointermode) == 2) {
|
|
|
|
blank();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (data.byte(kCommandtype) != 222) {
|
|
|
|
data.byte(kCommandtype) = 222;
|
|
|
|
commandonly(39);
|
|
|
|
}
|
|
|
|
if (data.word(kMousebutton) == data.word(kOldbutton))
|
|
|
|
return;
|
|
|
|
if ((data.word(kMousebutton) & 1) == 0)
|
|
|
|
return;
|
|
|
|
data.byte(kZoomon) ^= 1;
|
|
|
|
createpanel();
|
|
|
|
data.byte(kNewobs) = 0;
|
|
|
|
drawfloor();
|
|
|
|
printsprites();
|
|
|
|
reelsonscreen();
|
|
|
|
showicon();
|
|
|
|
getunderzoom();
|
|
|
|
undertextline();
|
|
|
|
commandonly(39);
|
|
|
|
readmouse();
|
|
|
|
worktoscreenm();
|
|
|
|
}
|
|
|
|
|
2011-09-04 10:44:05 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-04 11:20:02 +00:00
|
|
|
void DreamGenContext::showcity() {
|
|
|
|
clearwork();
|
2011-11-20 13:06:48 +00:00
|
|
|
showframe(tempGraphics(), 57, 32, 0, 0);
|
|
|
|
showframe(tempGraphics(), 120+57, 32, 1, 0);
|
2011-09-04 11:20:02 +00:00
|
|
|
}
|
|
|
|
|
2011-11-14 19:18:06 +00:00
|
|
|
void DreamGenContext::mainscreen() {
|
|
|
|
data.byte(kInmaparea) = 0;
|
2011-11-14 19:18:18 +00:00
|
|
|
if (data.byte(kWatchon) == 1) {
|
2011-11-14 20:38:40 +00:00
|
|
|
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);
|
2011-11-14 19:18:18 +00:00
|
|
|
} else {
|
2011-11-14 20:38:40 +00:00
|
|
|
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);
|
2011-11-14 19:18:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data.byte(kWalkandexam) != 0)
|
|
|
|
walkandexamine();
|
2011-11-14 19:18:06 +00:00
|
|
|
}
|
|
|
|
|
2011-11-15 10:05:30 +00:00
|
|
|
void DreamGenContext::showwatch() {
|
|
|
|
if (data.byte(kWatchon)) {
|
|
|
|
showframe((Frame *)segRef(data.word(kIcons1)).ptr(0, 0), 250, 1, 6, 0);
|
|
|
|
showtime();
|
|
|
|
}
|
|
|
|
}
|
2011-11-14 19:18:06 +00:00
|
|
|
|
2011-11-20 18:04:33 +00:00
|
|
|
void DreamGenContext::dumpwatch() {
|
|
|
|
if (data.byte(kWatchdump) != 1)
|
|
|
|
return;
|
|
|
|
multidump(256, 21, 40, 12);
|
|
|
|
data.byte(kWatchdump) = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-16 23:18:28 +00:00
|
|
|
void DreamGenContext::showtime() {
|
|
|
|
if (data.byte(kWatchon) == 0)
|
|
|
|
return;
|
|
|
|
Frame *charset = (Frame *)segRef(data.word(kCharset1)).ptr(0, 0);
|
|
|
|
|
2011-11-16 22:09:39 +00:00
|
|
|
int seconds = data.byte(kSecondcount);
|
|
|
|
int minutes = data.byte(kMinutecount);
|
|
|
|
int hours = data.byte(kHourcount);
|
|
|
|
|
|
|
|
showframe(charset, 282+5, 21, 91*3+10 + seconds / 10, 0);
|
|
|
|
showframe(charset, 282+9, 21, 91*3+10 + seconds % 10, 0);
|
|
|
|
|
|
|
|
showframe(charset, 270+5, 21, 91*3 + minutes / 10, 0);
|
|
|
|
showframe(charset, 270+11, 21, 91*3 + minutes % 10, 0);
|
|
|
|
|
|
|
|
showframe(charset, 256+5, 21, 91*3 + hours / 10, 0);
|
|
|
|
showframe(charset, 256+11, 21, 91*3 + hours % 10, 0);
|
2011-11-16 23:18:28 +00:00
|
|
|
|
|
|
|
showframe(charset, 267+5, 21, 91*3+20, 0);
|
|
|
|
}
|
|
|
|
|
2011-11-16 19:09:47 +00:00
|
|
|
void DreamGenContext::watchcount() {
|
|
|
|
if (data.byte(kWatchon) == 0)
|
|
|
|
return;
|
|
|
|
++data.byte(kTimercount);
|
|
|
|
if (data.byte(kTimercount) == 9) {
|
|
|
|
showframe((Frame *)segRef(data.word(kCharset1)).ptr(0, 0), 268+4, 21, 91*3+21, 0);
|
|
|
|
data.byte(kWatchdump) = 1;
|
|
|
|
} else if (data.byte(kTimercount) == 18) {
|
|
|
|
data.byte(kTimercount) = 0;
|
|
|
|
++data.byte(kSecondcount);
|
|
|
|
if (data.byte(kSecondcount) == 60) {
|
|
|
|
data.byte(kSecondcount) = 0;
|
|
|
|
++data.byte(kMinutecount);
|
|
|
|
if (data.byte(kMinutecount) == 60) {
|
|
|
|
data.byte(kMinutecount) = 0;
|
|
|
|
++data.byte(kHourcount);
|
|
|
|
if (data.byte(kHourcount) == 24)
|
|
|
|
data.byte(kHourcount) = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
showtime();
|
|
|
|
data.byte(kWatchdump) = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-14 18:49:19 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2011-11-16 20:00:46 +00:00
|
|
|
void DreamGenContext::zoomicon() {
|
|
|
|
if (data.byte(kZoomon) == 0)
|
|
|
|
return;
|
|
|
|
showframe((Frame *)segRef(data.word(kIcons1)).ptr(0, 0), kZoomx, kZoomy-1, 8, 0);
|
|
|
|
}
|
|
|
|
|
2011-11-16 20:23:51 +00:00
|
|
|
void DreamGenContext::loadroom() {
|
|
|
|
data.byte(kRoomloaded) = 1;
|
|
|
|
data.word(kTimecount) = 0;
|
|
|
|
data.word(kMaintimer) = 0;
|
|
|
|
data.word(kMapoffsetx) = 104;
|
|
|
|
data.word(kMapoffsety) = 38;
|
|
|
|
data.word(kTextaddressx) = 13;
|
|
|
|
data.word(kTextaddressy) = 182;
|
|
|
|
data.byte(kTextlen) = 240;
|
|
|
|
data.byte(kLocation) = data.byte(kNewlocation);
|
2011-11-17 10:34:06 +00:00
|
|
|
Room *room = getroomdata(data.byte(kNewlocation));
|
|
|
|
startloading(room);
|
2011-11-16 20:23:51 +00:00
|
|
|
loadroomssample();
|
|
|
|
switchryanon();
|
|
|
|
drawflags();
|
|
|
|
getdimension();
|
|
|
|
}
|
|
|
|
|
2011-11-16 21:52:34 +00:00
|
|
|
void DreamGenContext::loadroomssample() {
|
2011-11-16 22:08:55 +00:00
|
|
|
uint8 sample = data.byte(kRoomssample);
|
|
|
|
|
|
|
|
if (sample == 255 || data.byte(kCurrentsample) == sample)
|
|
|
|
return; // loaded already
|
|
|
|
|
|
|
|
data.byte(kCurrentsample) = sample;
|
|
|
|
cs.byte(kSamplename+10) = '0' + sample / 10;
|
|
|
|
cs.byte(kSamplename+11) = '0' + sample % 10;
|
|
|
|
dx = kSamplename;
|
2011-11-16 21:52:34 +00:00
|
|
|
loadsecondsample();
|
|
|
|
}
|
|
|
|
|
2011-11-17 16:44:19 +00:00
|
|
|
void DreamGenContext::readsetdata() {
|
2011-11-17 17:34:31 +00:00
|
|
|
data.word(kCharset1) = standardload((const char *)cs.ptr(kCharacterset1, 0));
|
|
|
|
data.word(kIcons1) = standardload((const char *)cs.ptr(kIcongraphics0, 0));
|
|
|
|
data.word(kIcons2) = standardload((const char *)cs.ptr(kIcongraphics1, 0));
|
|
|
|
data.word(kMainsprites) = standardload((const char *)cs.ptr(kSpritename1, 0));
|
|
|
|
data.word(kPuzzletext) = standardload((const char *)cs.ptr(kPuzzletextname, 0));
|
|
|
|
data.word(kCommandtext) = standardload((const char *)cs.ptr(kCommandtextname, 0));
|
2011-11-17 16:44:19 +00:00
|
|
|
ax = data.word(kCharset1);
|
|
|
|
data.word(kCurrentset) = ax;
|
|
|
|
if (data.byte(kSoundint) == 0xff)
|
|
|
|
return;
|
2011-11-18 06:23:21 +00:00
|
|
|
engine->openFile("DREAMWEB.VOL");
|
2011-11-17 17:08:17 +00:00
|
|
|
uint8 *volumeTab = segRef(data.word(kSoundbuffer)).ptr(16384, 0);
|
|
|
|
engine->readFromFile(volumeTab, 2048-256);
|
|
|
|
engine->closeFile();
|
2011-11-17 16:44:19 +00:00
|
|
|
}
|
|
|
|
|
2011-11-20 13:06:48 +00:00
|
|
|
Frame * DreamGenContext::tempGraphics() {
|
|
|
|
return (Frame *)segRef(data.word(kTempgraphics)).ptr(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Frame * DreamGenContext::tempGraphics2() {
|
|
|
|
return (Frame *)segRef(data.word(kTempgraphics2)).ptr(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Frame * DreamGenContext::tempGraphics3() {
|
|
|
|
return (Frame *)segRef(data.word(kTempgraphics3)).ptr(0, 0);
|
|
|
|
}
|
|
|
|
|
2011-11-22 10:56:54 +00:00
|
|
|
void DreamGenContext::playchannel0(uint8 index, uint8 repeat) {
|
|
|
|
if (data.byte(kSoundint) == 255)
|
|
|
|
return;
|
2011-11-22 15:16:55 +00:00
|
|
|
|
2011-11-22 10:56:54 +00:00
|
|
|
data.byte(kCh0playing) = index;
|
2011-11-22 15:16:55 +00:00
|
|
|
Sound *soundBank;
|
2011-11-22 10:56:54 +00:00
|
|
|
if (index >= 12) {
|
2011-11-22 15:16:55 +00:00
|
|
|
soundBank = (Sound *)segRef(data.word(kSounddata2)).ptr(0, 0);
|
2011-11-22 10:56:54 +00:00
|
|
|
index -= 12;
|
|
|
|
} else
|
2011-11-22 15:16:55 +00:00
|
|
|
soundBank = (Sound *)segRef(data.word(kSounddata)).ptr(0, 0);
|
2011-11-22 10:56:54 +00:00
|
|
|
|
|
|
|
data.byte(kCh0repeat) = repeat;
|
2011-11-22 15:16:55 +00:00
|
|
|
data.word(kCh0emmpage) = soundBank[index].emmPage;
|
|
|
|
data.word(kCh0offset) = soundBank[index].offset();
|
|
|
|
data.word(kCh0blockstocopy) = soundBank[index].blockCount();
|
2011-11-22 10:56:54 +00:00
|
|
|
if (repeat) {
|
|
|
|
data.word(kCh0oldemmpage) = data.word(kCh0emmpage);
|
|
|
|
data.word(kCh0oldoffset) = data.word(kCh0offset);
|
|
|
|
data.word(kCh0oldblockstocopy) = data.word(kCh0blockstocopy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::playchannel0() {
|
|
|
|
playchannel0(al, ah);
|
2011-11-21 13:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::playchannel1(uint8 index) {
|
2011-11-22 10:56:54 +00:00
|
|
|
if (data.byte(kSoundint) == 255)
|
|
|
|
return;
|
|
|
|
if (data.byte(kCh1playing) == 7)
|
|
|
|
return;
|
2011-11-22 15:16:55 +00:00
|
|
|
|
2011-11-22 10:56:54 +00:00
|
|
|
data.byte(kCh1playing) = index;
|
2011-11-22 15:16:55 +00:00
|
|
|
Sound *soundBank;
|
2011-11-22 10:56:54 +00:00
|
|
|
if (index >= 12) {
|
2011-11-22 15:16:55 +00:00
|
|
|
soundBank = (Sound *)segRef(data.word(kSounddata2)).ptr(0, 0);
|
2011-11-22 10:56:54 +00:00
|
|
|
index -= 12;
|
|
|
|
} else
|
2011-11-22 15:16:55 +00:00
|
|
|
soundBank = (Sound *)segRef(data.word(kSounddata)).ptr(0, 0);
|
2011-11-22 10:56:54 +00:00
|
|
|
|
2011-11-22 15:16:55 +00:00
|
|
|
data.word(kCh1emmpage) = soundBank[index].emmPage;
|
|
|
|
data.word(kCh1offset) = soundBank[index].offset();
|
|
|
|
data.word(kCh1blockstocopy) = soundBank[index].blockCount();
|
2011-11-22 10:56:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::playchannel1() {
|
|
|
|
playchannel1(al);
|
2011-11-21 13:33:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-22 22:53:35 +00:00
|
|
|
void DreamGenContext::findroominloc() {
|
|
|
|
uint8 x = data.byte(kMapx) / 11;
|
|
|
|
uint8 y = data.byte(kMapy) / 10;
|
|
|
|
uint8 roomNum = y * 6 + x;
|
|
|
|
data.byte(kRoomnum) = roomNum;
|
|
|
|
}
|
|
|
|
|
2011-11-23 12:09:31 +00:00
|
|
|
void DreamGenContext::autolook() {
|
|
|
|
if ((data.word(kMousex) != data.word(kOldx)) || (data.word(kMousey) != data.word(kOldy))) {
|
|
|
|
data.word(kLookcounter) = 1000;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
--data.word(kLookcounter);
|
|
|
|
if (data.word(kLookcounter))
|
|
|
|
return;
|
|
|
|
if (data.word(kWatchingtime))
|
|
|
|
return;
|
|
|
|
dolook();
|
|
|
|
}
|
|
|
|
|
2011-11-23 14:49:49 +00:00
|
|
|
void DreamGenContext::look() {
|
|
|
|
if (data.word(kWatchingtime) || (data.byte(kPointermode) == 2)) {
|
|
|
|
blank();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (data.byte(kCommandtype) != 241) {
|
|
|
|
data.byte(kCommandtype) = 241;
|
|
|
|
commandonly(25);
|
|
|
|
}
|
|
|
|
if ((data.word(kMousebutton) == 1) && (data.word(kMousebutton) != data.word(kOldbutton)))
|
|
|
|
dolook();
|
|
|
|
}
|
|
|
|
|
2011-11-23 20:50:35 +00:00
|
|
|
void DreamGenContext::dolook() {
|
|
|
|
createpanel();
|
|
|
|
showicon();
|
|
|
|
undertextline();
|
|
|
|
worktoscreenm();
|
|
|
|
data.byte(kCommandtype) = 255;
|
|
|
|
dumptextline();
|
|
|
|
uint8 index = data.byte(kRoomnum) & 31;
|
|
|
|
uint16 offset = segRef(data.word(kRoomdesc)).word(kIntextdat + index * 2);
|
|
|
|
uint8 *string = segRef(data.word(kRoomdesc)).ptr(kIntext, 0) + offset;
|
|
|
|
findnextcolon(&string);
|
|
|
|
uint16 x;
|
|
|
|
if (data.byte(kReallocation) < 50)
|
|
|
|
x = 66;
|
|
|
|
else
|
|
|
|
x = 40;
|
|
|
|
if (printslow(string, x, 80, 241, true) != 1)
|
|
|
|
hangonp(400);
|
|
|
|
|
|
|
|
data.byte(kPointermode) = 0;
|
|
|
|
data.byte(kCommandtype) = 0;
|
|
|
|
redrawmainscrn();
|
|
|
|
worktoscreenm();
|
|
|
|
}
|
|
|
|
|
2011-11-26 15:37:11 +00:00
|
|
|
void DreamGenContext::usecharset1() {
|
|
|
|
data.word(kCurrentset) = data.word(kCharset1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::usetempcharset() {
|
|
|
|
data.word(kCurrentset) = data.word(kTempcharset);
|
|
|
|
}
|
|
|
|
|
2011-11-26 19:36:56 +00:00
|
|
|
// if skipDat, skip clearing and loading Setdat and Freedat
|
|
|
|
void DreamGenContext::loadRoomData(const Room* room, bool skipDat) {
|
|
|
|
engine->openFile(room->name);
|
|
|
|
cs.word(kHandle) = 1; //only one handle
|
|
|
|
flags._c = false;
|
2011-11-26 19:24:23 +00:00
|
|
|
readheader();
|
2011-11-26 19:36:56 +00:00
|
|
|
|
|
|
|
// read segment lengths from room file header
|
|
|
|
int len[15];
|
|
|
|
for (int i = 0; i < 15; ++i)
|
|
|
|
len[i] = cs.word(kFiledata + 2*i);
|
|
|
|
|
|
|
|
data.word(kBackdrop) = allocateAndLoad(len[0]);
|
|
|
|
clearAndLoad(data.word(kWorkspace), 0, len[1], 132*66); // 132*66 = maplen
|
2011-11-26 19:24:23 +00:00
|
|
|
sortoutmap();
|
2011-11-26 19:36:56 +00:00
|
|
|
data.word(kSetframes) = allocateAndLoad(len[2]);
|
|
|
|
if (!skipDat)
|
|
|
|
clearAndLoad(data.word(kSetdat), 255, len[3], kSetdatlen);
|
|
|
|
else
|
|
|
|
engine->skipBytes(len[3]);
|
|
|
|
// NB: The skipDat version of this function as called by restoreall
|
|
|
|
// had a 'call bloc' instead of 'call loadseg' for reel1,
|
|
|
|
// but 'bloc' was not defined.
|
|
|
|
data.word(kReel1) = allocateAndLoad(len[4]);
|
|
|
|
data.word(kReel2) = allocateAndLoad(len[5]);
|
|
|
|
data.word(kReel3) = allocateAndLoad(len[6]);
|
|
|
|
data.word(kReels) = allocateAndLoad(len[7]);
|
|
|
|
data.word(kPeople) = allocateAndLoad(len[8]);
|
|
|
|
data.word(kSetdesc) = allocateAndLoad(len[9]);
|
|
|
|
data.word(kBlockdesc) = allocateAndLoad(len[10]);
|
|
|
|
data.word(kRoomdesc) = allocateAndLoad(len[11]);
|
|
|
|
data.word(kFreeframes) = allocateAndLoad(len[12]);
|
|
|
|
if (!skipDat)
|
|
|
|
clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
|
|
|
|
else
|
|
|
|
engine->skipBytes(len[13]);
|
|
|
|
data.word(kFreedesc) = allocateAndLoad(len[14]);
|
|
|
|
|
2011-11-26 19:24:23 +00:00
|
|
|
closefile();
|
2011-11-26 19:36:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::restoreall() {
|
|
|
|
const Room *room = getroomdata(data.byte(kLocation));
|
|
|
|
loadRoomData(room, true);
|
2011-11-26 19:24:23 +00:00
|
|
|
setallchanges();
|
|
|
|
}
|
|
|
|
|
2011-11-26 19:45:23 +00:00
|
|
|
void DreamGenContext::restorereels() {
|
|
|
|
STACK_CHECK;
|
|
|
|
_cmp(data.byte(kRoomloaded), 0);
|
|
|
|
if (flags.z())
|
|
|
|
return /* (dontrestore) */;
|
|
|
|
al = data.byte(kReallocation);
|
|
|
|
getroomdata();
|
|
|
|
dx = bx;
|
|
|
|
openfile();
|
|
|
|
readheader();
|
|
|
|
dontloadseg();
|
|
|
|
dontloadseg();
|
|
|
|
dontloadseg();
|
|
|
|
dontloadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kReel1) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kReel2) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kReel3) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
closefile();
|
|
|
|
}
|
|
|
|
|
2011-06-15 21:03:00 +00:00
|
|
|
} /*namespace dreamgen */
|
2011-08-15 13:42:09 +00:00
|
|
|
|