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"
|
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
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;
|
|
|
|
seecommandtail();
|
|
|
|
checkbasemem();
|
|
|
|
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;
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
scanfornames();
|
|
|
|
|
|
|
|
bool startNewGame = true;
|
|
|
|
|
|
|
|
if (al == 0 && firstLoop) {
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
if (data.byte(kQuitrequested))
|
|
|
|
return; // exit game
|
|
|
|
|
|
|
|
if (data.byte(kGetback) == 4)
|
|
|
|
startNewGame = false; // savegame has been loaded
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
firstLoop = false;
|
|
|
|
|
|
|
|
if (startNewGame) {
|
|
|
|
// "playgame"
|
|
|
|
|
|
|
|
titles();
|
|
|
|
if (data.byte(kQuitrequested))
|
|
|
|
return; // exit game
|
|
|
|
credits();
|
|
|
|
|
|
|
|
if (data.byte(kQuitrequested))
|
|
|
|
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;
|
|
|
|
data.byte(kVolumedirection) = -1;
|
|
|
|
data.byte(kCommandtype) = 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// main loop
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
if (data.byte(kQuitrequested))
|
|
|
|
return; // exit game
|
|
|
|
|
|
|
|
screenupdate();
|
|
|
|
|
|
|
|
if (data.byte(kWongame) != 0) {
|
|
|
|
// "endofgame"
|
|
|
|
clearbeforeload();
|
|
|
|
fadescreendowns();
|
|
|
|
cx = 200;
|
|
|
|
hangon();
|
|
|
|
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();
|
|
|
|
cx = 100;
|
|
|
|
hangon();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2011-06-26 10:06:16 +00:00
|
|
|
|
2011-07-30 12:13:34 +00:00
|
|
|
static Common::String getFilename(Context &context) {
|
2011-06-15 21:03:00 +00:00
|
|
|
uint16 name_ptr = context.dx;
|
|
|
|
Common::String name;
|
|
|
|
uint8 c;
|
|
|
|
while((c = context.cs.byte(name_ptr++)) != 0)
|
|
|
|
name += (char)c;
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
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-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::openforsave() {
|
|
|
|
const char *name = (const char *)ds.ptr(dx, 13);
|
2011-06-15 21:03:00 +00:00
|
|
|
debug(1, "openforsave(%s)", name);
|
2011-06-16 20:30:39 +00:00
|
|
|
engine->openSaveFileForWriting(name);
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
engine->mouseCall();
|
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;
|
|
|
|
loadspeech();
|
|
|
|
if (data.byte(kSpeechloaded) == 1) {
|
|
|
|
al = 50+12;
|
|
|
|
playchannel1();
|
2011-07-17 14:06:19 +00:00
|
|
|
}
|
2011-08-11 14:59:20 +00:00
|
|
|
dx = pop();
|
|
|
|
cx = pop();
|
|
|
|
bx = pop();
|
|
|
|
ax = pop();
|
|
|
|
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() {
|
|
|
|
uint16 id = (uint16)es;
|
2011-06-15 21:03:00 +00:00
|
|
|
debug(1, "deallocating segment %04x", id);
|
2011-06-16 20:30:39 +00:00
|
|
|
deallocateSegment(id);
|
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);
|
|
|
|
if (seg == id)
|
|
|
|
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-25 14:20:19 +00:00
|
|
|
//good place for early initialization
|
|
|
|
switch(engine->getLanguage()) {
|
|
|
|
case Common::EN_ANY:
|
|
|
|
case Common::EN_GRB:
|
|
|
|
case Common::EN_USA:
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
data.byte(kForeignrelease) = 1;
|
|
|
|
}
|
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::saveseg() {
|
|
|
|
cx = es.word(di);
|
|
|
|
_add(di, 2);
|
|
|
|
savefilewrite();
|
2011-06-15 21:03:00 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 20:30:39 +00:00
|
|
|
void DreamGenContext::savefilewrite() {
|
|
|
|
ax = engine->writeToSaveFile(ds.ptr(dx, cx), cx);
|
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() {
|
|
|
|
//fixme: this is a bit hackish, set16colpalette called after initialization and nearly before main loop.
|
|
|
|
engine->enableSavingOrLoading();
|
|
|
|
}
|
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-07-20 16:21:03 +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-28 03:10:35 +00:00
|
|
|
void DreamGenContext::turnpathonCPP(uint8 param) {
|
|
|
|
al = param;
|
|
|
|
push(es);
|
|
|
|
push(bx);
|
|
|
|
turnpathon();
|
|
|
|
bx = pop();
|
|
|
|
es = pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::turnpathoffCPP(uint8 param) {
|
|
|
|
al = param;
|
|
|
|
push(es);
|
|
|
|
push(bx);
|
|
|
|
turnpathoff();
|
|
|
|
bx = pop();
|
|
|
|
es = pop();
|
|
|
|
}
|
|
|
|
|
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-07-26 05:54:25 +00:00
|
|
|
void DreamGenContext::getroomspaths() {
|
|
|
|
es = data.word(kReels);
|
|
|
|
bx = data.byte(kRoomnum) * 144;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 *DreamGenContext::getroomspathsCPP() {
|
2011-08-11 10:26:30 +00:00
|
|
|
void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144);
|
2011-07-26 05:54:25 +00:00
|
|
|
return (uint8 *)result;
|
|
|
|
}
|
|
|
|
|
2011-07-27 15:53:50 +00:00
|
|
|
void DreamGenContext::makebackob() {
|
|
|
|
if (data.byte(kNewobs) == 0)
|
|
|
|
return;
|
|
|
|
uint8 priority = es.byte(si+5);
|
|
|
|
uint8 type = es.byte(si+8);
|
|
|
|
Sprite *sprite = makesprite(data.word(kObjectx), data.word(kObjecty), addr_backobject, data.word(kSetframes), 0);
|
|
|
|
|
|
|
|
// Recover es:bx from sprite
|
|
|
|
es = data.word(kBuffers);
|
|
|
|
bx = kSpritetable;
|
|
|
|
Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16);
|
|
|
|
bx += sizeof(Sprite) * (sprite - sprites);
|
|
|
|
//
|
2011-07-30 13:52:28 +00:00
|
|
|
sprite->setObjData(si);
|
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;
|
|
|
|
sprite->frame = 0;
|
|
|
|
}
|
|
|
|
|
2011-07-30 17:54:53 +00:00
|
|
|
void DreamGenContext::getroomdata() {
|
|
|
|
bx = kRoomdata + sizeof(Room) * al;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DreamGenContext::getroomdata(uint8 roomIndex) {
|
|
|
|
getroomdata(roomIndex);
|
|
|
|
}
|
|
|
|
|
2011-07-30 19:46:59 +00:00
|
|
|
void DreamGenContext::startloading() {
|
|
|
|
const Room *room = (Room *)cs.ptr(bx, sizeof(Room));
|
|
|
|
startloading(room);
|
|
|
|
}
|
|
|
|
|
2011-07-30 19:56:33 +00:00
|
|
|
void DreamGenContext::readheader() {
|
|
|
|
ax = engine->readFromFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
|
|
|
|
es = cs;
|
|
|
|
di = kFiledata;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
data.byte(kFacing) = room->b22;
|
|
|
|
data.byte(kTurntoface) = room->b22;
|
|
|
|
data.byte(kCounttoopen) = room->countToOpen;
|
|
|
|
data.byte(kLiftpath) = room->liftPath;
|
|
|
|
data.byte(kDoorpath) = room->doorPath;
|
|
|
|
data.byte(kLastweapon) = -1;
|
|
|
|
al = room->b27;
|
|
|
|
push(ax);
|
|
|
|
al = room->b31;
|
|
|
|
ah = data.byte(kReallocation);
|
|
|
|
data.byte(kReallocation) = al;
|
|
|
|
dx = bx;
|
|
|
|
Common::String name = getFilename(*this);
|
|
|
|
engine->openFile(name);
|
|
|
|
cs.word(kHandle) = 1; //only one handle
|
|
|
|
flags._c = false;
|
|
|
|
readheader();
|
|
|
|
allocateload();
|
|
|
|
ds = ax;
|
|
|
|
data.word(kBackdrop) = ax;
|
|
|
|
dx = (0);
|
|
|
|
loadseg();
|
|
|
|
ds = data.word(kWorkspace);
|
|
|
|
dx = (0);
|
|
|
|
cx = 132*66;
|
|
|
|
al = 0;
|
|
|
|
fillspace();
|
|
|
|
loadseg();
|
|
|
|
sortoutmap();
|
|
|
|
allocateload();
|
|
|
|
data.word(kSetframes) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = (0);
|
|
|
|
loadseg();
|
|
|
|
ds = data.word(kSetdat);
|
|
|
|
dx = 0;
|
|
|
|
cx = (64*128);
|
|
|
|
al = 255;
|
|
|
|
fillspace();
|
|
|
|
loadseg();
|
|
|
|
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();
|
|
|
|
allocateload();
|
|
|
|
data.word(kReels) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kPeople) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kSetdesc) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kBlockdesc) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kRoomdesc) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kFreeframes) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = 0;
|
|
|
|
loadseg();
|
|
|
|
ds = data.word(kFreedat);
|
|
|
|
dx = 0;
|
|
|
|
cx = (16*80);
|
|
|
|
al = 255;
|
|
|
|
fillspace();
|
|
|
|
loadseg();
|
|
|
|
allocateload();
|
|
|
|
data.word(kFreedesc) = ax;
|
|
|
|
ds = ax;
|
|
|
|
dx = (0);
|
|
|
|
loadseg();
|
|
|
|
closefile();
|
|
|
|
findroominloc();
|
|
|
|
deletetaken();
|
|
|
|
setallchanges();
|
|
|
|
autoappear();
|
|
|
|
al = data.byte(kNewlocation);
|
|
|
|
getroomdata();
|
|
|
|
data.byte(kLastweapon) = -1;
|
|
|
|
data.byte(kMandead) = 0;
|
|
|
|
data.word(kLookcounter) = 160;
|
|
|
|
data.byte(kNewlocation) = 255;
|
|
|
|
data.byte(kLinepointer) = 254;
|
|
|
|
ax = pop();
|
|
|
|
if (al != 255) {
|
|
|
|
data.byte(kManspath) = al;
|
|
|
|
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-11 10:33:33 +00:00
|
|
|
al = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
placesetobject();
|
|
|
|
data.byte(kHavedoneobs) = 1;
|
|
|
|
} else if (type == 1) {
|
2011-08-11 10:33:33 +00:00
|
|
|
al = secondParam;
|
2011-07-30 21:21:43 +00:00
|
|
|
removesetobject();
|
|
|
|
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-07-30 21:37:18 +00:00
|
|
|
while (true) {
|
2011-08-11 10:33:33 +00:00
|
|
|
if (reel->x < 220)
|
2011-07-30 21:37:18 +00:00
|
|
|
break;
|
2011-08-11 10:33:33 +00:00
|
|
|
if (reel->x == 255)
|
2011-07-30 21:37:18 +00:00
|
|
|
break;
|
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
|
|
|
}
|
|
|
|
soundonreels();
|
|
|
|
}
|
|
|
|
|
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-03 11:54:03 +00:00
|
|
|
uint8 width, height;
|
|
|
|
showframe(src, kZoomx + 24, kZoomy + 19, frame, 0, &width, &height);
|
|
|
|
}
|
|
|
|
|
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-08-11 10:26:30 +00:00
|
|
|
multiput(segRef(data.word(kBuffers)).ptr(kTextunder, 0), x, y, kUndertextsizex, kUndertextsizey);
|
2011-08-03 14:19:27 +00:00
|
|
|
}
|
|
|
|
|
2011-08-08 20:26:31 +00:00
|
|
|
void DreamGenContext::autosetwalk() {
|
|
|
|
al = data.byte(kManspath);
|
|
|
|
if (data.byte(kFinaldest) == al)
|
|
|
|
return;
|
2011-08-09 20:04:06 +00:00
|
|
|
const uint8 *roomsPaths = getroomspathsCPP();
|
|
|
|
checkdest(roomsPaths);
|
2011-08-08 20:26:31 +00:00
|
|
|
data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
|
|
|
|
data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
|
|
|
|
data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12;
|
|
|
|
data.word(kLineendy) = roomsPaths[data.byte(kDestination) * 8 + 1] - 12;
|
|
|
|
bresenhams();
|
|
|
|
if (data.byte(kLinedirection) != 0) {
|
|
|
|
data.byte(kLinepointer) = data.byte(kLinelength) - 1;
|
|
|
|
data.byte(kLinedirection) = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
data.byte(kLinepointer) = 0;
|
|
|
|
}
|
|
|
|
|
2011-08-09 20:04:06 +00:00
|
|
|
void DreamGenContext::checkdest(const uint8 *roomsPaths) {
|
|
|
|
const uint8 *p = roomsPaths + 12 * 8;
|
|
|
|
ah = data.byte(kManspath) << 4;
|
|
|
|
al = data.byte(kDestination);
|
|
|
|
uint8 destination = data.byte(kDestination);
|
|
|
|
for (size_t i = 0; i < 24; ++i) {
|
|
|
|
dh = p[0] & 0xf0;
|
|
|
|
dl = p[0] & 0x0f;
|
|
|
|
if (ax == dx) {
|
|
|
|
data.byte(kDestination) = p[1] & 0x0f;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dl = (p[0] & 0xf0) >> 4;
|
|
|
|
dh = (p[0] & 0x0f) << 4;
|
|
|
|
if (ax == dx) {
|
|
|
|
destination = p[1] & 0x0f;
|
|
|
|
}
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
data.byte(kDestination) = destination;
|
|
|
|
}
|
|
|
|
|
2011-08-11 21:13:17 +00:00
|
|
|
void DreamGenContext::checkifperson() {
|
|
|
|
flags._z = not checkifperson(al, ah);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
data.word(kReelpointer) = people->w0();
|
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;
|
|
|
|
data.word(kPersondata) = people->w2();
|
|
|
|
al = people->b4;
|
|
|
|
ah = 5;
|
|
|
|
obname();
|
|
|
|
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);
|
|
|
|
{
|
|
|
|
uint16 y = data.word(kTextaddressy);
|
|
|
|
const uint8 *string = segRef(data.word(kCommandtext)).ptr(commandText, 0);
|
|
|
|
printdirect(&string, data.word(kTextaddressx), &y, textLen, (bool)(textLen & 1));
|
|
|
|
}
|
|
|
|
copyname(type, index, commandLine);
|
|
|
|
uint16 x = data.word(kLastxpos);
|
|
|
|
if (command != 0)
|
|
|
|
x += 5;
|
|
|
|
{
|
|
|
|
uint16 y = data.word(kTextaddressy);
|
|
|
|
const uint8 *string = commandLine;
|
|
|
|
printdirect(&string, x, &y, textLen, (bool)(textLen & 1));
|
|
|
|
}
|
|
|
|
data.byte(kNewtextline) = 1;
|
|
|
|
}
|
|
|
|
|
2011-08-15 15:00:20 +00:00
|
|
|
void DreamGenContext::showpanel() {
|
|
|
|
Frame *frame = (Frame *)segRef(data.word(kIcons1)).ptr(0, sizeof(Frame));
|
|
|
|
uint8 width, height;
|
|
|
|
showframe(frame, 72, 0, 19, 0, &width, &height);
|
|
|
|
showframe(frame, 192, 0, 19, 0, &width, &height);
|
|
|
|
}
|
|
|
|
|
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-06-15 21:03:00 +00:00
|
|
|
} /*namespace dreamgen */
|
2011-08-15 13:42:09 +00:00
|
|
|
|