/* PLEASE DO NOT MODIFY THIS FILE. ALL CHANGES WILL BE LOST! LOOK FOR README FOR DETAILS */ /* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "dreamgen.h" namespace DreamGen { void DreamGenContext::transferMap() { STACK_CHECK; di = data.word(kExframepos); push(di); al = data.byte(kExpos); ah = 0; bx = ax; _add(ax, ax); _add(ax, bx); cx = 6; _mul(cx); es = data.word(kExtras); bx = (0); _add(bx, ax); _add(di, (0+2080)); push(bx); al = data.byte(kItemtotran); ah = 0; bx = ax; _add(ax, ax); _add(ax, bx); cx = 6; _mul(cx); ds = data.word(kFreeframes); bx = (0); _add(bx, ax); si = (0+2080); al = ds.byte(bx); ah = 0; cl = ds.byte(bx+1); ch = 0; _add(si, ds.word(bx+2)); dx = ds.word(bx+4); bx = pop(); es.byte(bx+0) = al; es.byte(bx+1) = cl; es.word(bx+4) = dx; _mul(cx); cx = ax; push(cx); _movsb(cx, true); cx = pop(); ax = pop(); es.word(bx+2) = ax; _add(data.word(kExframepos), cx); } void DreamGenContext::read() { STACK_CHECK; cx = 40; randomAccess(); parser(); _cmp(es.byte(di+1), 0); if (!flags.z()) goto okcom; netError(); return; okcom: es = cs; di = 418; ax = data.word(kTextfile1); data.word(kMonsource) = ax; ds = ax; si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile2; ax = data.word(kTextfile2); data.word(kMonsource) = ax; ds = ax; si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile2; ax = data.word(kTextfile3); data.word(kMonsource) = ax; ds = ax; si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile2; al = 7; monMessage(); return; foundfile2: getKeyAndLogo(); _cmp(al, 0); if (flags.z()) goto keyok1; return; keyok1: es = cs; di = offset_operand1; ds = data.word(kMonsource); searchForString(); _cmp(al, 0); if (flags.z()) goto findtopictext; al = data.byte(kOldlogonum); data.byte(kLogonum) = al; al = 11; monMessage(); return; findtopictext: _inc(bx); push(es); push(bx); monitorLogo(); scrollMonitor(); bx = pop(); es = pop(); moretopic: monPrint(); al = es.byte(bx); _cmp(al, 34); if (flags.z()) goto endoftopic; _cmp(al, '='); if (flags.z()) goto endoftopic; _cmp(al, '*'); if (flags.z()) goto endoftopic; push(es); push(bx); processTrigger(); cx = 24; randomAccess(); bx = pop(); es = pop(); goto moretopic; endoftopic: scrollMonitor(); } void DreamGenContext::dirFile() { STACK_CHECK; al = 34; es.byte(di) = al; push(es); push(di); ds = data.word(kTextfile1); si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile; di = pop(); es = pop(); push(es); push(di); ds = data.word(kTextfile2); si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile; di = pop(); es = pop(); push(es); push(di); ds = data.word(kTextfile3); si = (66*2); searchForString(); _cmp(al, 0); if (flags.z()) goto foundfile; di = pop(); es = pop(); al = 7; monMessage(); return; foundfile: ax = pop(); ax = pop(); getKeyAndLogo(); _cmp(al, 0); if (flags.z()) goto keyok2; return; keyok2: push(es); push(bx); ds = cs; si = offset_operand1+1; es = cs; di = 418+1; cx = 12; _movsb(cx, true); monitorLogo(); scrollMonitor(); al = 10; monMessage(); bx = pop(); es = pop(); directloop2: al = es.byte(bx); _inc(bx); _cmp(al, 34); if (flags.z()) goto endofdir2; _cmp(al, '*'); if (flags.z()) goto endofdir2; _cmp(al, '='); if (!flags.z()) goto directloop2; monPrint(); goto directloop2; endofdir2: scrollMonitor(); } void DreamGenContext::searchForString() { STACK_CHECK; dl = es.byte(di); cx = di; restartlook: di = cx; bx = si; dh = 0; keeplooking: _lodsb(); makeCaps(); _cmp(al, '*'); if (flags.z()) goto notfound; _cmp(dl, '='); if (!flags.z()) goto nofindingtopic; _cmp(al, 34); if (flags.z()) goto notfound; nofindingtopic: ah = es.byte(di); _cmp(al, dl); if (!flags.z()) goto notbracket; _inc(dh); _cmp(dh, 2); if (flags.z()) goto complete; notbracket: _cmp(al, ah); if (!flags.z()) goto restartlook; _inc(di); goto keeplooking; complete: es = ds; al = 0; bx = si; return; notfound: al = 1; } void DreamGenContext::parser() { STACK_CHECK; es = cs; di = offset_operand1; cx = 13; al = 0; _stosb(cx, true); di = offset_operand1; al = '='; _stosb(); ds = cs; si = 493; notspace1: _lodsw(); _cmp(al, 32); if (flags.z()) goto stillspace1; _cmp(al, 0); if (!flags.z()) goto notspace1; goto finishpars; stillspace1: _lodsw(); _cmp(al, 32); if (flags.z()) goto stillspace1; copyin1: _stosb(); _lodsw(); _cmp(al, 0); if (flags.z()) goto finishpars; _cmp(al, 32); if (!flags.z()) goto copyin1; finishpars: di = offset_operand1; } void DreamGenContext::__start() { static const uint8 src[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x13, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0000: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0010: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0020: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0xff, 0x00, //0x0030: .... .... .... .... 0xff, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0xb6, //0x0040: ...0 .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0050: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0060: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0070: .... .h.& .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0080: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0090: .... .... .... .... 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00a0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00b0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00c0: .... .. .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00d0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00e0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x00f0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0100: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0110: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0120: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, //0x0130: .... .... .... .... 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0140: .... .... .... .... 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //0x0150: .... .... .... .... 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0160: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0170: .... .... .... .... 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x44, 0x52, 0x45, 0x41, 0x4d, 0x57, 0x45, 0x42, 0x2e, //0x0180: .... ...D REAM WEB. 0x56, 0x39, 0x39, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, //0x0190: V99. 0x20, 0x00, 0x22, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, //0x01a0: ." . 0x0d, 0x0a, 0x0d, 0x0a, 0x24, 0x10, 0x12, 0x12, 0x11, 0x10, 0x10, 0x10, 0x01, 0x01, 0x01, 0x01, //0x01b0: .... $... .... .... 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x44, 0x3a, 0x00, //0x01c0: .... .... .... .D:. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x01d0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x01e0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x01f0: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0200: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0210: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0220: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0230: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0240: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0250: .... .... .... .... 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0260: .... .... .... .... }; ds.assign(src, src + sizeof(src)); dreamweb(); } } // End of namespace DreamGen