diff options
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 1951 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 163 | ||||
-rw-r--r-- | engines/dreamweb/module.mk | 5 | ||||
-rw-r--r-- | engines/dreamweb/print.cpp | 224 | ||||
-rw-r--r-- | engines/dreamweb/runtime.h | 6 | ||||
-rw-r--r-- | engines/dreamweb/sprite.cpp | 874 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 99 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 1503 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 76 | ||||
-rw-r--r-- | engines/dreamweb/vgagrafx.cpp | 452 |
10 files changed, 2239 insertions, 3114 deletions
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 59d69758b6..9a5a27dff0 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -1694,116 +1694,6 @@ notendtelly: showgamereel(); } -void DreamGenContext::madman() { - STACK_CHECK; - data.word(kWatchingtime) = 2; - checkspeed(); - if (!flags.z()) - goto nomadspeed; - ax = es.word(bx+3); - _cmp(ax, 364); - if (!flags.c()) - goto ryansded; - _cmp(ax, 10); - if (!flags.z()) - goto notfirstmad; - push(es); - push(bx); - push(ax); - dx = 2247; - loadtemptext(); - ax = pop(); - bx = pop(); - es = pop(); - data.byte(kCombatcount) = -1; - data.byte(kSpeechcount) = 0; -notfirstmad: - _inc(ax); - _cmp(ax, 294); - if (flags.z()) - goto madmanspoken; - _cmp(ax, 66); - if (!flags.z()) - goto nomadspeak; - _inc(data.byte(kCombatcount)); - push(es); - push(bx); - madmantext(); - bx = pop(); - es = pop(); - ax = 53; - _cmp(data.byte(kCombatcount), 64); - if (flags.c()) - goto nomadspeak; - _cmp(data.byte(kCombatcount), 70); - if (flags.z()) - goto killryan; - _cmp(data.byte(kLastweapon), 8); - if (!flags.z()) - goto nomadspeak; - data.byte(kCombatcount) = 72; - data.byte(kLastweapon) = -1; - data.byte(kMadmanflag) = 1; - ax = 67; - goto nomadspeak; -killryan: - ax = 310; -nomadspeak: - es.word(bx+3) = ax; -nomadspeed: - showgamereel(); - al = data.byte(kMapx); - es.byte(bx+1) = al; - madmode(); - return; -madmanspoken: - _cmp(data.byte(kWongame), 1); - if (flags.z()) - return /* (alreadywon) */; - data.byte(kWongame) = 1; - push(es); - push(bx); - getridoftemptext(); - bx = pop(); - es = pop(); - return; -ryansded: - data.byte(kMandead) = 2; - showgamereel(); -} - -void DreamGenContext::madmantext() { - STACK_CHECK; - _cmp(data.byte(kSpeechcount), 63); - if (!flags.c()) - return /* (nomadtext) */; - _cmp(data.byte(kCh1playing), 255); - if (!flags.z()) - return /* (nomadtext) */; - al = data.byte(kSpeechcount); - _inc(data.byte(kSpeechcount)); - _add(al, 47); - bl = 72; - bh = 80; - cx = 90; - dx = 1; - ah = 82; - setuptimedtemp(); -} - -void DreamGenContext::madmode() { - STACK_CHECK; - data.word(kWatchingtime) = 2; - data.byte(kPointermode) = 0; - _cmp(data.byte(kCombatcount), 65); - if (flags.c()) - return /* (iswatchmad) */; - _cmp(data.byte(kCombatcount), 70); - if (!flags.c()) - return /* (iswatchmad) */; - data.byte(kPointermode) = 2; -} - void DreamGenContext::priesttext() { STACK_CHECK; _cmp(es.word(bx+3), 2); @@ -2160,22 +2050,6 @@ void DreamGenContext::addtopeoplelist() { _add(data.word(kListpos), 5); } -void DreamGenContext::showgamereel() { - STACK_CHECK; - ax = es.word(bx+3); - _cmp(ax, 512); - if (!flags.c()) - return /* (noshow) */; - data.word(kReelpointer) = ax; - push(es); - push(bx); - plotreel(); - bx = pop(); - es = pop(); - ax = data.word(kReelpointer); - es.word(bx+3) = ax; -} - void DreamGenContext::checkspeed() { STACK_CHECK; _cmp(data.byte(kLastweapon), -1); @@ -2237,182 +2111,6 @@ void DreamGenContext::checkone() { dx = pop(); } -void DreamGenContext::findsource() { - STACK_CHECK; - ax = data.word(kCurrentframe); - _cmp(ax, 160); - if (!flags.c()) - goto over1000; - ds = data.word(kReel1); - data.word(kTakeoff) = 0; - return; -over1000: - _cmp(ax, 320); - if (!flags.c()) - goto over1001; - ds = data.word(kReel2); - data.word(kTakeoff) = 160; - return; -over1001: - ds = data.word(kReel3); - data.word(kTakeoff) = 320; -} - -void DreamGenContext::mainman() { - STACK_CHECK; - _cmp(data.byte(kResetmanxy), 1); - if (!flags.z()) - goto notinnewroom; - data.byte(kResetmanxy) = 0; - al = data.byte(kRyanx); - ah = data.byte(kRyany); - es.word(bx+10) = ax; - es.byte(bx+29) = 0; - goto executewalk; -notinnewroom: - _dec(es.byte(bx+22)); - _cmp(es.byte(bx+22), -1); - if (flags.z()) - goto executewalk; - return; -executewalk: - es.byte(bx+22) = 0; - al = data.byte(kTurntoface); - _cmp(al, data.byte(kFacing)); - if (flags.z()) - goto facingok; - aboutturn(); - goto notwalk; -facingok: - _cmp(data.byte(kTurndirection), 0); - if (flags.z()) - goto alreadyturned; - _cmp(data.byte(kLinepointer), 254); - if (!flags.z()) - goto alreadyturned; - data.byte(kReasseschanges) = 1; - al = data.byte(kFacing); - _cmp(al, data.byte(kLeavedirection)); - if (!flags.z()) - goto alreadyturned; - checkforexit(); -alreadyturned: - data.byte(kTurndirection) = 0; - _cmp(data.byte(kLinepointer), 254); - if (!flags.z()) - goto walkman; - es.byte(bx+29) = 0; - goto notwalk; -walkman: - al = es.byte(bx+29); - _inc(al); - _cmp(al, 11); - if (!flags.z()) - goto notanimend1; - al = 1; -notanimend1: - es.byte(bx+29) = al; - walking(); - _cmp(data.byte(kLinepointer), 254); - if (flags.z()) - goto afterwalk; - al = data.byte(kFacing); - _and(al, 1); - if (flags.z()) - goto isdouble; - al = es.byte(bx+29); - _cmp(al, 2); - if (flags.z()) - goto afterwalk; - _cmp(al, 7); - if (flags.z()) - goto afterwalk; -isdouble: - walking(); -afterwalk: - _cmp(data.byte(kLinepointer), 254); - if (!flags.z()) - goto notwalk; - al = data.byte(kTurntoface); - _cmp(al, data.byte(kFacing)); - if (!flags.z()) - goto notwalk; - data.byte(kReasseschanges) = 1; - al = data.byte(kFacing); - _cmp(al, data.byte(kLeavedirection)); - if (!flags.z()) - goto notwalk; - checkforexit(); -notwalk: - al = data.byte(kFacing); - ah = 0; - di = 1105; - _add(di, ax); - al = cs.byte(di); - _add(al, es.byte(bx+29)); - es.byte(bx+15) = al; - ax = es.word(bx+10); - data.byte(kRyanx) = al; - data.byte(kRyany) = ah; -} - -void DreamGenContext::aboutturn() { - STACK_CHECK; - _cmp(data.byte(kTurndirection), 1); - if (flags.z()) - goto incdir; - _cmp(data.byte(kTurndirection), -1); - if (flags.z()) - goto decdir; - al = data.byte(kFacing); - _sub(al, data.byte(kTurntoface)); - if (!flags.c()) - goto higher; - _neg(al); - _cmp(al, 4); - if (!flags.c()) - goto decdir; - goto incdir; -higher: - _cmp(al, 4); - if (!flags.c()) - goto incdir; - goto decdir; -incdir: - data.byte(kTurndirection) = 1; - al = data.byte(kFacing); - _inc(al); - _and(al, 7); - data.byte(kFacing) = al; - es.byte(bx+29) = 0; - return; -decdir: - data.byte(kTurndirection) = -1; - al = data.byte(kFacing); - _dec(al); - _and(al, 7); - data.byte(kFacing) = al; - es.byte(bx+29) = 0; -} - -void DreamGenContext::facerightway() { - STACK_CHECK; - push(es); - push(bx); - getroomspaths(); - al = data.byte(kManspath); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = es.byte(bx+7); - data.byte(kTurntoface) = al; - data.byte(kLeavedirection) = al; - bx = pop(); - es = pop(); -} - void DreamGenContext::checkforexit() { STACK_CHECK; cl = data.byte(kRyanx); @@ -2772,147 +2470,6 @@ failrain: al = 0; } -void DreamGenContext::showrain() { - STACK_CHECK; - ds = data.word(kMainsprites); - si = 6*58; - ax = ds.word(si+2); - si = ax; - _add(si, 2080); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80)+(250*4)+(256*30)); - es = data.word(kBuffers); - _cmp(es.byte(bx), 255); - if (flags.z()) - return /* (nothunder) */; -morerain: - es = data.word(kBuffers); - _cmp(es.byte(bx), 255); - if (flags.z()) - goto finishrain; - al = es.byte(bx+1); - ah = 0; - _add(ax, data.word(kMapady)); - _add(ax, data.word(kMapystart)); - cx = 320; - _mul(cx); - cl = es.byte(bx); - ch = 0; - _add(ax, cx); - _add(ax, data.word(kMapadx)); - _add(ax, data.word(kMapxstart)); - di = ax; - cl = es.byte(bx+2); - ch = 0; - ax = es.word(bx+3); - dl = es.byte(bx+5); - dh = 0; - _sub(ax, dx); - _and(ax, 511); - es.word(bx+3) = ax; - _add(bx, 6); - push(si); - _add(si, ax); - es = data.word(kWorkspace); - ah = 0; - dx = 320-2; -rainloop: - _lodsb(); - _cmp(al, ah); - if (flags.z()) - goto noplot; - _stosb(); - _add(di, dx); - if (--cx) - goto rainloop; - si = pop(); - goto morerain; -noplot: - _add(di, 320-1); - if (--cx) - goto rainloop; - si = pop(); - goto morerain; -finishrain: - _cmp(data.word(kCh1blockstocopy), 0); - if (!flags.z()) - return /* (nothunder) */; - _cmp(data.byte(kReallocation), 2); - if (!flags.z()) - goto notlouisthund; - _cmp(data.byte(kBeenmugged), 1); - if (!flags.z()) - return /* (nothunder) */; -notlouisthund: - _cmp(data.byte(kReallocation), 55); - if (flags.z()) - return /* (nothunder) */; - randomnum1(); - _cmp(al, 1); - if (!flags.c()) - return /* (nothunder) */; - al = 7; - _cmp(data.byte(kCh0playing), 6); - if (flags.z()) - goto isthunder1; - al = 4; -isthunder1: - playchannel1(); -} - -void DreamGenContext::backobject() { - STACK_CHECK; - ds = data.word(kSetdat); - di = es.word(bx+20); - al = es.byte(bx+18); - _cmp(al, 0); - if (flags.z()) - goto _tmp48z; - _dec(al); - es.byte(bx+18) = al; - return /* (finishback) */; -_tmp48z: - al = ds.byte(di+7); - es.byte(bx+18) = al; - al = ds.byte(di+8); - _cmp(al, 6); - if (!flags.z()) - goto notwidedoor; - widedoor(); - return /* (finishback) */; -notwidedoor: - _cmp(al, 5); - if (!flags.z()) - goto notrandom; - random(); - return /* (finishback) */; -notrandom: - _cmp(al, 4); - if (!flags.z()) - goto notlockdoor; - lockeddoorway(); - return /* (finishback) */; -notlockdoor: - _cmp(al, 3); - if (!flags.z()) - goto notlift; - liftsprite(); - return /* (finishback) */; -notlift: - _cmp(al, 2); - if (!flags.z()) - goto notdoor; - doorway(); - return /* (finishback) */; -notdoor: - _cmp(al, 1); - if (!flags.z()) - goto steadyob; - constant(); - return /* (finishback) */; -steadyob: - steady(); -} - void DreamGenContext::liftnoise() { STACK_CHECK; _cmp(data.byte(kReallocation), 5); @@ -2966,231 +2523,6 @@ gotconst: ds.byte(di+17) = al; } -void DreamGenContext::doorway() { - STACK_CHECK; - data.byte(kDoorcheck1) = -24; - data.byte(kDoorcheck2) = 10; - data.byte(kDoorcheck3) = -30; - data.byte(kDoorcheck4) = 10; - dodoor(); -} - -void DreamGenContext::widedoor() { - STACK_CHECK; - data.byte(kDoorcheck1) = -24; - data.byte(kDoorcheck2) = 24; - data.byte(kDoorcheck3) = -30; - data.byte(kDoorcheck4) = 24; - dodoor(); -} - -void DreamGenContext::lockeddoorway() { - STACK_CHECK; - al = data.byte(kRyanx); - ah = data.byte(kRyany); - cl = es.byte(bx+10); - ch = es.byte(bx+11); - _cmp(al, cl); - if (!flags.c()) - goto rtofdoor2; - _sub(al, cl); - _cmp(al, -24); - if (!flags.c()) - goto upordown2; - goto shutdoor2; -rtofdoor2: - _sub(al, cl); - _cmp(al, 10); - if (!flags.c()) - goto shutdoor2; -upordown2: - _cmp(ah, ch); - if (!flags.c()) - goto botofdoor2; - _sub(ah, ch); - _cmp(ah, -30); - if (flags.c()) - goto shutdoor2; - goto opendoor2; -botofdoor2: - _sub(ah, ch); - _cmp(ah, 12); - if (!flags.c()) - goto shutdoor2; -opendoor2: - _cmp(data.byte(kThroughdoor), 1); - if (flags.z()) - goto mustbeopen; - _cmp(data.byte(kLockstatus), 1); - if (flags.z()) - goto shutdoor; -mustbeopen: - cl = es.byte(bx+19); - _cmp(cl, 1); - if (!flags.z()) - goto notdoorsound4; - al = 0; - playchannel1(); -notdoorsound4: - _cmp(cl, 6); - if (!flags.z()) - goto noturnonyet; - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathon(); - bx = pop(); - es = pop(); -noturnonyet: - cl = es.byte(bx+19); - _cmp(data.byte(kThroughdoor), 1); - if (!flags.z()) - goto notthrough2; - _cmp(cl, 0); - if (!flags.z()) - goto notthrough2; - cl = 6; -notthrough2: - _inc(cl); - ch = 0; - push(di); - _add(di, cx); - al = ds.byte(di+18); - _cmp(al, 255); - if (!flags.z()) - goto atlast3; - _dec(di); - _dec(cl); -atlast3: - es.byte(bx+19) = cl; - al = ds.byte(di+18); - di = pop(); - es.byte(bx+15) = al; - ds.byte(di+17) = al; - _cmp(cl, 5); - if (!flags.z()) - return /* (justshutting) */; - data.byte(kThroughdoor) = 1; - return; -shutdoor2: - cl = es.byte(bx+19); - _cmp(cl, 5); - if (!flags.z()) - goto notdoorsound3; - al = 1; - playchannel1(); -notdoorsound3: - _cmp(cl, 0); - if (flags.z()) - goto atlast4; - _dec(cl); - es.byte(bx+19) = cl; -atlast4: - ch = 0; - data.byte(kThroughdoor) = 0; - push(di); - _add(di, cx); - al = ds.byte(di+18); - di = pop(); - es.byte(bx+15) = al; - ds.byte(di+17) = al; - _cmp(cl, 0); - if (!flags.z()) - return /* (notlocky) */; - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathoff(); - bx = pop(); - es = pop(); - data.byte(kLockstatus) = 1; - return; -/*continuing to unbounded code: shutdoor from dodoor:60-87*/ -shutdoor: - cl = es.byte(bx+19); - _cmp(cl, 5); - if (!flags.z()) - goto notdoorsound1; - al = 1; - _cmp(data.byte(kReallocation), 5); - if (!flags.z()) - goto nothoteldoor1; - al = 13; -nothoteldoor1: - playchannel1(); -notdoorsound1: - _cmp(cl, 0); - if (flags.z()) - goto atlast2; - _dec(cl); - es.byte(bx+19) = cl; -atlast2: - ch = 0; - push(di); - _add(di, cx); - al = ds.byte(di+18); - di = pop(); - es.byte(bx+15) = al; - ds.byte(di+17) = al; - _cmp(cl, 5); - if (!flags.z()) - return /* (notnearly) */; - data.byte(kThroughdoor) = 0; -} - -void DreamGenContext::updatepeople() { - STACK_CHECK; - es = data.word(kBuffers); - di = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)); - data.word(kListpos) = di; - cx = 12*5; - al = 255; - _stosb(cx, true); - _inc(data.word(kMaintimer)); - es = cs; - bx = 534; - di = 991; -updateloop: - al = es.byte(bx); - _cmp(al, 255); - if (flags.z()) - return /* (endupdate) */; - _cmp(al, data.byte(kReallocation)); - if (!flags.z()) - goto notinthisroom; - cx = es.word(bx+1); - _cmp(cl, data.byte(kMapx)); - if (!flags.z()) - goto notinthisroom; - _cmp(ch, data.byte(kMapy)); - if (!flags.z()) - goto notinthisroom; - push(di); - ax = cs.word(di); - __dispatch_call(ax); - di = pop(); -notinthisroom: - _add(bx, 8); - _add(di, 2); - goto updateloop; -} - -void DreamGenContext::getreelframeax() { - STACK_CHECK; - push(ds); - data.word(kCurrentframe) = ax; - findsource(); - es = ds; - ds = pop(); - ax = data.word(kCurrentframe); - _sub(ax, data.word(kTakeoff)); - _add(ax, ax); - cx = ax; - _add(ax, ax); - _add(ax, cx); - bx = ax; -} - void DreamGenContext::reelsonscreen() { STACK_CHECK; reconstruct(); @@ -3200,48 +2532,6 @@ void DreamGenContext::reelsonscreen() { usetimedtext(); } -void DreamGenContext::plotreel() { - STACK_CHECK; - getreelstart(); -retryreel: - push(es); - push(si); - ax = es.word(si+2); - _cmp(al, 220); - if (flags.c()) - goto normalreel; - _cmp(al, 255); - if (flags.z()) - goto normalreel; - dealwithspecial(); - _inc(data.word(kReelpointer)); - si = pop(); - es = pop(); - _add(si, 40); - goto retryreel; -normalreel: - cx = 8; -plotloop: - push(cx); - push(es); - push(si); - ax = es.word(si); - _cmp(ax, 0x0ffff); - if (flags.z()) - goto notplot; - showreelframe(); -notplot: - si = pop(); - es = pop(); - cx = pop(); - _add(si, 5); - if (--cx) - goto plotloop; - soundonreels(); - bx = pop(); - es = pop(); -} - void DreamGenContext::soundonreels() { STACK_CHECK; bl = data.byte(kReallocation); @@ -3307,126 +2597,6 @@ notfudge: data.byte(kHavedoneobs) = 0; } -void DreamGenContext::dealwithspecial() { - STACK_CHECK; - _sub(al, 220); - _cmp(al, 0); - if (!flags.z()) - goto notplset; - al = ah; - placesetobject(); - data.byte(kHavedoneobs) = 1; - return; -notplset: - _cmp(al, 1); - if (!flags.z()) - goto notremset; - al = ah; - removesetobject(); - data.byte(kHavedoneobs) = 1; - return; -notremset: - _cmp(al, 2); - if (!flags.z()) - goto notplfree; - al = ah; - placefreeobject(); - data.byte(kHavedoneobs) = 1; - return; -notplfree: - _cmp(al, 3); - if (!flags.z()) - goto notremfree; - al = ah; - removefreeobject(); - data.byte(kHavedoneobs) = 1; - return; -notremfree: - _cmp(al, 4); - if (!flags.z()) - goto notryanoff; - switchryanoff(); - return; -notryanoff: - _cmp(al, 5); - if (!flags.z()) - goto notryanon; - data.byte(kTurntoface) = ah; - data.byte(kFacing) = ah; - switchryanon(); - return; -notryanon: - _cmp(al, 6); - if (!flags.z()) - goto notchangeloc; - data.byte(kNewlocation) = ah; - return; -notchangeloc: - movemap(); -} - -void DreamGenContext::movemap() { - STACK_CHECK; - _cmp(ah, 32); - if (!flags.z()) - goto notmapup2; - _sub(data.byte(kMapy), 20); - data.byte(kNowinnewroom) = 1; - return; -notmapup2: - _cmp(ah, 16); - if (!flags.z()) - goto notmapupspec; - _sub(data.byte(kMapy), 10); - data.byte(kNowinnewroom) = 1; - return; -notmapupspec: - _cmp(ah, 8); - if (!flags.z()) - goto notmapdownspec; - _add(data.byte(kMapy), 10); - data.byte(kNowinnewroom) = 1; - return; -notmapdownspec: - _cmp(ah, 2); - if (!flags.z()) - goto notmaprightspec; - _add(data.byte(kMapx), 11); - data.byte(kNowinnewroom) = 1; - return; -notmaprightspec: - _sub(data.byte(kMapx), 11); - data.byte(kNowinnewroom) = 1; -} - -void DreamGenContext::getreelstart() { - STACK_CHECK; - ax = data.word(kReelpointer); - cx = 40; - _mul(cx); - es = data.word(kReels); - si = ax; - _add(si, (0+(36*144))); -} - -void DreamGenContext::showreelframe() { - STACK_CHECK; - al = es.byte(si+2); - ah = 0; - di = ax; - _add(di, data.word(kMapadx)); - al = es.byte(si+3); - bx = ax; - _add(bx, data.word(kMapady)); - ax = es.word(si); - data.word(kCurrentframe) = ax; - findsource(); - ax = data.word(kCurrentframe); - _sub(ax, data.word(kTakeoff)); - ah = 8; - showframe(); -} - void DreamGenContext::deleverything() { STACK_CHECK; al = data.byte(kMapysize); @@ -3501,13 +2671,6 @@ dumpevery2: goto dumpevery2; } -void DreamGenContext::allocatework() { - STACK_CHECK; - bx = 0x1000; - allocatemem(); - data.word(kWorkspace) = ax; -} - void DreamGenContext::loadpalfromiff() { STACK_CHECK; dx = 2481; @@ -3669,68 +2832,6 @@ void DreamGenContext::createpanel2() { showframe(); } -void DreamGenContext::clearwork() { - STACK_CHECK; - ax = 0x0; - es = data.word(kWorkspace); - di = 0; - cx = (200*320)/64; -clearloop: - _stosw(32); - if (--cx) - goto clearloop; -} - -void DreamGenContext::zoom() { - STACK_CHECK; - _cmp(data.word(kWatchingtime), 0); - if (!flags.z()) - return /* (inwatching) */; - _cmp(data.byte(kZoomon), 1); - if (flags.z()) - goto zoomswitch; - return; -zoomswitch: - _cmp(data.byte(kCommandtype), 199); - if (flags.c()) - goto zoomit; - putunderzoom(); - return; -zoomit: - ax = data.word(kOldpointery); - _sub(ax, 9); - cx = (320); - _mul(cx); - _add(ax, data.word(kOldpointerx)); - _sub(ax, 11); - si = ax; - ax = (132)+4; - cx = (320); - _mul(cx); - _add(ax, (8)+5); - di = ax; - es = data.word(kWorkspace); - ds = data.word(kWorkspace); - cx = 20; -zoomloop: - push(cx); - cx = 23; -zoomloop2: - _lodsb(); - ah = al; - _stosw(); - es.word(di+(320)-2) = ax; - if (--cx) - goto zoomloop2; - _add(si, (320)-23); - _add(di, (320)-46+(320)); - cx = pop(); - if (--cx) - goto zoomloop; - crosshair(); - data.byte(kDidzoom) = 1; -} - void DreamGenContext::delthisone() { STACK_CHECK; push(ax); @@ -3775,83 +2876,6 @@ deloneloop: goto deloneloop; } -void DreamGenContext::doblocks() { - STACK_CHECK; - es = data.word(kWorkspace); - ax = data.word(kMapady); - cx = (320); - _mul(cx); - di = data.word(kMapadx); - _add(di, ax); - al = data.byte(kMapy); - ah = 0; - bx = (66); - _mul(bx); - bl = data.byte(kMapx); - bh = 0; - _add(ax, bx); - si = (0); - _add(si, ax); - cx = 10; -loop120: - push(di); - push(cx); - cx = 11; -loop124: - push(cx); - push(di); - ds = data.word(kMapdata); - _lodsb(); - ds = data.word(kBackdrop); - push(si); - _cmp(al, 0); - if (flags.z()) - goto zeroblock; - ah = al; - al = 0; - si = (0+192); - _add(si, ax); - bh = 14; - bh = 4; -firstbitofblock: - _movsw(8); - _add(di, (320)-16); - _dec(bh); - if (!flags.z()) - goto firstbitofblock; - bh = 12; -loop125: - _movsw(8); - ax = 0x0dfdf; - _stosw(2); - _add(di, (320)-20); - _dec(bh); - if (!flags.z()) - goto loop125; - _add(di, 4); - ax = 0x0dfdf; - _stosw(8); - _add(di, (320)-16); - _stosw(8); - _add(di, (320)-16); - _stosw(8); - _add(di, (320)-16); - _stosw(8); -zeroblock: - si = pop(); - di = pop(); - cx = pop(); - _add(di, 16); - if (--cx) - goto loop124; - _add(si, (66)-11); - cx = pop(); - di = pop(); - _add(di, (320)*16); - if (--cx) - goto loop120; -} - void DreamGenContext::transferinv() { STACK_CHECK; di = data.word(kExframepos); @@ -7648,40 +6672,6 @@ blankframe: goto showobsloop; } -void DreamGenContext::makebackob() { - STACK_CHECK; - _cmp(data.byte(kNewobs), 0); - if (flags.z()) - return /* (nomake) */; - al = es.byte(si+5); - ah = es.byte(si+8); - push(si); - push(ax); - push(si); - ax = data.word(kObjectx); - bx = data.word(kObjecty); - ah = bl; - si = ax; - cx = 49520; - dx = data.word(kSetframes); - di = (0); - makesprite(); - ax = pop(); - es.word(bx+20) = ax; - ax = pop(); - _cmp(al, 255); - if (!flags.z()) - goto usedpriority; - al = 0; -usedpriority: - es.byte(bx+23) = al; - es.byte(bx+30) = ah; - es.byte(bx+16) = 0; - es.byte(bx+18) = 0; - es.byte(bx+19) = 0; - si = pop(); -} - void DreamGenContext::showallfree() { STACK_CHECK; es = data.word(kBuffers); @@ -12853,28 +11843,6 @@ notonsartroof: placesetobject(); } -void DreamGenContext::dumptimedtext() { - STACK_CHECK; - _cmp(data.byte(kNeedtodumptimed), 1); - if (!flags.z()) - return /* (nodumptimed) */; - al = data.byte(kTimedy); - _cmp(data.byte(kForeignrelease), 0); - if (flags.z()) - goto _tmp1; - _sub(al, 3); -_tmp1: - ah = 0; - bx = ax; - al = data.byte(kTimedx); - ah = 0; - di = ax; - cl = 240; - ch = (30); - multidump(); - data.byte(kNeedtodumptimed) = 0; -} - void DreamGenContext::setuptimeduse() { STACK_CHECK; _cmp(data.word(kTimecount), 0); @@ -12897,58 +11865,6 @@ void DreamGenContext::setuptimeduse() { data.word(kTimedoffset) = bx; } -void DreamGenContext::setuptimedtemp() { - STACK_CHECK; - _cmp(ah, 0); - if (flags.z()) - goto notloadspeech3; - push(ax); - push(bx); - push(cx); - push(dx); - dl = 'T'; - dh = ah; - cl = 'T'; - ah = 0; - loadspeech(); - _cmp(data.byte(kSpeechloaded), 1); - if (!flags.z()) - goto _tmp1; - al = 50+12; - playchannel1(); -_tmp1: - dx = pop(); - cx = pop(); - bx = pop(); - ax = pop(); - _cmp(data.byte(kSpeechloaded), 1); - if (!flags.z()) - goto notloadspeech3; - _cmp(data.byte(kSubtitles), 1); - if (flags.z()) - goto notloadspeech3; - return; -notloadspeech3: - _cmp(data.word(kTimecount), 0); - if (!flags.z()) - return /* (cantsetup2) */; - data.byte(kTimedy) = bh; - data.byte(kTimedx) = bl; - data.word(kCounttotimed) = cx; - _add(dx, cx); - data.word(kTimecount) = dx; - bl = al; - bh = 0; - _add(bx, bx); - es = data.word(kTextfile1); - cx = (66*2); - ax = es.word(bx); - _add(ax, cx); - bx = ax; - data.word(kTimedseg) = es; - data.word(kTimedoffset) = bx; -} - void DreamGenContext::edenscdplayer() { STACK_CHECK; showfirstuse(); @@ -16137,46 +15053,6 @@ notsecondbank1: es = pop(); } -void DreamGenContext::makenextblock() { - STACK_CHECK; - volumeadjust(); - loopchannel0(); - _cmp(data.word(kCh1blockstocopy), 0); - if (flags.z()) - goto mightbeonlych0; - _cmp(data.word(kCh0blockstocopy), 0); - if (flags.z()) - goto mightbeonlych1; - _dec(data.word(kCh0blockstocopy)); - _dec(data.word(kCh1blockstocopy)); - bothchannels(); - return; -mightbeonlych1: - data.byte(kCh0playing) = 255; - _cmp(data.word(kCh1blockstocopy), 0); - if (flags.z()) - return /* (notch1only) */; - _dec(data.word(kCh1blockstocopy)); - channel1only(); - return; -mightbeonlych0: - data.byte(kCh1playing) = 255; - _cmp(data.word(kCh0blockstocopy), 0); - if (flags.z()) - goto notch0only; - _dec(data.word(kCh0blockstocopy)); - channel0only(); - return; -notch0only: - es = data.word(kSoundbuffer); - di = data.word(kSoundbufferwrite); - cx = 1024; - ax = 0x7f7f; - _stosw(cx, true); - _and(di, 16384-1); - data.word(kSoundbufferwrite) = di; -} - void DreamGenContext::volumeadjust() { STACK_CHECK; al = data.byte(kVolumedirection); @@ -16198,162 +15074,6 @@ volfinish: data.byte(kVolumedirection) = 0; } -void DreamGenContext::loopchannel0() { - STACK_CHECK; - _cmp(data.word(kCh0blockstocopy), 0); - if (!flags.z()) - return /* (notloop) */; - _cmp(data.byte(kCh0repeat), 0); - if (flags.z()) - return /* (notloop) */; - _cmp(data.byte(kCh0repeat), 255); - if (flags.z()) - goto endlessloop; - _dec(data.byte(kCh0repeat)); -endlessloop: - ax = data.word(kCh0oldemmpage); - data.word(kCh0emmpage) = ax; - ax = data.word(kCh0oldoffset); - data.word(kCh0offset) = ax; - ax = data.word(kCh0blockstocopy); - _add(ax, data.word(kCh0oldblockstocopy)); - data.word(kCh0blockstocopy) = ax; -} - -void DreamGenContext::channel0tran() { - STACK_CHECK; - _cmp(data.byte(kVolume), 0); - if (!flags.z()) - goto lowvolumetran; - cx = 1024; - _movsw(cx, true); - return; -lowvolumetran: - cx = 1024; - bh = data.byte(kVolume); - bl = 0; - _add(bx, 16384-256); -volloop: - _lodsw(); - bl = al; - al = es.byte(bx); - bl = ah; - ah = es.byte(bx); - _stosw(); - if (--cx) - goto volloop; -} - -void DreamGenContext::domix() { - STACK_CHECK; - _cmp(data.byte(kVolume), 0); - if (!flags.z()) - goto lowvolumemix; -slow: - _lodsb(); - ah = ds.byte(bx); - _inc(bx); - _cmp(al, dh); - if (!flags.c()) - goto toplot; - _cmp(ah, dh); - if (!flags.c()) - goto nodistort; - _add(al, ah); - if (flags.s()) - goto botok; - _xor(al, al); - _stosb(); - if (--cx) - goto slow; - return /* (doneit) */; -botok: - _xor(al, dh); - _stosb(); - if (--cx) - goto slow; - return /* (doneit) */; -toplot: - _cmp(ah, dh); - if (flags.c()) - goto nodistort; - _add(al, ah); - if (!flags.s()) - goto topok; - al = dl; - _stosb(); - if (--cx) - goto slow; - return /* (doneit) */; -topok: - _xor(al, dh); - _stosb(); - if (--cx) - goto slow; - return /* (doneit) */; -nodistort: - _add(al, ah); - _xor(al, dh); - _stosb(); - if (--cx) - goto slow; - return /* (doneit) */; -lowvolumemix: - _lodsb(); - push(bx); - bh = data.byte(kVolume); - _add(bh, 63); - bl = al; - al = es.byte(bx); - bx = pop(); - ah = ds.byte(bx); - _inc(bx); - _cmp(al, dh); - if (!flags.c()) - goto toplotv; - _cmp(ah, dh); - if (!flags.c()) - goto nodistortv; - _add(al, ah); - if (flags.s()) - goto botokv; - _xor(al, al); - _stosb(); - if (--cx) - goto lowvolumemix; - return /* (doneit) */; -botokv: - _xor(al, dh); - _stosb(); - if (--cx) - goto lowvolumemix; - return /* (doneit) */; -toplotv: - _cmp(ah, dh); - if (flags.c()) - goto nodistortv; - _add(al, ah); - if (!flags.s()) - goto topokv; - al = dl; - _stosb(); - if (--cx) - goto lowvolumemix; - return /* (doneit) */; -topokv: - _xor(al, dh); - _stosb(); - if (--cx) - goto lowvolumemix; - return /* (doneit) */; -nodistortv: - _add(al, ah); - _xor(al, dh); - _stosb(); - if (--cx) - goto lowvolumemix; -} - void DreamGenContext::entrytexts() { STACK_CHECK; _cmp(data.byte(kLocation), 21); @@ -16776,84 +15496,6 @@ void DreamGenContext::clearrest() { deallocatemem(); } -void DreamGenContext::parseblaster() { - STACK_CHECK; -lookattail: - al = es.byte(bx); - _cmp(al, 0); - if (flags.z()) - return /* (endtail) */; - _cmp(al, 13); - if (flags.z()) - return /* (endtail) */; - _cmp(al, 'i'); - if (flags.z()) - goto issoundint; - _cmp(al, 'I'); - if (flags.z()) - goto issoundint; - _cmp(al, 'b'); - if (flags.z()) - goto isbright; - _cmp(al, 'B'); - if (flags.z()) - goto isbright; - _cmp(al, 'a'); - if (flags.z()) - goto isbaseadd; - _cmp(al, 'A'); - if (flags.z()) - goto isbaseadd; - _cmp(al, 'n'); - if (flags.z()) - goto isnosound; - _cmp(al, 'N'); - if (flags.z()) - goto isnosound; - _cmp(al, 'd'); - if (flags.z()) - goto isdma; - _cmp(al, 'D'); - if (flags.z()) - goto isdma; - _inc(bx); - if (--cx) - goto lookattail; - return; -issoundint: - al = es.byte(bx+1); - _sub(al, '0'); - data.byte(kSoundint) = al; - _inc(bx); - goto lookattail; -isdma: - al = es.byte(bx+1); - _sub(al, '0'); - data.byte(kSounddmachannel) = al; - _inc(bx); - goto lookattail; -isbaseadd: - push(cx); - al = es.byte(bx+2); - _sub(al, '0'); - ah = 0; - cl = 4; - _shl(ax, cl); - _add(ax, 0x200); - data.word(kSoundbaseadd) = ax; - cx = pop(); - _inc(bx); - goto lookattail; -isbright: - data.byte(kBrightness) = 1; - _inc(bx); - goto lookattail; -isnosound: - data.byte(kSoundint) = 255; - _inc(bx); - goto lookattail; -} - void DreamGenContext::startup() { STACK_CHECK; data.byte(kCurrentkey) = 0; @@ -17488,69 +16130,6 @@ nothingund: blank(); } -void DreamGenContext::checkifperson() { - STACK_CHECK; - es = data.word(kBuffers); - bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)); - cx = 12; -identifyreel: - push(cx); - _cmp(es.byte(bx+4), 255); - if (flags.z()) - goto notareelid; - push(es); - push(bx); - push(ax); - ax = es.word(bx+0); - data.word(kReelpointer) = ax; - getreelstart(); - _cmp(es.word(si+2), 0x0ffff); - if (!flags.z()) - goto notblankpers; - _add(si, 5); -notblankpers: - cx = es.word(si+2); - ax = es.word(si+0); - push(cx); - getreelframeax(); - cx = pop(); - _add(cl, es.byte(bx+4)); - _add(ch, es.byte(bx+5)); - dx = cx; - _add(dl, es.byte(bx+0)); - _add(dh, es.byte(bx+1)); - ax = pop(); - bx = pop(); - es = pop(); - _cmp(al, cl); - if (flags.c()) - goto notareelid; - _cmp(ah, ch); - if (flags.c()) - goto notareelid; - _cmp(al, dl); - if (!flags.c()) - goto notareelid; - _cmp(ah, dh); - if (!flags.c()) - goto notareelid; - cx = pop(); - ax = es.word(bx+2); - data.word(kPersondata) = ax; - al = es.byte(bx+4); - ah = 5; - obname(); - al = 0; - _cmp(al, 1); - return; -notareelid: - cx = pop(); - _add(bx, 5); - _dec(cx); - if (!flags.z()) - goto identifyreel; -} - void DreamGenContext::checkifset() { STACK_CHECK; es = data.word(kBuffers); @@ -18184,60 +16763,6 @@ void DreamGenContext::examineobtext() { commandwithob(); } -void DreamGenContext::commandwithob() { - STACK_CHECK; - push(ax); - push(ax); - push(bx); - push(cx); - push(dx); - push(es); - push(ds); - push(si); - push(di); - deltextline(); - di = pop(); - si = pop(); - ds = pop(); - es = pop(); - dx = pop(); - cx = pop(); - bx = pop(); - ax = pop(); - push(bx); - ah = 0; - _add(ax, ax); - bx = ax; - es = data.word(kCommandtext); - ax = es.word(bx); - _add(ax, (66*2)); - si = ax; - di = data.word(kTextaddressx); - bx = data.word(kTextaddressy); - dl = data.byte(kTextlen); - al = 0; - ah = 0; - printdirect(); - ax = pop(); - di = 5847; - copyname(); - ax = pop(); - di = data.word(kLastxpos); - _cmp(al, 0); - if (flags.z()) - goto noadd; - _add(di, 5); -noadd: - bx = data.word(kTextaddressy); - es = cs; - si = 5847; - dl = data.byte(kTextlen); - al = 0; - ah = 0; - printdirect(); - data.byte(kNewtextline) = 1; -} - void DreamGenContext::commandonly() { STACK_CHECK; push(ax); @@ -18402,109 +16927,6 @@ holdingreel: data.byte(kWatchmode) = 2; } -void DreamGenContext::autosetwalk() { - STACK_CHECK; - al = data.byte(kManspath); - _cmp(data.byte(kFinaldest), al); - if (!flags.z()) - goto notsamealready; - return; -notsamealready: - getroomspaths(); - checkdest(); - push(bx); - al = data.byte(kManspath); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = es.byte(bx); - ah = 0; - _sub(ax, 12); - data.word(kLinestartx) = ax; - al = es.byte(bx+1); - ah = 0; - _sub(ax, 12); - data.word(kLinestarty) = ax; - bx = pop(); - al = data.byte(kDestination); - ah = 0; - _add(ax, ax); - _add(ax, ax); - _add(ax, ax); - _add(bx, ax); - al = es.byte(bx); - ah = 0; - _sub(ax, 12); - data.word(kLineendx) = ax; - al = es.byte(bx+1); - ah = 0; - _sub(ax, 12); - data.word(kLineendy) = ax; - bresenhams(); - _cmp(data.byte(kLinedirection), 0); - if (flags.z()) - goto normalline; - al = data.byte(kLinelength); - _dec(al); - data.byte(kLinepointer) = al; - data.byte(kLinedirection) = 1; - return; -normalline: - data.byte(kLinepointer) = 0; -} - -void DreamGenContext::checkdest() { - STACK_CHECK; - push(bx); - _add(bx, 12*8); - ah = data.byte(kManspath); - cl = 4; - _shl(ah, cl); - al = data.byte(kDestination); - cl = 24; - ch = data.byte(kDestination); -checkdestloop: - dh = es.byte(bx); - _and(dh, 0xf0); - dl = es.byte(bx); - _and(dl, 0xf); - _cmp(ax, dx); - if (!flags.z()) - goto nextcheck; - al = es.byte(bx+1); - _and(al, 15); - data.byte(kDestination) = al; - bx = pop(); - return; -nextcheck: - dl = es.byte(bx); - _and(dl, 0xf0); - _shr(dl, 1); - _shr(dl, 1); - _shr(dl, 1); - _shr(dl, 1); - dh = es.byte(bx); - _and(dh, 0xf); - _shl(dh, 1); - _shl(dh, 1); - _shl(dh, 1); - _shl(dh, 1); - _cmp(ax, dx); - if (!flags.z()) - goto nextcheck2; - ch = es.byte(bx+1); - _and(ch, 15); -nextcheck2: - _add(bx, 2); - _dec(cl); - if (!flags.z()) - goto checkdestloop; - data.byte(kDestination) = ch; - bx = pop(); -} - void DreamGenContext::bresenhams() { STACK_CHECK; workoutframes(); @@ -18720,106 +17142,6 @@ success: data.byte(kTurndirection) = 0; } -void DreamGenContext::getroomspaths() { - STACK_CHECK; - al = data.byte(kRoomnum); - ah = 0; - cx = 144; - _mul(cx); - es = data.word(kReels); - bx = (0); - _add(bx, ax); -} - -void DreamGenContext::copyname() { - STACK_CHECK; - push(di); - findobname(); - di = pop(); - es = cs; - cx = 28; -make: - _lodsb(); - _cmp(al, ':'); - if (flags.z()) - goto finishmakename; - _cmp(al, 0); - if (flags.z()) - goto finishmakename; - _stosb(); - if (--cx) - goto make; -finishmakename: - _inc(cx); - al = 0; - _stosb(); - return; - al = 255; - _stosb(cx, true); -} - -void DreamGenContext::findobname() { - STACK_CHECK; - push(ax); - ah = 0; - _add(ax, ax); - bx = ax; - ax = pop(); - _cmp(ah, 5); - if (!flags.z()) - goto notpersonname; - push(ax); - _and(al, 127); - ah = 0; - bx = 64*2; - _mul(bx); - si = ax; - ds = data.word(kPeople); - _add(si, (0+24)); - cx = (0+24+(1026*2)); - ax = ds.word(si); - _add(ax, cx); - si = ax; - ax = pop(); - return; -notpersonname: - _cmp(ah, 4); - if (!flags.z()) - goto notextraname; - ds = data.word(kExtras); - _add(bx, (0+2080+30000+(16*114))); - ax = ds.word(bx); - _add(ax, (0+2080+30000+(16*114)+((114+2)*2))); - si = ax; - return; -notextraname: - _cmp(ah, 2); - if (!flags.z()) - goto notfreename; - ds = data.word(kFreedesc); - _add(bx, (0)); - ax = ds.word(bx); - _add(ax, (0+(82*2))); - si = ax; - return; -notfreename: - _cmp(ah, 1); - if (!flags.z()) - goto notsetname; - ds = data.word(kSetdesc); - _add(bx, (0)); - ax = ds.word(bx); - _add(ax, (0+(130*2))); - si = ax; - return; -notsetname: - ds = data.word(kBlockdesc); - _add(bx, (0)); - ax = ds.word(bx); - _add(ax, (0+(98*2))); - si = ax; -} - void DreamGenContext::showicon() { STACK_CHECK; _cmp(data.byte(kReallocation), 50); @@ -18924,22 +17246,6 @@ void DreamGenContext::showman() { showframe(); } -void DreamGenContext::showpanel() { - STACK_CHECK; - ds = data.word(kIcons1); - di = 72; - bx = 0; - al = 19; - ah = 0; - showframe(); - ds = data.word(kIcons1); - di = 192; - bx = 0; - al = 19; - ah = 0; - showframe(); -} - void DreamGenContext::roomname() { STACK_CHECK; di = 88; @@ -19248,32 +17554,6 @@ void DreamGenContext::putunderzoom() { multiput(); } -void DreamGenContext::crosshair() { - STACK_CHECK; - _cmp(data.byte(kCommandtype), 3); - if (flags.z()) - goto nocross; - _cmp(data.byte(kCommandtype), 10); - if (!flags.c()) - goto nocross; - es = data.word(kWorkspace); - ds = data.word(kIcons1); - di = (8)+24; - bx = (132)+19; - al = 9; - ah = 0; - showframe(); - return; -nocross: - es = data.word(kWorkspace); - ds = data.word(kIcons1); - di = (8)+24; - bx = (132)+19; - al = 29; - ah = 0; - showframe(); -} - void DreamGenContext::showpointer() { STACK_CHECK; showblink(); @@ -19446,22 +17726,6 @@ _tmp1: multiget(); } -void DreamGenContext::deltextline() { - STACK_CHECK; - di = data.word(kTextaddressx); - bx = data.word(kTextaddressy); - _cmp(data.byte(kForeignrelease), 0); - if (flags.z()) - goto _tmp1; - _sub(bx, 3); -_tmp1: - ds = data.word(kBuffers); - si = (0); - cl = (228); - ch = (13); - multiput(); -} - void DreamGenContext::animpointer() { STACK_CHECK; _cmp(data.byte(kPointermode), 2); @@ -19941,142 +18205,6 @@ blimey: es = pop(); } -void DreamGenContext::startloading() { - STACK_CHECK; - data.byte(kCombatcount) = 0; - al = cs.byte(bx+13); - data.byte(kRoomssample) = al; - al = cs.byte(bx+15); - data.byte(kMapx) = al; - al = cs.byte(bx+16); - data.byte(kMapy) = al; - al = cs.byte(bx+20); - data.byte(kLiftflag) = al; - al = cs.byte(bx+21); - data.byte(kManspath) = al; - data.byte(kDestination) = al; - data.byte(kFinaldest) = al; - al = cs.byte(bx+22); - data.byte(kFacing) = al; - data.byte(kTurntoface) = al; - al = cs.byte(bx+23); - data.byte(kCounttoopen) = al; - al = cs.byte(bx+24); - data.byte(kLiftpath) = al; - al = cs.byte(bx+25); - data.byte(kDoorpath) = al; - data.byte(kLastweapon) = -1; - al = cs.byte(bx+27); - push(ax); - al = cs.byte(bx+31); - ah = data.byte(kReallocation); - data.byte(kReallocation) = al; - dx = bx; - openfile(); - 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(); - _cmp(al, 255); - if (flags.z()) - goto dontwalkin; - data.byte(kManspath) = al; - push(bx); - autosetwalk(); - bx = pop(); -dontwalkin: - findxyfrompath(); -} - void DreamGenContext::disablepath() { STACK_CHECK; push(cx); @@ -20146,25 +18274,6 @@ lookx: data.byte(kRoomnum) = cl; } -void DreamGenContext::getroomdata() { - STACK_CHECK; - ah = 0; - cx = 32; - _mul(cx); - bx = 6187; - _add(bx, ax); -} - -void DreamGenContext::readheader() { - STACK_CHECK; - ds = cs; - dx = 6091; - cx = (6187-6091); - readfromfile(); - es = cs; - di = 6141; -} - void DreamGenContext::allocateload() { STACK_CHECK; push(es); @@ -20177,23 +18286,6 @@ void DreamGenContext::allocateload() { es = pop(); } -void DreamGenContext::fillspace() { - STACK_CHECK; - push(es); - push(ds); - push(dx); - push(di); - push(bx); - di = dx; - es = ds; - _stosb(cx, true); - bx = pop(); - di = pop(); - dx = pop(); - ds = pop(); - es = pop(); -} - void DreamGenContext::getridoftemp() { STACK_CHECK; es = data.word(kTempgraphics); @@ -20912,8 +19004,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_priest: priest(); break; case addr_madmanstelly: madmanstelly(); break; case addr_madman: madman(); break; - case addr_madmantext: madmantext(); break; - case addr_madmode: madmode(); break; case addr_priesttext: priesttext(); break; case addr_textforend: textforend(); break; case addr_textformonk: textformonk(); break; @@ -20923,14 +19013,10 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_sparky: sparky(); break; case addr_train: train(); break; case addr_addtopeoplelist: addtopeoplelist(); break; - case addr_showgamereel: showgamereel(); break; case addr_checkspeed: checkspeed(); break; case addr_delsprite: delsprite(); break; case addr_checkone: checkone(); break; - case addr_findsource: findsource(); break; case addr_mainman: mainman(); break; - case addr_aboutturn: aboutturn(); break; - case addr_facerightway: facerightway(); break; case addr_checkforexit: checkforexit(); break; case addr_adjustdown: adjustdown(); break; case addr_adjustup: adjustup(); break; @@ -20940,28 +19026,16 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_initrain: initrain(); break; case addr_splitintolines: splitintolines(); break; case addr_getblockofpixel: getblockofpixel(); break; - case addr_showrain: showrain(); break; case addr_backobject: backobject(); break; case addr_liftnoise: liftnoise(); break; case addr_random: random(); break; case addr_steady: steady(); break; case addr_constant: constant(); break; - case addr_doorway: doorway(); break; - case addr_widedoor: widedoor(); break; - case addr_lockeddoorway: lockeddoorway(); break; - case addr_updatepeople: updatepeople(); break; - case addr_getreelframeax: getreelframeax(); break; case addr_reelsonscreen: reelsonscreen(); break; - case addr_plotreel: plotreel(); break; case addr_soundonreels: soundonreels(); break; case addr_reconstruct: reconstruct(); break; - case addr_dealwithspecial: dealwithspecial(); break; - case addr_movemap: movemap(); break; - case addr_getreelstart: getreelstart(); break; - case addr_showreelframe: showreelframe(); break; case addr_deleverything: deleverything(); break; case addr_dumpeverything: dumpeverything(); break; - case addr_allocatework: allocatework(); break; case addr_showpcx: showpcx(); break; case addr_loadpalfromiff: loadpalfromiff(); break; case addr_setmode: setmode(); break; @@ -20971,12 +19045,9 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_pixelcheckset: pixelcheckset(); break; case addr_createpanel: createpanel(); break; case addr_createpanel2: createpanel2(); break; - case addr_clearwork: clearwork(); break; case addr_vsync: vsync(); break; case addr_doshake: doshake(); break; - case addr_zoom: zoom(); break; case addr_delthisone: delthisone(); break; - case addr_doblocks: doblocks(); break; case addr_transferinv: transferinv(); break; case addr_transfermap: transfermap(); break; case addr_fadedos: fadedos(); break; @@ -21099,7 +19170,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_addlength: addlength(); break; case addr_drawflags: drawflags(); break; case addr_showallobs: showallobs(); break; - case addr_makebackob: makebackob(); break; case addr_showallfree: showallfree(); break; case addr_showallex: showallex(); break; case addr_calcfrframe: calcfrframe(); break; @@ -21276,9 +19346,7 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_setallchanges: setallchanges(); break; case addr_dochange: dochange(); break; case addr_autoappear: autoappear(); break; - case addr_dumptimedtext: dumptimedtext(); break; case addr_setuptimeduse: setuptimeduse(); break; - case addr_setuptimedtemp: setuptimedtemp(); break; case addr_edenscdplayer: edenscdplayer(); break; case addr_usewall: usewall(); break; case addr_usechurchgate: usechurchgate(); break; @@ -21398,16 +19466,12 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_out22c: out22c(); break; case addr_playchannel0: playchannel0(); break; case addr_playchannel1: playchannel1(); break; - case addr_makenextblock: makenextblock(); break; case addr_volumeadjust: volumeadjust(); break; - case addr_loopchannel0: loopchannel0(); break; case addr_channel0only: channel0only(); break; case addr_channel1only: channel1only(); break; - case addr_channel0tran: channel0tran(); break; case addr_bothchannels: bothchannels(); break; case addr_saveems: saveems(); break; case addr_restoreems: restoreems(); break; - case addr_domix: domix(); break; case addr_dmaend: dmaend(); break; case addr_startdmablock: startdmablock(); break; case addr_setuppit: setuppit(); break; @@ -21430,7 +19494,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_clearrest: clearrest(); break; case addr_deallocatemem: deallocatemem(); break; case addr_allocatemem: allocatemem(); break; - case addr_parseblaster: parseblaster(); break; case addr_startup: startup(); break; case addr_startup1: startup1(); break; case addr_screenupdate: screenupdate(); break; @@ -21448,7 +19511,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_madmanrun: madmanrun(); break; case addr_checkcoords: checkcoords(); break; case addr_identifyob: identifyob(); break; - case addr_checkifperson: checkifperson(); break; case addr_checkifset: checkifset(); break; case addr_checkifex: checkifex(); break; case addr_checkiffree: checkiffree(); break; @@ -21467,7 +19529,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_obname: obname(); break; case addr_finishedwalking: finishedwalking(); break; case addr_examineobtext: examineobtext(); break; - case addr_commandwithob: commandwithob(); break; case addr_commandonly: commandonly(); break; case addr_printmessage: printmessage(); break; case addr_printmessage2: printmessage2(); break; @@ -21476,17 +19537,11 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_walktotext: walktotext(); break; case addr_getflagunderp: getflagunderp(); break; case addr_setwalk: setwalk(); break; - case addr_autosetwalk: autosetwalk(); break; - case addr_checkdest: checkdest(); break; case addr_bresenhams: bresenhams(); break; case addr_workoutframes: workoutframes(); break; - case addr_getroomspaths: getroomspaths(); break; - case addr_copyname: copyname(); break; - case addr_findobname: findobname(); break; case addr_showicon: showicon(); break; case addr_middlepanel: middlepanel(); break; case addr_showman: showman(); break; - case addr_showpanel: showpanel(); break; case addr_roomname: roomname(); break; case addr_usecharset1: usecharset1(); break; case addr_usetempcharset: usetempcharset(); break; @@ -21506,12 +19561,10 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_getunderzoom: getunderzoom(); break; case addr_dumpzoom: dumpzoom(); break; case addr_putunderzoom: putunderzoom(); break; - case addr_crosshair: crosshair(); break; case addr_showpointer: showpointer(); break; case addr_delpointer: delpointer(); break; case addr_dumppointer: dumppointer(); break; case addr_undertextline: undertextline(); break; - case addr_deltextline: deltextline(); break; case addr_animpointer: animpointer(); break; case addr_setmouse: setmouse(); break; case addr_readmouse: readmouse(); break; @@ -21538,15 +19591,11 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_restorereels: restorereels(); break; case addr_restoreall: restoreall(); break; case addr_sortoutmap: sortoutmap(); break; - case addr_startloading: startloading(); break; case addr_disablepath: disablepath(); break; case addr_findxyfrompath: findxyfrompath(); break; case addr_findroominloc: findroominloc(); break; - case addr_getroomdata: getroomdata(); break; - case addr_readheader: readheader(); break; case addr_dontloadseg: dontloadseg(); break; case addr_allocateload: allocateload(); break; - case addr_fillspace: fillspace(); break; case addr_getridoftemp: getridoftemp(); break; case addr_getridoftemptext: getridoftemptext(); break; case addr_getridoftemp2: getridoftemp2(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index c2aa204942..e1071dfebc 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -57,15 +57,11 @@ public: static const uint16 addr_getridoftemp2 = 0xcb78; static const uint16 addr_getridoftemptext = 0xcb74; static const uint16 addr_getridoftemp = 0xcb70; - static const uint16 addr_fillspace = 0xcb6c; static const uint16 addr_allocateload = 0xcb68; static const uint16 addr_dontloadseg = 0xcb64; - static const uint16 addr_readheader = 0xcb60; - static const uint16 addr_getroomdata = 0xcb5c; static const uint16 addr_findroominloc = 0xcb58; static const uint16 addr_findxyfrompath = 0xcb54; static const uint16 addr_disablepath = 0xcb50; - static const uint16 addr_startloading = 0xcb4c; static const uint16 addr_sortoutmap = 0xcb48; static const uint16 addr_restoreall = 0xcb44; static const uint16 addr_restorereels = 0xcb40; @@ -92,12 +88,10 @@ public: static const uint16 addr_readmouse = 0xcae4; static const uint16 addr_setmouse = 0xcae0; static const uint16 addr_animpointer = 0xcadc; - static const uint16 addr_deltextline = 0xcad4; static const uint16 addr_undertextline = 0xcad0; static const uint16 addr_dumppointer = 0xcacc; static const uint16 addr_delpointer = 0xcac8; static const uint16 addr_showpointer = 0xcac4; - static const uint16 addr_crosshair = 0xcac0; static const uint16 addr_putunderzoom = 0xcabc; static const uint16 addr_dumpzoom = 0xcab8; static const uint16 addr_getunderzoom = 0xcab4; @@ -117,17 +111,11 @@ public: static const uint16 addr_usetempcharset = 0xca7c; static const uint16 addr_usecharset1 = 0xca78; static const uint16 addr_roomname = 0xca74; - static const uint16 addr_showpanel = 0xca70; static const uint16 addr_showman = 0xca6c; static const uint16 addr_middlepanel = 0xca68; static const uint16 addr_showicon = 0xca64; - static const uint16 addr_findobname = 0xca60; - static const uint16 addr_copyname = 0xca5c; - static const uint16 addr_getroomspaths = 0xca58; static const uint16 addr_workoutframes = 0xca54; static const uint16 addr_bresenhams = 0xca50; - static const uint16 addr_checkdest = 0xca4c; - static const uint16 addr_autosetwalk = 0xca48; static const uint16 addr_setwalk = 0xca44; static const uint16 addr_getflagunderp = 0xca40; static const uint16 addr_walktotext = 0xca3c; @@ -136,7 +124,6 @@ public: static const uint16 addr_printmessage2 = 0xca30; static const uint16 addr_printmessage = 0xca2c; static const uint16 addr_commandonly = 0xca28; - static const uint16 addr_commandwithob = 0xca24; static const uint16 addr_examineobtext = 0xca20; static const uint16 addr_finishedwalking = 0xca1c; static const uint16 addr_obname = 0xca18; @@ -155,7 +142,6 @@ public: static const uint16 addr_checkiffree = 0xc9e4; static const uint16 addr_checkifex = 0xc9e0; static const uint16 addr_checkifset = 0xc9dc; - static const uint16 addr_checkifperson = 0xc9d8; static const uint16 addr_identifyob = 0xc9d4; static const uint16 addr_checkcoords = 0xc9d0; static const uint16 addr_madmanrun = 0xc9cc; @@ -174,7 +160,6 @@ public: static const uint16 addr_screenupdate = 0xc99c; static const uint16 addr_startup1 = 0xc998; static const uint16 addr_startup = 0xc994; - static const uint16 addr_parseblaster = 0xc990; static const uint16 addr_allocatemem = 0xc988; static const uint16 addr_deallocatemem = 0xc984; static const uint16 addr_clearrest = 0xc980; @@ -196,16 +181,12 @@ public: static const uint16 addr_setuppit = 0xc93c; static const uint16 addr_startdmablock = 0xc938; static const uint16 addr_dmaend = 0xc934; - static const uint16 addr_domix = 0xc930; static const uint16 addr_restoreems = 0xc92c; static const uint16 addr_saveems = 0xc928; static const uint16 addr_bothchannels = 0xc924; - static const uint16 addr_channel0tran = 0xc920; static const uint16 addr_channel1only = 0xc91c; static const uint16 addr_channel0only = 0xc918; - static const uint16 addr_loopchannel0 = 0xc90c; static const uint16 addr_volumeadjust = 0xc908; - static const uint16 addr_makenextblock = 0xc904; static const uint16 addr_playchannel1 = 0xc900; static const uint16 addr_playchannel0 = 0xc8fc; static const uint16 addr_out22c = 0xc8f8; @@ -327,9 +308,7 @@ public: static const uint16 addr_usechurchgate = 0xc730; static const uint16 addr_usewall = 0xc72c; static const uint16 addr_edenscdplayer = 0xc728; - static const uint16 addr_setuptimedtemp = 0xc720; static const uint16 addr_setuptimeduse = 0xc71c; - static const uint16 addr_dumptimedtext = 0xc718; static const uint16 addr_autoappear = 0xc70c; static const uint16 addr_dochange = 0xc708; static const uint16 addr_setallchanges = 0xc704; @@ -506,7 +485,6 @@ public: static const uint16 addr_calcfrframe = 0xc454; static const uint16 addr_showallex = 0xc450; static const uint16 addr_showallfree = 0xc44c; - static const uint16 addr_makebackob = 0xc448; static const uint16 addr_showallobs = 0xc444; static const uint16 addr_drawflags = 0xc43c; static const uint16 addr_addlength = 0xc438; @@ -629,12 +607,9 @@ public: static const uint16 addr_fadedos = 0xc248; static const uint16 addr_transfermap = 0xc244; static const uint16 addr_transferinv = 0xc240; - static const uint16 addr_doblocks = 0xc228; static const uint16 addr_delthisone = 0xc214; - static const uint16 addr_zoom = 0xc210; static const uint16 addr_doshake = 0xc20c; static const uint16 addr_vsync = 0xc208; - static const uint16 addr_clearwork = 0xc204; static const uint16 addr_createpanel2 = 0xc200; static const uint16 addr_createpanel = 0xc1fc; static const uint16 addr_pixelcheckset = 0xc1f8; @@ -644,28 +619,16 @@ public: static const uint16 addr_setmode = 0xc1dc; static const uint16 addr_loadpalfromiff = 0xc1d8; static const uint16 addr_showpcx = 0xc1cc; - static const uint16 addr_allocatework = 0xc1c8; static const uint16 addr_dumpeverything = 0xc1c4; static const uint16 addr_deleverything = 0xc1c0; - static const uint16 addr_showreelframe = 0xc1bc; - static const uint16 addr_getreelstart = 0xc1b8; - static const uint16 addr_movemap = 0xc1b4; - static const uint16 addr_dealwithspecial = 0xc1b0; static const uint16 addr_reconstruct = 0xc1ac; static const uint16 addr_soundonreels = 0xc1a8; - static const uint16 addr_plotreel = 0xc1a4; static const uint16 addr_reelsonscreen = 0xc1a0; - static const uint16 addr_getreelframeax = 0xc19c; - static const uint16 addr_updatepeople = 0xc198; - static const uint16 addr_lockeddoorway = 0xc194; - static const uint16 addr_widedoor = 0xc18c; - static const uint16 addr_doorway = 0xc188; static const uint16 addr_constant = 0xc184; static const uint16 addr_steady = 0xc180; static const uint16 addr_random = 0xc17c; static const uint16 addr_liftnoise = 0xc178; static const uint16 addr_backobject = 0xc170; - static const uint16 addr_showrain = 0xc16c; static const uint16 addr_getblockofpixel = 0xc168; static const uint16 addr_splitintolines = 0xc164; static const uint16 addr_initrain = 0xc160; @@ -675,14 +638,10 @@ public: static const uint16 addr_adjustup = 0xc150; static const uint16 addr_adjustdown = 0xc14c; static const uint16 addr_checkforexit = 0xc148; - static const uint16 addr_facerightway = 0xc144; - static const uint16 addr_aboutturn = 0xc13c; static const uint16 addr_mainman = 0xc138; - static const uint16 addr_findsource = 0xc130; static const uint16 addr_checkone = 0xc12c; static const uint16 addr_delsprite = 0xc11c; static const uint16 addr_checkspeed = 0xc110; - static const uint16 addr_showgamereel = 0xc10c; static const uint16 addr_addtopeoplelist = 0xc108; static const uint16 addr_train = 0xc104; static const uint16 addr_sparky = 0xc100; @@ -692,8 +651,6 @@ public: static const uint16 addr_textformonk = 0xc0f0; static const uint16 addr_textforend = 0xc0ec; static const uint16 addr_priesttext = 0xc0e8; - static const uint16 addr_madmode = 0xc0e4; - static const uint16 addr_madmantext = 0xc0e0; static const uint16 addr_madman = 0xc0dc; static const uint16 addr_madmanstelly = 0xc0d8; static const uint16 addr_priest = 0xc0d4; @@ -1323,10 +1280,10 @@ public: void bothchannels(); void usewire(); void getnamepos(); - void drawitall(); + void loadtemptext(); void clearstartpal(); void femalefan(); - void showgamereel(); + //void showgamereel(); void identifyob(); void trysoundalloc(); void uselighter(); @@ -1338,7 +1295,7 @@ public: void clearbuffers(); void neterror(); void storeit(); - void lockeddoorway(); + //void lockeddoorway(); void isitworn(); //void putundertimed(); void dumpmap(); @@ -1356,14 +1313,14 @@ public: void readkey(); void louis(); void entrytexts(); - void getreelstart(); + //void getreelstart(); void buttonenter(); void checkinput(); - void crosshair(); + //void crosshair(); void bresenhams(); void getbackfromops(); //void frameoutv(); - void restoreall(); + void opensarters(); void screenupdate(); void addlength(); void wornerror(); @@ -1372,29 +1329,32 @@ public: void commandonly(); void adjustlen(); void deallocatemem(); - void mainscreen(); + void checkforemm(); void watchreel(); void showfolder(); void turnanypathoff(); void openfilefromc(); void gettime(); - void clearwork(); + //void clearwork(); void loadtraveltext(); //void worktoscreen(); void getexpos(); void fadedos(); + //void fillspace(); //void multiget(); + //void autosetwalk(); void fadeupmonfirst(); void drawfloor(); void loadkeypad(); - void findsource(); + //void findsource(); void clearendpal(); void findtext1(); void isryanholding(); - void interupttest(); + void showslots(); void usecashcard(); void usewall(); void opentomb(); + //void findobname(); void buttonfour(); void animpointer(); //void lockmon(); @@ -1409,8 +1369,8 @@ public: void additionaltext(); //void kernchars(); void othersmoker(); - void autosetwalk(); - void setuptimedtemp(); + void dofade(); + //void setuptimedtemp(); void blocknametext(); void useelevator5(); void useelevator4(); @@ -1420,13 +1380,13 @@ public: void useelevator2(); void buttonone(); void keyboardread(); - void deltextline(); + //void deltextline(); void entercode(); void getopenedsize(); void getpersframe(); void doshake(); void resetkeyboard(); - void showpanel(); + //void showpanel(); void soundstartup(); void slabdoora(); void fadeupyellows(); @@ -1450,17 +1410,16 @@ public: void eden(); void showdiary(); void purgealocation(); - void updatepeople(); + //void updatepeople(); void slabdoorf(); void addtopeoplelist(); void hangoncurs(); void sparkydrip(); - //void modifychar(); void compare(); void printcurs(); //void convertkey(); void outofopen(); - void dealwithspecial(); + //void dealwithspecial(); //void eraseoldobs(); void dircom(); //void liftsprite(); @@ -1473,8 +1432,8 @@ public: void fadescreenup(); void loadold(); void loadtempcharset(); + void showbyte(); void useslab(); - void aboutturn(); void usealtar(); void createpanel2(); void turnonpower(); @@ -1488,7 +1447,7 @@ public: void endgame(); void monprint(); void usepipe(); - void startloading(); + //void startloading(); void getunderzoom(); void candles(); void backobject(); @@ -1496,7 +1455,7 @@ public: void reminders(); void selectslot2(); void runtap(); - void domix(); + //void domix(); void priesttext(); void paneltomap(); void obname(); @@ -1508,13 +1467,11 @@ public: void disablesoundint(); void checkifset(); void showallex(); - void showrain(); void openpoolboss(); void buttontwo(); - void fillopen(); //void usetimedtext(); void delsprite(); - void getroomspaths(); + //void getroomspaths(); //void dumptextline(); void fadescreendownhalf(); void useplate(); @@ -1524,9 +1481,10 @@ public: void isitdescribed(); void hotelbell(); void loadspeech(); + void interupttest(); //void cls(); //void printsprites(); - void checkifperson(); + //void checkifperson(); void showallobs(); //void getnumber(); void adjustleft(); @@ -1546,6 +1504,7 @@ public: //void printchar(); void showkeypad(); void obtoinv(); + //void getroomdata(); void removeobfrominv(); void usecoveredbox(); void openyourneighbour(); @@ -1562,7 +1521,7 @@ public: void discops(); //void printdirect(); void delthisone(); - void makebackob(); + //void makebackob(); void middlepanel(); void dumpwatch(); void saveload(); @@ -1577,8 +1536,8 @@ public: void locklightoff(); void wearwatch(); void runintroseq(); - void doblocks(); - void showbyte(); + //void doblocks(); + void restoreall(); void allpalette(); void findormake(); void nextsymbol(); @@ -1593,14 +1552,14 @@ public: void folderhints(); void openhoteldoor(); void removesetobject(); - void dumptimedtext(); + //void dumptimedtext(); //void frameoutfx(); void blank(); void drinker(); void nextcolon(); void placefreeobject(); void delpointer(); - void loopchannel0(); + //void loopchannel0(); void initrain(); void showleftpage(); void rockstar(); @@ -1635,7 +1594,7 @@ public: void showpointer(); void usecooker(); void loadmenu(); - void checkforemm(); + //void aboutturn(); void checkifpathison(); void smallcandle(); void receptionist(); @@ -1656,7 +1615,7 @@ public: void putundermenu(); void checkifex(); void intromagic2(); - void findobname(); + void mainscreen(); void edeninbath(); void intromagic1(); void showdiarypage(); @@ -1671,12 +1630,12 @@ public: void steady(); void pixelcheckset(); void reexfrominv(); - void fillspace(); + void examinventory(); void talk(); void usedryer(); void dumpeverything(); void usehatch(); - void zoom(); + //void zoom(); void outofinv(); void viewfolder(); //void walking(); @@ -1690,7 +1649,7 @@ public: void playguitar(); void lastfolder(); void transfermap(); - void showreelframe(); + //void showreelframe(); void showmonk(); void diarykeyn(); void set16colpalette(); @@ -1711,7 +1670,7 @@ public: void getridofpit(); void convnum(); void nothelderror(); - void readheader(); + //void readheader(); void getsetad(); void getyad(); void reconstruct(); @@ -1778,11 +1737,10 @@ public: void loadintotemp2(); void gamer(); void personnametext(); - void quitsymbol(); void readfromfile(); void initialinv(); - void showslots(); - void dofade(); + void quitsymbol(); + //void modifychar(); void hangon(); void settopright(); void findsetobject(); @@ -1809,14 +1767,15 @@ public: void scrollmonitor(); void setsoundoff(); void setpickup(); + //void doorway(); void dropobject(); void printmessage(); void reexfromopen(); void fillryan(); - void loadtemptext(); + void drawitall(); void usestereo(); void showcurrentfile(); - void copyname(); + //void copyname(); void look(); void setmouse(); void checkone(); @@ -1832,32 +1791,32 @@ public: void afterintroroom(); void blockget(); void usetrainer(); - void allocatework(); + //void allocatework(); void addtopresslist(); void walkandexamine(); void dmaend(); //void quickquit2(); void twodigitnum(); - void madmantext(); + //void madmantext(); void dumpcurrent(); void textforend(); void showdiarykeys(); void dontloadseg(); - void madmode(); + //void madmode(); void intro3text(); void allocatemem(); void sortoutmap(); - void doorway(); + //void showrain(); void useopened(); void inventory(); void powerlightoff(); - void getroomdata(); + void fillopen(); void showoutermenu(); void signon(); void deleteextext(); void foghornsound(); void showrightpage(); - void openhoteldoor2(); + void showloadops(); void examicon(); void showgun(); void switchryanon(); @@ -1869,7 +1828,7 @@ public: void opentvdoor(); void triggermessage(); void finalframe(); - void plotreel(); + //void plotreel(); void swapwithopen(); //void makesprite(); void dreamweb(); @@ -1883,7 +1842,6 @@ public: void turnanypathon(); void restorereels(); void setwalk(); - //void printboth(); void useroutine(); void zoomicon(); void hotelcontrol(); @@ -1900,10 +1858,10 @@ public: void makecaps(); void read(); void fadescreenups(); - void checkdest(); + //void checkdest(); //void initman(); void loadpalfromiff(); - void facerightway(); + //void facerightway(); void startup1(); void findlen(); void showsymbol(); @@ -1917,7 +1875,7 @@ public: //void clearsprites(); void obpicture(); void selectopenob(); - void widedoor(); + //void widedoor(); void security(); //void printasprite(); void buttonfive(); @@ -1931,7 +1889,7 @@ public: void showman(); void readmouse2(); void newplace(); - void movemap(); + //void movemap(); void loadsample(); void usecardreader1(); void usecardreader2(); @@ -1941,7 +1899,7 @@ public: void quitkey(); void openfile(); void usecharset1(); - void makenextblock(); + //void makenextblock(); void showpuztext(); void addalong(); //void width160(); @@ -1949,7 +1907,6 @@ public: //void dodoor(); void greyscalesum(); void buttoneight(); - void opensarters(); void findexobject(); void errormessage2(); void usechurchhole(); @@ -1958,7 +1915,7 @@ public: void fadecalculation(); void waitframes(); void clearrest(); - void getreelframeax(); + //void getreelframeax(); void barwoman(); void roomname(); void credits(); @@ -1998,9 +1955,9 @@ public: void redrawmainscrn(); void finishedwalking(); void findallryan(); - void channel0tran(); + //void channel0tran(); void buttonpress(); - void parseblaster(); + //void parseblaster(); void callhotellift(); void makemainscreen(); void intromonks2(); @@ -2034,12 +1991,12 @@ public: void intro(); void hangonp(); void fadescreendowns(); - void showloadops(); + void openhoteldoor2(); void getridoftempsp(); void scanfornames(); void setallchanges(); void newgame(); - void examinventory(); + //void printboth(); void standardload(); void undertextline(); void findroominloc(); @@ -2063,7 +2020,7 @@ public: void isitright(); void businessman(); void switchryanoff(); - void commandwithob(); + //void commandwithob(); void panelicons1(); void adjustdown(); void withwhat(); diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index 3b0c7f3325..6c4c506695 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -5,7 +5,10 @@ MODULE_OBJS := \ detection.o \ dreamweb.o \ dreamgen.o \ - stubs.o + print.o \ + sprite.o \ + stubs.o \ + vgagrafx.o # This module can be built as a plugin ifeq ($(ENABLE_DREAMWEB), DYNAMIC_PLUGIN) diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp new file mode 100644 index 0000000000..26084c35d1 --- /dev/null +++ b/engines/dreamweb/print.cpp @@ -0,0 +1,224 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" +#include "engines/util.h" +#include "graphics/surface.h" + +namespace DreamGen { + +void DreamGenContext::printboth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { + uint16 newX = *x; + uint8 width, height; + printchar(charSet, &newX, y, c, nextChar, &width, &height); + multidump(*x, y, width, height); + *x = newX; +} + +uint8 DreamGenContext::getnextword(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount) { + *totalWidth = 0; + *charCount = 0; + while(true) { + uint8 firstChar = *string; + ++string; + ++*charCount; + if ((firstChar == ':') || (firstChar == 0)) { //endall + *totalWidth += 6; + return 1; + } + if (firstChar == 32) { //endword + *totalWidth += 6; + return 0; + } + firstChar = engine->modifyChar(firstChar); + if (firstChar != 255) { + uint8 secondChar = *string; + uint8 width = charSet[firstChar - 32 + data.word(kCharshift)].width; + width = kernchars(firstChar, secondChar, width); + *totalWidth += width; + } + } +} + +void DreamGenContext::printchar() { + uint16 x = di; + uint8 width, height; + printchar((const Frame *)ds.ptr(0, 0), &x, bx, al, ah, &width, &height); + di = x; + cl = width; + ch = height; +} + +void DreamGenContext::printchar(const Frame *charSet, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { + if (c == 255) + return; + push(si); + push(di); + if (data.byte(kForeignrelease) != 0) + y -= 3; + uint16 tmp = c - 32 + data.word(kCharshift); + showframe(charSet, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); + di = pop(); + si = pop(); + _cmp(data.byte(kKerning), 0); + if (flags.z()) + *width = kernchars(c, nextChar, *width); + (*x) += *width; +} + +void DreamGenContext::printslow() { + al = printslow(es.ptr(si, 0), di, bx, dl, (bool)(dl & 1)); +} + +uint8 DreamGenContext::printslow(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered) { + data.byte(kPointerframe) = 1; + data.byte(kPointermode) = 3; + const Frame* charSet = (const Frame *)segRef(data.word(kCharset1)).ptr(0, 0); + do { + uint16 offset = x; + uint16 charCount = getnumber(charSet, string, maxWidth, centered, &offset); + do { + uint8 c0 = string[0]; + uint8 c1 = string[1]; + uint8 c2 = string[2]; + c0 = engine->modifyChar(c0); + printboth(charSet, &offset, y, c0, c1); + if ((c1 == 0) || (c1 == ':')) { + return 0; + } + if (charCount != 1) { + c1 = engine->modifyChar(c1); + data.word(kCharshift) = 91; + uint16 offset2 = offset; + printboth(charSet, &offset2, y, c1, c2); + data.word(kCharshift) = 0; + for (int i=0; i<2; ++i) { + waitframes(); + if (ax == 0) + continue; + if (ax != data.word(kOldbutton)) { + return 1; + } + } + } + + ++string; + --charCount; + } while (charCount); + y += 10; + } while (true); +} + +void DreamGenContext::printdirect() { + uint16 y = bx; + uint16 initialSi = si; + const uint8 *initialString = es.ptr(si, 0); + const uint8 *string = initialString; + printdirect(&string, di, &y, dl, (bool)(dl & 1)); + si = initialSi + (string - initialString); + bx = y; +} + +void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { + data.word(kLastxpos) = x; + const Frame *charSet = (const Frame *)segRef(data.word(kCurrentset)).ptr(0, 0); + while (true) { + uint16 offset = x; + uint8 charCount = getnumber(charSet, *string, maxWidth, centered, &offset); + uint16 i = offset; + do { + uint8 c = (*string)[0]; + uint8 nextChar = (*string)[1]; + ++(*string); + if ((c == 0) || (c == ':')) { + return; + } + c = engine->modifyChar(c); + uint8 width, height; + printchar(charSet, &i, *y, c, nextChar, &width, &height); + data.word(kLastxpos) = i; + --charCount; + } while(charCount); + *y += data.word(kLinespacing); + } +} + +void DreamGenContext::getnumber() { + uint16 offset = di; + cl = getnumber((Frame *)ds.ptr(0, 0), es.ptr(si, 0), dl, (bool)(dl & 1), &offset); + di = offset; +} + +uint8 DreamGenContext::getnumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16* offset) { + uint8 totalWidth = 0; + uint8 charCount = 0; + while (true) { + uint8 wordTotalWidth, wordCharCount; + uint8 done = getnextword(charSet, string, &wordTotalWidth, &wordCharCount); + string += wordCharCount; + + if (done == 1) { //endoftext + ax = totalWidth + wordTotalWidth - 10; + if (ax < maxWidth) { + totalWidth += wordTotalWidth; + charCount += wordCharCount; + } + + if (centered) { + ax = (maxWidth & 0xfe) + 2 + 20 - totalWidth; + ax /= 2; + } else { + ax = 0; + } + *offset += ax; + return charCount; + } + ax = totalWidth + wordTotalWidth - 10; + if (ax >= maxWidth) { //gotoverend + if (centered) { + ax = (maxWidth & 0xfe) - totalWidth + 20; + ax /= 2; + } else { + ax = 0; + } + *offset += ax; + return charCount; + } + totalWidth += wordTotalWidth; + charCount += wordCharCount; + } +} + +uint8 DreamGenContext::kernchars(uint8 firstChar, uint8 secondChar, uint8 width) { + if ((firstChar == 'a') || (al == 'u')) { + if ((secondChar == 'n') || (secondChar == 't') || (secondChar == 'r') || (secondChar == 'i') || (secondChar == 'l')) + return width-1; + } + return width; +} + +void DreamGenContext::kernchars() { + cl = kernchars(al, ah, cl); +} + +} /*namespace dreamgen */ + diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h index 0c27c12e3c..8aa71b285c 100644 --- a/engines/dreamweb/runtime.h +++ b/engines/dreamweb/runtime.h @@ -287,6 +287,12 @@ public: _freeSegments.push_back(id); } + SegmentRef segRef(uint16 seg) { + SegmentRef result(this); + result = seg; + return result; + } + inline void _cmp(uint8 a, uint8 b) { _sub(a, b); } diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp new file mode 100644 index 0000000000..2129d1ca6d --- /dev/null +++ b/engines/dreamweb/sprite.cpp @@ -0,0 +1,874 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" +#include "engines/util.h" +#include "graphics/surface.h" + +namespace DreamGen { + +Sprite *DreamGenContext::spritetable() { + Sprite *sprite = (Sprite *)segRef(data.word(kBuffers)).ptr(kSpritetable, 16 * sizeof(Sprite)); + return sprite; +} + +void DreamGenContext::printsprites() { + for (size_t priority = 0; priority < 7; ++priority) { + Sprite *sprites = spritetable(); + for (size_t j = 0; j < 16; ++j) { + const Sprite &sprite = sprites[j]; + if (sprite.updateCallback() == 0x0ffff) + continue; + if (priority != sprite.priority) + continue; + if (sprite.hidden == 1) + continue; + printasprite(&sprite); + } + } +} + +void DreamGenContext::printasprite(const Sprite *sprite) { + uint16 x, y; + if (sprite->y >= 220) { + y = data.word(kMapady) - (256 - sprite->y); + } else { + y = sprite->y + data.word(kMapady); + } + + if (sprite->x >= 220) { + x = data.word(kMapadx) - (256 - sprite->x); + } else { + x = sprite->x + data.word(kMapadx); + } + + uint8 c; + if (sprite->b29 != 0) + c = 8; + else + c = 0; + uint8 width, height; + showframe((const Frame *)segRef(sprite->frameData()).ptr(0, 0), x, y, sprite->b15, c, &width, &height); +} + +void DreamGenContext::clearsprites() { + memset(spritetable(), 0xff, sizeof(Sprite) * 16); +} + +Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi) { + Sprite *sprite = spritetable(); + while (sprite->b15 != 0xff) { // NB: No boundchecking in the original code either + ++sprite; + } + + sprite->setUpdateCallback(updateCallback); + sprite->x = x; + sprite->y = y; + sprite->setFrameData(frameData); + WRITE_LE_UINT16(&sprite->w8, somethingInDi); + sprite->w2 = 0xffff; + sprite->b15 = 0; + sprite->delay = 0; + return sprite; +} + +void DreamGenContext::makesprite() { // NB: returns new sprite in es:bx + Sprite *sprite = makesprite(si & 0xff, si >> 8, cx, dx, di); + + // 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); + // +} + +void DreamGenContext::spriteupdate() { + Sprite *sprites = spritetable(); + sprites[0].hidden = data.byte(kRyanon); + + Sprite *sprite = sprites; + for (size_t i=0; i < 16; ++i) { + uint16 updateCallback = sprite->updateCallback(); + if (updateCallback != 0xffff) { + sprite->w24 = sprite->w2; + if (updateCallback == addr_mainman) // NB : Let's consider the callback as an enum while more code is not ported to C++ + mainman(sprite); + else { + assert(updateCallback == addr_backobject); + backobject(sprite); + } + } + + if (data.byte(kNowinnewroom) == 1) + break; + ++sprite; + } +} + +void DreamGenContext::initman() { + Sprite *sprite = makesprite(data.byte(kRyanx), data.byte(kRyany), addr_mainman, data.word(kMainsprites), 0); + sprite->priority = 4; + sprite->b22 = 0; + sprite->b29 = 0; +} + +void DreamGenContext::mainman() { + assert(false); +} + +void DreamGenContext::mainman(Sprite *sprite) { + push(es); + push(ds); + + // Recover es:bx from sprite + es = data.word(kBuffers); + bx = kSpritetable; + Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); + bx += 32 * (sprite - sprites); + // + + if (data.byte(kResetmanxy) == 1) { + data.byte(kResetmanxy) = 0; + sprite->x = data.byte(kRyanx); + sprite->y = data.byte(kRyany); + sprite->b29 = 0; + } + --sprite->b22; + if (sprite->b22 != 0xff) { + ds = pop(); + es = pop(); + return; + } + sprite->b22 = 0; + if (data.byte(kTurntoface) != data.byte(kFacing)) { + aboutturn(sprite); + } else { + if ((data.byte(kTurndirection) != 0) && (data.byte(kLinepointer) == 254)) { + data.byte(kReasseschanges) = 1; + if (data.byte(kFacing) == data.byte(kLeavedirection)) + checkforexit(); + } + data.byte(kTurndirection) = 0; + if (data.byte(kLinepointer) == 254) { + sprite->b29 = 0; + } else { + ++sprite->b29; + if (sprite->b29 == 11) + sprite->b29 = 1; + walking(sprite); + if (data.byte(kLinepointer) != 254) { + if ((data.byte(kFacing) & 1) == 0) + walking(sprite); + else if ((sprite->b29 != 2) && (sprite->b29 != 7)) + walking(sprite); + } + if (data.byte(kLinepointer) == 254) { + if (data.byte(kTurntoface) == data.byte(kFacing)) { + data.byte(kReasseschanges) = 1; + if (data.byte(kFacing) == data.byte(kLeavedirection)) + checkforexit(); + } + } + } + } + static const uint8 facelist[] = { 0,60,33,71,11,82,22,93 }; + sprite->b15 = sprite->b29 + facelist[data.byte(kFacing)]; + data.byte(kRyanx) = sprite->x; + data.byte(kRyany) = sprite->y; + + ds = pop(); + es = pop(); +} + +void DreamGenContext::walking(Sprite *sprite) { + uint8 comp; + if (data.byte(kLinedirection) != 0) { + --data.byte(kLinepointer); + comp = 200; + } else { + ++data.byte(kLinepointer); + comp = data.byte(kLinelength); + } + if (data.byte(kLinepointer) < comp) { + sprite->x = data.byte(kLinedata + data.byte(kLinepointer) * 2 + 0); + sprite->y = data.byte(kLinedata + data.byte(kLinepointer) * 2 + 1); + return; + } + + data.byte(kLinepointer) = 254; + data.byte(kManspath) = data.byte(kDestination); + if (data.byte(kDestination) == data.byte(kFinaldest)) { + facerightway(); + return; + } + data.byte(kDestination) = data.byte(kFinaldest); + push(es); + push(bx); + autosetwalk(); + bx = pop(); + es = pop(); +} + +void DreamGenContext::aboutturn(Sprite *sprite) { + bool incdir = true; + + if (data.byte(kTurndirection) == 1) + incdir = true; + else if ((int8)data.byte(kTurndirection) == -1) + incdir = false; + else { + if (data.byte(kFacing) < data.byte(kTurntoface)) { + uint8 delta = data.byte(kTurntoface) - data.byte(kFacing); + if (delta >= 4) + incdir = false; + else + incdir = true; + } else { + uint8 delta = data.byte(kFacing) - data.byte(kTurntoface); + if (delta >= 4) + incdir = true; + else + incdir = false; + } + } + + if (incdir) { + data.byte(kTurndirection) = 1; + data.byte(kFacing) = (data.byte(kFacing) + 1) & 7; + sprite->b29 = 0; + } else { + data.byte(kTurndirection) = -1; + data.byte(kFacing) = (data.byte(kFacing) - 1) & 7; + sprite->b29 = 0; + } +} + +void DreamGenContext::backobject() { + assert(false); +} + +void DreamGenContext::backobject(Sprite *sprite) { + ObjData *objData = (ObjData *)segRef(data.word(kSetdat)).ptr(sprite->objData(), 0); + + if (sprite->delay != 0) { + --sprite->delay; + return; + } + + sprite->delay = objData->delay; + if (objData->type == 6) + widedoor(sprite, objData); + else if (objData->type == 5) + random(sprite, objData); + else if (objData->type == 4) + lockeddoorway(sprite, objData); + else if (objData->type == 3) + liftsprite(sprite, objData); + else if (objData->type == 2) + doorway(sprite, objData); + else if (objData->type == 1) + constant(sprite, objData); + else + steady(sprite, objData); +} + +void DreamGenContext::constant(Sprite *sprite, ObjData *objData) { + ++sprite->frame; + if (objData->b18[sprite->frame] == 255) { + sprite->frame = 0; + } + uint8 b18 = objData->b18[sprite->frame]; + objData->b17 = b18; + sprite->b15 = b18; +} + +void DreamGenContext::random(Sprite *sprite, ObjData *objData) { + randomnum1(); + uint16 r = ax; + sprite->b15 = objData->b18[r&7]; +} + +void DreamGenContext::doorway(Sprite *sprite, ObjData *objData) { + data.byte(kDoorcheck1) = -24; + data.byte(kDoorcheck2) = 10; + data.byte(kDoorcheck3) = -30; + data.byte(kDoorcheck4) = 10; + dodoor(sprite, objData); +} + +void DreamGenContext::widedoor(Sprite *sprite, ObjData *objData) { + data.byte(kDoorcheck1) = -24; + data.byte(kDoorcheck2) = 24; + data.byte(kDoorcheck3) = -30; + data.byte(kDoorcheck4) = 24; + dodoor(sprite, objData); +} + +void DreamGenContext::dodoor() { + Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); + ObjData *objData = (ObjData *)ds.ptr(di, 0); + dodoor(sprite, objData); +} + +void DreamGenContext::dodoor(Sprite *sprite, ObjData *objData) { + uint8 ryanx = data.byte(kRyanx); + uint8 ryany = data.byte(kRyany); + if (ryanx < sprite->x) { + if (ryanx < sprite->x + (int8)data.byte(kDoorcheck1)) + goto shutdoor; + } else { + if (ryanx >= sprite->x + data.byte(kDoorcheck2)) + goto shutdoor; + } + if (ryany < sprite->y) { + if (ryany < sprite->y + (int8)data.byte(kDoorcheck3)) + goto shutdoor; + } else { + if (ryany >= sprite->y + data.byte(kDoorcheck4)) + goto shutdoor; + } +//opendoor: + if ((data.byte(kThroughdoor) == 1) && (sprite->frame == 0)) + sprite->frame = 6; + + ++sprite->frame; + if (sprite->frame == 1) { //doorsound2 + if (data.byte(kReallocation) == 5) //hoteldoor2 + al = 13; + else + al = 0; + playchannel1(); + } + if (objData->b18[sprite->frame] == 255) { + --sprite->frame; + } + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + data.byte(kThroughdoor) = 1; + return; +shutdoor: + if (sprite->frame == 5) { //doorsound1; + if (data.byte(kReallocation) == 5) //hoteldoor1 + al = 13; + else + al = 1; + playchannel1(); + } + if (sprite->frame != 0) { + --sprite->frame; + } + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + if (sprite->frame == 5) //nearly + data.byte(kThroughdoor) = 0; +} + +void DreamGenContext::steady(Sprite *sprite, ObjData *objData) { + uint8 b18 = objData->b18[0]; + objData->b17 = b18; + sprite->b15 = b18; +} + +void DreamGenContext::lockeddoorway(Sprite *sprite, ObjData *objData) { + if (data.byte(kRyanx) < sprite->x) { + if (sprite->x - data.byte(kRyanx) > 24) + goto shutdoor2; + } else { + if (data.byte(kRyanx) - sprite->x >= 10) + goto shutdoor2; + } + + if (data.byte(kRyany) < sprite->y) { + if (sprite->y - data.byte(kRyany) > 30) + goto shutdoor2; + } else { + if (data.byte(kRyany) - sprite->y >= 12) + goto shutdoor2; + } + + if (data.byte(kThroughdoor) != 1) { + if (data.byte(kLockstatus) == 1) + goto shutdoor2; + } + + if (sprite->frame == 1) { + al = 0; + playchannel1(); + } + + if (sprite->frame == 6) { + turnpathonCPP(data.byte(kDoorpath)); + } + + if ((data.byte(kThroughdoor) == 1) && (sprite->frame == 0)) { + sprite->frame = 6; + } + + ++sprite->frame; + if (objData->b18[sprite->frame] == 255) { + --sprite->frame; + } + + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + if (sprite->frame == 5) + data.byte(kThroughdoor) = 1; + return; + +shutdoor2: + if (sprite->frame == 5) { + al = 1; + playchannel1(); + } + + if (sprite->frame != 0) { + --sprite->frame; + } + + data.byte(kThroughdoor) = 0; + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + + if (sprite->frame == 0) { + turnpathoffCPP(data.byte(kDoorpath)); + data.byte(kLockstatus) = 1; + } +} + +void DreamGenContext::liftsprite(Sprite *sprite, ObjData *objData) { + uint8 liftFlag = data.byte(kLiftflag); + if (liftFlag == 0) { //liftclosed + turnpathoffCPP(data.byte(kLiftpath)); + + if (data.byte(kCounttoopen) != 0) { + _dec(data.byte(kCounttoopen)); + if (data.byte(kCounttoopen) == 0) + data.byte(kLiftflag) = 3; + } + sprite->frame = 0; + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + } + else if (liftFlag == 1) { //liftopen + turnpathonCPP(data.byte(kLiftpath)); + + if (data.byte(kCounttoclose) != 0) { + _dec(data.byte(kCounttoclose)); + if (data.byte(kCounttoclose) == 0) + data.byte(kLiftflag) = 2; + } + sprite->frame = 12; + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + } + else if (liftFlag == 3) { //openlift + if (sprite->frame == 12) { + data.byte(kLiftflag) = 1; + return; + } + ++sprite->frame; + if (sprite->frame == 1) { + al = 2; + liftnoise(); + } + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + } else { //closeLift + assert(liftFlag == 2); + if (sprite->frame == 0) { + data.byte(kLiftflag) = 0; + return; + } + --sprite->frame; + if (sprite->frame == 11) { + al = 3; + liftnoise(); + } + sprite->b15 = objData->b17 = objData->b18[sprite->frame]; + } +} + +void DreamGenContext::facerightway() { + uint8 *paths = getroomspathsCPP(); + uint8 dir = paths[8 * data.byte(kManspath) + 7]; + data.byte(kTurntoface) = dir; + data.byte(kLeavedirection) = dir; +} + +void DreamGenContext::findsource() { + uint16 currentFrame = data.word(kCurrentframe); + if (currentFrame < 160) { + ds = data.word(kReel1); + data.word(kTakeoff) = 0; + } else if (currentFrame < 320) { + ds = data.word(kReel2); + data.word(kTakeoff) = 160; + } else { + ds = data.word(kReel3); + data.word(kTakeoff) = 320; + } +} + +Frame *DreamGenContext::findsourceCPP() { + push(ds); + findsource(); + Frame *result = (Frame *)ds.ptr(0, 0); + ds = pop(); + return result; +} + +Reel *DreamGenContext::getreelstart() { + Reel *reel = (Reel *)segRef(data.word(kReels)).ptr(kReellist + data.word(kReelpointer) * sizeof(Reel) * 8, sizeof(Reel)); + return reel; +} + +void DreamGenContext::showreelframe() { + Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); + showreelframe(reel); +} + +void DreamGenContext::showreelframe(Reel *reel) { + uint16 x = reel->x + data.word(kMapadx); + uint16 y = reel->y + data.word(kMapady); + data.word(kCurrentframe) = reel->frame(); + Frame *source = findsourceCPP(); + uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); + uint8 width, height; + showframe(source, x, y, frame, 8, &width, &height); +} + +void DreamGenContext::showgamereel() { + uint16 reelpointer = es.word(bx+3); + if (reelpointer >= 512) + return; + data.word(kReelpointer) = reelpointer; + push(es); + push(bx); + plotreel(); + bx = pop(); + es = pop(); + es.word(bx+3) = data.word(kReelpointer); +} + +const Frame *DreamGenContext::getreelframeax(uint16 frame) { + data.word(kCurrentframe) = frame; + uint16 offset = data.word(kCurrentframe) - data.word(kTakeoff); + return findsourceCPP() + offset; +} + +void DreamGenContext::showrain() { + ds = data.word(kMainsprites); + si = 6*58; + ax = ds.word(si+2); + si = ax + 2080; + Rain *rain = (Rain *)segRef(data.word(kBuffers)).ptr(kRainlist, 0); + if (rain->x == 255) + return; + while (true) { + if (rain->x == 255) { + if (data.word(kCh1blockstocopy) != 0) + return; + if ((data.byte(kReallocation) == 2) && (data.byte(kBeenmugged) != 1)) + return; + if (data.byte(kReallocation) == 55) + return; + randomnum1(); + if (al >= 1) + return; + if (data.byte(kCh0playing) != 6) + al = 4; + else + al = 7; + playchannel1(); + return; + } + uint16 y = rain->y + data.word(kMapady) + data.word(kMapystart); + uint16 x = rain->x + data.word(kMapadx) + data.word(kMapxstart); + uint16 size = rain->size; + ax = ((uint16)(rain->w3() - rain->b5)) & 511; + rain->setW3(ax); + ++rain; + const uint8 *src = ds.ptr(si, 0) + ax; + uint8 *dst = workspace() + y * 320 + x; + for(uint16 i = 0; i < size; ++i) { + uint8 v = src[i]; + if (v != 0) + *dst = v; + dst += 320-1; + } + } +} + +void DreamGenContext::updatepeople() { + data.word(kListpos) = kPeoplelist; + memset(segRef(data.word(kBuffers)).ptr(kPeoplelist, 12 * sizeof(People)), 0xff, 12 * sizeof(People)); + ++data.word(kMaintimer); + es = cs; + bx = kReelroutines; + const ReelRoutine *reelRoutine = (const ReelRoutine *)cs.ptr(bx, 0); + const uint16 *callbacks = (const uint16 *)cs.ptr(kReelcalls, 0); + while (true) { + uint8 realLocation = reelRoutine->reallocation; + if (realLocation == 255) + return; + if ((realLocation == data.byte(kReallocation)) && + (reelRoutine->mapX == data.byte(kMapx)) && + (reelRoutine->mapY == data.byte(kMapy))) { + uint16 callback = READ_LE_UINT16(callbacks); + //dw gamer,sparkydrip,eden,edeninbath,sparky,smokebloke + if (callback == addr_gamer) + gamer(); + else if (callback == addr_sparkydrip) + sparkydrip(); + else if (callback == addr_eden) + eden(); + else if (callback == addr_edeninbath) + edeninbath(); + else if (callback == addr_sparky) + sparky(); + else if (callback == addr_smokebloke) + smokebloke(); + //dw manasleep,drunk,receptionist,malefan,femalefan + else if (callback == addr_manasleep) + manasleep(); + else if (callback == addr_drunk) + drunk(); + else if (callback == addr_receptionist) + receptionist(); + else if (callback == addr_malefan) + malefan(); + else if (callback == addr_femalefan) + femalefan(); + //dw louis,louischair,soldier1,bossman,interviewer + else if (callback == addr_louis) + louis(); + else if (callback == addr_louischair) + louischair(); + else if (callback == addr_soldier1) + soldier1(); + else if (callback == addr_bossman) + bossman(); + else if (callback == addr_interviewer) + interviewer(); + //dw heavy,manasleep2,mansatstill,drinker,bartender + else if (callback == addr_heavy) + heavy(); + else if (callback == addr_manasleep2) + manasleep2(); + else if (callback == addr_mansatstill) + mansatstill(); + else if (callback == addr_drinker) + drinker(); + else if (callback == addr_bartender) + bartender(); + //dw othersmoker,tattooman,attendant,keeper,candles1 + else if (callback == addr_othersmoker) + othersmoker(); + else if (callback == addr_tattooman) + tattooman(); + else if (callback == addr_attendant) + attendant(); + else if (callback == addr_keeper) + keeper(); + else if (callback == addr_candles1) + candles1(); + //dw smallcandle,security,copper,poolguard,rockstar + else if (callback == addr_smallcandle) + smallcandle(); + else if (callback == addr_security) + security(); + else if (callback == addr_copper) + copper(); + else if (callback == addr_poolguard) + poolguard(); + else if (callback == addr_rockstar) + rockstar(); + //dw businessman,train,aide,mugger,helicopter + else if (callback == addr_businessman) + businessman(); + else if (callback == addr_train) + train(); + else if (callback == addr_aide) + aide(); + else if (callback == addr_mugger) + mugger(); + else if (callback == addr_helicopter) + helicopter(); + //dw intromagic1,intromusic,intromagic2,candles2,gates + else if (callback == addr_intromagic1) + intromagic1(); + else if (callback == addr_intromusic) + intromusic(); + else if (callback == addr_intromagic2) + intromagic2(); + else if (callback == addr_candles2) + candles2(); + else if (callback == addr_gates) + gates(); + //dw intromagic3,intromonks1,candles,intromonks2 + else if (callback == addr_intromagic3) + intromagic3(); + else if (callback == addr_intromonks1) + intromonks1(); + else if (callback == addr_candles) + candles(); + else if (callback == addr_intromonks2) + intromonks2(); + //dw handclap,monkandryan,endgameseq,priest,madman + else if (callback == addr_handclap) + handclap(); + else if (callback == addr_monkandryan) + monkandryan(); + else if (callback == addr_endgameseq) + endgameseq(); + else if (callback == addr_priest) + priest(); + else if (callback == addr_madman) + madman(); + //dw madmanstelly,alleybarksound,foghornsound + else if (callback == addr_madmanstelly) + madmanstelly(); + else if (callback == addr_alleybarksound) + alleybarksound(); + else if (callback == addr_foghornsound) + foghornsound(); + //dw carparkdrip,carparkdrip,carparkdrip,carparkdrip + else if (callback == addr_carparkdrip) + carparkdrip(); + else + assert(false); // Oops I forgot something in the dispatch table + } + bx += 8; + ++reelRoutine; + ++callbacks; + } +} + +void DreamGenContext::madmantext() { + if (isCD()) { + if (data.byte(kSpeechcount) >= 63) + return; + if (data.byte(kCh1playing) != 255) + return; + al = data.byte(kSpeechcount); + ++data.byte(kSpeechcount); + } else { + if (data.byte(kCombatcount) >= 61) + return; + al = data.byte(kCombatcount); + _and(al, 3); + if (!flags.z()) + return; + al = data.byte(kCombatcount) / 4; + } + setuptimedtemp(47 + al, 82, 72, 80, 90, 1); +} + +void DreamGenContext::madman() { + data.word(kWatchingtime) = 2; + checkspeed(); + if (flags.z()) { + ax = es.word(bx+3); + if (ax >= 364) { + data.byte(kMandead) = 2; + showgamereel(); + return; + } + if (ax == 10) { + push(es); + push(bx); + push(ax); + dx = kIntrotextname; + loadtemptext(); + ax = pop(); + bx = pop(); + es = pop(); + data.byte(kCombatcount) = -1; + data.byte(kSpeechcount) = 0; + } + ++ax; + if (ax == 294) { + if (data.byte(kWongame) == 1) + return; + data.byte(kWongame) = 1; + push(es); + push(bx); + getridoftemptext(); + bx = pop(); + es = pop(); + return; + } + if (ax == 66) { + ++data.byte(kCombatcount); + push(es); + push(bx); + madmantext(); + bx = pop(); + es = pop(); + ax = 53; + if (data.byte(kCombatcount) >= (isCD() ? 64 : 62)) { + if (data.byte(kCombatcount) == (isCD() ? 70 : 68)) + ax = 310; + else { + if (data.byte(kLastweapon) == 8) { + data.byte(kCombatcount) = isCD() ? 72 : 70; + data.byte(kLastweapon) = -1; + data.byte(kMadmanflag) = 1; + ax = 67; + } + } + } + } + es.word(bx+3) = ax; + } + showgamereel(); + es.byte(bx+1) = data.byte(kMapx); + madmode(); +} + +void DreamGenContext::madmode() { + data.word(kWatchingtime) = 2; + data.byte(kPointermode) = 0; + if (data.byte(kCombatcount) < (isCD() ? 65 : 63)) + return; + if (data.byte(kCombatcount) >= (isCD() ? 70 : 68)) + return; + data.byte(kPointermode) = 2; +} + +void DreamGenContext::movemap(uint8 param) { + switch (param) { + case 32: + data.byte(kMapy) -= 20; + break; + case 16: + data.byte(kMapy) -= 10; + break; + case 8: + data.byte(kMapy) += 10; + break; + case 2: + data.byte(kMapx) += 11; + break; + default: + data.byte(kMapx) -= 11; + break; + } + data.byte(kNowinnewroom) = 1; +} + +} /*namespace dreamgen */ + diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index e274375cf4..685e4cffe1 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -20,21 +20,30 @@ * */ +#include "common/endian.h" + struct Sprite { - uint16 updateCallback; + uint16 _updateCallback; + uint16 updateCallback() const { return READ_LE_UINT16(&_updateCallback); } + void setUpdateCallback(uint16 v) { WRITE_LE_UINT16(&_updateCallback, v); } uint16 w2; uint16 w4; - uint16 w6; + uint16 _frameData; + uint16 frameData() const { return READ_LE_UINT16(&_frameData); } + void setFrameData(uint16 v) { WRITE_LE_UINT16(&_frameData, v); } uint16 w8; uint8 x; uint8 y; uint16 w12; uint8 b14; uint8 b15; - uint16 w16; + uint8 b16; + uint8 b17; uint8 delay; uint8 frame; - uint16 obj_data; + uint16 _objData; + uint16 objData() const { return READ_LE_UINT16(&_objData); } + void setObjData(uint16 v) { WRITE_LE_UINT16(&_objData, v); } uint8 b22; uint8 priority; uint16 w24; @@ -66,3 +75,85 @@ struct ObjData { uint8 b17; uint8 b18[256]; // NB: Don't know the size yet }; + +struct Frame { + uint8 width; + uint8 height; + uint16 _ptr; + uint16 ptr() const { return READ_LE_UINT16(&_ptr); } + void setPtr(uint16 v) { WRITE_LE_UINT16(&_ptr, v); } + uint8 x; + uint8 y; +}; + +struct Reel { + uint8 frame_lo; + uint8 frame_hi; + uint16 frame() const { return READ_LE_UINT16(&frame_lo); } + void setFrame(uint16 v) { WRITE_LE_UINT16(&frame_lo, v); } + uint8 x; + uint8 y; + uint8 b4; +}; + +struct ReelRoutine { + uint8 reallocation; + uint8 mapX; + uint8 mapY; + uint8 b3; + uint8 b4; + uint8 b5; + uint8 b6; + uint8 b7; +}; + +struct People { + uint8 b0; + uint8 b1; + uint16 w0() const { return READ_LE_UINT16(&b0); } + void setW0(uint16 v) { WRITE_LE_UINT16(&b0, v); } + uint8 b2; + uint8 b3; + uint16 w2() const { return READ_LE_UINT16(&b2); } + void setW2(uint16 v) { WRITE_LE_UINT16(&b2, v); } + uint8 b4; + +}; + +struct Room { + uint8 name[10]; + uint8 b10; + uint8 b11; + uint8 b12; + uint8 roomsSample; + uint8 b14; + uint8 mapX; + uint8 mapY; + uint8 b17; + uint8 b18; + uint8 b19; + uint8 liftFlag; + uint8 b21; + uint8 b22; + uint8 countToOpen; + uint8 liftPath; + uint8 doorPath; + uint8 b26; + uint8 b27; + uint8 b28; + uint8 b29; + uint8 b30; + uint8 b31; +}; + +struct Rain { + uint8 x; + uint8 y; + uint8 size; + uint8 w3_lo; + uint8 w3_hi; + uint16 w3() const { return READ_LE_UINT16(&w3_lo); } + void setW3(uint16 v) { WRITE_LE_UINT16(&w3_lo, v); } + uint8 b5; +}; + diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 5ba3796e30..c978d8d475 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -174,7 +174,7 @@ void DreamGenContext::dreamweb() { } } -Common::String getFilename(Context &context) { +static Common::String getFilename(Context &context) { uint16 name_ptr = context.dx; Common::String name; uint8 c; @@ -183,126 +183,6 @@ Common::String getFilename(Context &context) { return name; } -void DreamGenContext::multiget() { - multiget(di, bx, cl, ch); -} - -void DreamGenContext::multiget(uint16 x, uint16 y, uint8 w, uint8 h) { - unsigned src = x + y * kScreenwidth; - unsigned dst = (uint16)si; - es = ds; - ds = data.word(kWorkspace); - if (y + h > 200) - h = 200 - y; - if (x + w > 320) - w = 320 - x; - //debug(1, "multiget %u,%u %ux%u -> segment: %04x->%04x", x, y, w, h, (uint16)ds, (uint16)es); - for(unsigned l = 0; l < h; ++l) { - uint8 *src_p = ds.ptr(src + kScreenwidth * l, w); - uint8 *dst_p = es.ptr(dst + w * l, w); - memcpy(dst_p, src_p, w); - } - si += w * h; - di = src + kScreenwidth * h; - cx = 0; -} - -void DreamGenContext::multiput() { - multiput(di, bx, cl, ch); -} - -void DreamGenContext::multiput(uint16 x, uint16 y, uint8 w, uint8 h) { - unsigned src = (uint16)si; - unsigned dst = x + y * kScreenwidth; - es = data.word(kWorkspace); - if (y + h > 200) - h = 200 - y; - if (x + w > 320) - w = 320 - x; - //debug(1, "multiput %ux%u -> segment: %04x->%04x", w, h, (uint16)ds, (uint16)es); - for(unsigned l = 0; l < h; ++l) { - uint8 *src_p = ds.ptr(src + w * l, w); - uint8 *dst_p = es.ptr(dst + kScreenwidth * l, w); - memcpy(dst_p, src_p, w); - } - si += w * h; - di = dst + kScreenwidth * h; - cx = 0; -} - -void DreamGenContext::multidump(uint16 x, uint16 y, uint8 width, uint8 height) { - ds = data.word(kWorkspace); - unsigned offset = x + y * kScreenwidth; - //debug(1, "multidump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset); - engine->blit(ds.ptr(offset, width * height), kScreenwidth, x, y, width, height); -} - -void DreamGenContext::multidump() { - multidump(di, bx, cl, ch); - unsigned offset = di + bx * kScreenwidth; - si = di = offset + ch * kScreenwidth; - cx = 0; -} - -void DreamGenContext::worktoscreen() { - ds = data.word(kWorkspace); - uint size = 320 * 200; - engine->blit(ds.ptr(0, size), 320, 0, 0, 320, 200); - di = si = size; - cx = 0; -} - -void DreamGenContext::printundermon() { - engine->printUnderMonitor(); -} - -void DreamGenContext::cls() { - engine->cls(); -} - -void DreamGenContext::frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { - dst += pitch * y + x; - - for (uint16 j = 0; j < height; ++j) { - memcpy(dst, src, width); - dst += pitch; - src += width; - } -} - -void DreamGenContext::frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { - uint16 stride = pitch - width; - dst += y * pitch + x; - - for (uint16 i = 0; i < height; ++i) { - for (uint16 j = 0; j < width; ++j) { - if (*dst == 0xff) { - *dst = *src; - } - ++src; - ++dst; - } - dst += stride; - } -} - -void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { - uint16 stride = pitch - width; - dst += y * pitch + x; - dst -= width; - - for (uint16 j = 0; j < height; ++j) { - for (uint16 i = 0; i < width; ++i) { - uint8 pixel = src[width - i - 1]; - if (pixel) - *dst = pixel; - ++dst; - } - src += width; - dst += stride; - } -} - void DreamGenContext::seecommandtail() { data.word(kSoundbaseadd) = 0x220; data.byte(kSoundint) = 5; @@ -394,84 +274,6 @@ void DreamGenContext::setmouse() { data.word(kOldpointerx) = 0xffff; } -void DreamGenContext::printboth() { - uint16 x = di; - printboth(es, ds, &x, bx, al); - di = x; -} - -void DreamGenContext::printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c) { - uint16 newX = *x; - uint8 width, height; - printchar(dst, src, &newX, y, c, &width, &height); - multidump(*x, y, width, height); - *x = newX; -} - -uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount) { - *totalWidth = 0; - *charCount = 0; - while(true) { - uint8 firstChar = *string; - ++string; - ++*charCount; - if ((firstChar == ':') || (firstChar == 0)) { //endall - *totalWidth += 6; - return 1; - } - if (firstChar == 32) { //endword - *totalWidth += 6; - return 0; - } - firstChar = engine->modifyChar(firstChar); - if (firstChar != 255) { - uint8 secondChar = *string; - uint8 width = ds.byte(6*(firstChar - 32 + data.word(kCharshift))); - width = kernchars(firstChar, secondChar, width); - *totalWidth += width; - } - } -} - -void DreamGenContext::getnextword() { - uint8 totalWidth, charCount; - al = getnextword(es.ptr(di, 0), &totalWidth, &charCount); - bl = totalWidth; - bh = charCount; - di += charCount; -} - -void DreamGenContext::printchar() { - uint16 x = di; - uint8 width, height; - printchar(es, ds, &x, bx, al, &width, &height); - di = x; - cl = width; - ch = height; -} - -void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uint8 c, uint8 *width, uint8 *height) { - if (c == 255) - return; - push(si); - push(di); - push(ax); - if (data.byte(kForeignrelease) != 0) - y -= 3; - showframe(dst, src, *x, y, c - 32 + data.word(kCharshift), 0, width, height); - ax = pop(); - di = pop(); - si = pop(); - _cmp(data.byte(kKerning), 0); - if (flags.z()) - *width = kernchars(c, ah, *width); - (*x) += *width; -} - -void DreamGenContext::printslow() { - al = printslow(di, bx, dl, (bool)(dl & 1)); -} - void DreamGenContext::dumptextline() { if (data.byte(kNewtextline) != 1) return; @@ -483,100 +285,13 @@ void DreamGenContext::dumptextline() { multidump(x, y, 228, 13); } -uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered) { - data.byte(kPointerframe) = 1; - data.byte(kPointermode) = 3; - ds = data.word(kCharset1); - do { - uint16 offset = x; - uint16 charCount = getnumber(si, maxWidth, centered, &offset); - do { - push(si); - push(es); - uint8 c0 = es.byte(si); - push(es); - push(ds); - c0 = engine->modifyChar(c0); - printboth(es, ds, &offset, y, c0); - ds = pop(); - es = pop(); - uint8 c1 = es.byte(si+1); - ++si; - if ((c1 == 0) || (c1 == ':')) { - es = pop(); - si = pop(); - return 0; - } - if (charCount != 1) { - push(ds); - push(es); - c1 = engine->modifyChar(c1); - data.word(kCharshift) = 91; - uint16 offset2 = offset; - printboth(es, ds, &offset2, y, c1); - data.word(kCharshift) = 0; - es = pop(); - ds = pop(); - for (int i=0; i<2; ++i) { - waitframes(); - if (ax == 0) - continue; - if (ax != data.word(kOldbutton)) { - es = pop(); - si = pop(); - return 1; - } - } - } - - es = pop(); - si = pop(); - ++si; - --charCount; - } while (charCount); - y += 10; - } while (true); -} - -void DreamGenContext::printdirect() { - uint16 y = bx; - printdirect(di, &y, dl, (bool)(dl & 1)); - bx = y; -} - -void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered) { - data.word(kLastxpos) = x; - ds = data.word(kCurrentset); - while (true) { - uint16 offset = x; - uint8 charCount = getnumber(si, maxWidth, centered, &offset); - uint16 i = offset; - do { - uint8 c = es.byte(si); - ++si; - if ((c == 0) || (c == ':')) { - return; - } - c = engine->modifyChar(c); - ah = es.byte(si); // get next char for kerning - uint8 width, height; - push(es); - printchar(es, ds, &i, *y, c, &width, &height); - es = pop(); - data.word(kLastxpos) = i; - --charCount; - } while(charCount); - *y += data.word(kLinespacing); - } -} - void DreamGenContext::getundertimed() { uint16 y = data.byte(kTimedy); if (data.byte(kForeignrelease)) y -= 3; ds = data.word(kBuffers); si = kUndertimedtext; - multiget(data.byte(kTimedx), y, 240, kUndertimedysize); + multiget(ds.ptr(si, 0), data.byte(kTimedx), y, 240, kUndertimedysize); } void DreamGenContext::putundertimed() { @@ -585,7 +300,7 @@ void DreamGenContext::putundertimed() { y -= 3; ds = data.word(kBuffers); si = kUndertimedtext; - multiput(data.byte(kTimedx), y, 240, kUndertimedysize); + multiput(ds.ptr(si, 0), data.byte(kTimedx), y, 240, kUndertimedysize); } void DreamGenContext::usetimedtext() { @@ -605,67 +320,62 @@ void DreamGenContext::usetimedtext() { es = data.word(kTimedseg); si = data.word(kTimedoffset); + const uint8 *string = es.ptr(si, 0); uint16 y = data.byte(kTimedy); - printdirect(data.byte(kTimedx), &y, 237, true); + printdirect(&string, data.byte(kTimedx), &y, 237, true); data.byte(kNeedtodumptimed) = 1; } -void DreamGenContext::getnumber() { - uint16 offset = di; - cl = getnumber(si, dl, (bool)(dl & 1), &offset); - di = offset; -} - -uint8 DreamGenContext::getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset) { - uint8 totalWidth = 0; - uint8 charCount = 0; - while (true) { - uint8 wordTotalWidth, wordCharCount; - uint8 done = getnextword(es.ptr(index, 0), &wordTotalWidth, &wordCharCount); - index += wordCharCount; - - if (done == 1) { //endoftext - ax = totalWidth + wordTotalWidth - 10; - if (ax < maxWidth) { - totalWidth += wordTotalWidth; - charCount += wordCharCount; - } - - if (centered) { - ax = (maxWidth & 0xfe) + 2 + 20 - totalWidth; - ax /= 2; - } else { - ax = 0; - } - *offset += ax; - return charCount; - } - ax = totalWidth + wordTotalWidth - 10; - if (ax >= maxWidth) { //gotoverend - if (centered) { - ax = (maxWidth & 0xfe) - totalWidth + 20; - ax /= 2; - } else { - ax = 0; - } - *offset += ax; - return charCount; +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(); } - totalWidth += wordTotalWidth; - charCount += wordCharCount; + dx = pop(); + cx = pop(); + bx = pop(); + ax = pop(); + if ((data.byte(kSpeechloaded) == 1) && (data.byte(kSubtitles) != 1)) + return; } -} +#endif -uint8 DreamGenContext::kernchars(uint8 firstChar, uint8 secondChar, uint8 width) { - if ((firstChar == 'a') || (al == 'u')) { - if ((secondChar == 'n') || (secondChar == 't') || (secondChar == 'r') || (secondChar == 'i') || (secondChar == 'l')) - return width-1; - } - return width; -} + 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); +} + +void DreamGenContext::dumptimedtext() { + if (data.byte(kNeedtodumptimed) != 1) + return; + uint8 y = data.byte(kTimedy); + if (data.byte(kForeignrelease) != 0) + y -= 3; -void DreamGenContext::kernchars() { - cl = kernchars(al, ah, cl); + multidump(data.byte(kTimedx), y, 240, kUndertimedysize); + data.byte(kNeedtodumptimed) = 0; } void DreamGenContext::gettime() { @@ -681,12 +391,17 @@ void DreamGenContext::gettime() { } void DreamGenContext::allocatemem() { - uint size = (bx + 2) * 16; + ax = allocatemem(bx); +} + +uint16 DreamGenContext::allocatemem(uint16 paragraphs) { + uint size = (paragraphs + 2) * 16; debug(1, "allocate mem, %u bytes", size); flags._c = false; SegmentRef seg = allocateSegment(size); - ax = (uint16)seg; - debug(1, "\tsegment address -> %04x", (uint16)ax); + uint16 result = (uint16)seg; + debug(1, "\tsegment address -> %04x", result); + return result; } void DreamGenContext::deallocatemem() { @@ -880,349 +595,96 @@ void DreamGenContext::fadedos() { engine->fadeDos(); } -void DreamGenContext::doshake() { - uint8 &counter = data.byte(kShakecounter); - _cmp(counter, 48); - if (flags.z()) - return; - - _add(counter, 1); - static const int shakeTable[] = { - 0, -2, 3, -2, 0, 2, 4, -1, - 1, -3, 3, 2, 0, -2, 3, -2, - 0, 2, 4, -1, 1, -3, 3, 2, - 0, -2, 3, -2, 0, 2, 4, -1, - - 1, -3, 3, 2, 0, -2, 3, -2, - 0, 2, 4, -1, 1, -3, 3, 2, - 0, -2, 3, -2, 0, 2, 4, -1, - 1, -3, 3, 2, 0, -2, 3, -2, - - 0, 2, 4, -1, 1, -3, 3, 2, - 0, -2, 3, -2, 0, 2, 4, -1, - 1, -3, 3, 2, 0, -2, 3, -2, - 0, 2, 4, -1, 1, -3, 3, 2, - - 0, -2, 3, -2, 0, 2, 4, -1, - 1, -3, 3, 0, - }; - int offset = shakeTable[counter]; - engine->setShakePos(offset >= 0 ? offset : -offset); -} - -void DreamGenContext::vsync() { - push(ax); - push(bx); - push(cx); - push(dx); - push(si); - push(di); - push(es); - push(ds); - engine->waitForVSync(); - ds = pop(); - es = pop(); - di = pop(); - si = pop(); - dx = pop(); - cx = pop(); - bx = pop(); - ax = pop(); -} - -void DreamGenContext::setmode() { - vsync(); - initGraphics(320, 200, false); -} - -void DreamGenContext::showpcx() { - Common::String name = getFilename(*this); - Common::File pcxFile; - - if (!pcxFile.open(name)) { - warning("showpcx: Could not open '%s'", name.c_str()); - return; - } - - uint8 *maingamepal; - int i, j; - - // Read the 16-color palette into the 'maingamepal' buffer. Note that - // the color components have to be adjusted from 8 to 6 bits. - - pcxFile.seek(16, SEEK_SET); - es = data.word(kBuffers); - maingamepal = es.ptr(kMaingamepal, 768); - pcxFile.read(maingamepal, 48); - - memset(maingamepal + 48, 0xff, 720); - for (i = 0; i < 48; i++) { - maingamepal[i] >>= 2; - } - - // Decode the image data. - - Graphics::Surface *s = g_system->lockScreen(); - Common::Rect rect(640, 480); - - s->fillRect(rect, 0); - pcxFile.seek(128, SEEK_SET); - - for (int y = 0; y < 480; y++) { - byte *dst = (byte *)s->getBasePtr(0, y); - int decoded = 0; - - while (decoded < 320) { - byte col = pcxFile.readByte(); - byte len; - - if ((col & 0xc0) == 0xc0) { - len = col & 0x3f; - col = pcxFile.readByte(); - } else { - len = 1; - } - - // The image uses 16 colors and is stored as four bit - // planes, one for each bit of the color, least - // significant bit plane first. - - for (i = 0; i < len; i++) { - int plane = decoded / 80; - int pos = decoded % 80; - - for (j = 0; j < 8; j++) { - byte bit = (col >> (7 - j)) & 1; - dst[8 * pos + j] |= (bit << plane); - } - - decoded++; - } - } - } - - g_system->unlockScreen(); - pcxFile.close(); -} - -/* -void DreamGenContext::frameoutv() { - uint16 pitch = dx; - uint16 width = cx & 0xff; - uint16 height = cx >> 8; - - const uint8 *src = ds.ptr(si, width * height); - uint8 *dst = es.ptr(0, pitch * height); - - frameoutv(dst, src, pitch, width, height, di, bx); -} -*/ - -void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { - // NB : These resilience checks were not in the original engine, but did they result in undefined behaviour - // or was something broken during porting to C++? - assert(pitch == 320); - - if(x >= 320) - return; - if(y >= 200) +void DreamGenContext::eraseoldobs() { + if (data.byte(kNewobs) == 0) return; - if(x + width > 320) { - width = 320 - x; - } - if(y + height > 200) { - height = 200 - y; - } - uint16 stride = pitch - width; - dst += pitch * y + x; - - for (uint16 j = 0; j < height; ++j) { - for (uint16 i = 0; i < width; ++i) { - uint8 pixel = *src++; - if (pixel) - *dst = pixel; - ++dst; + Sprite *sprites = spritetable(); + for (size_t i=0; i < 16; ++i) { + Sprite &sprite = sprites[i]; + if (sprite.objData() != 0xffff) { + memset(&sprite, 0xff, sizeof(Sprite)); } - dst += stride; } } -Sprite *DreamGenContext::spritetable() { +void DreamGenContext::turnpathonCPP(uint8 param) { + al = param; push(es); push(bx); - - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprite = (Sprite *)es.ptr(bx, 16 * sizeof(Sprite)); - + turnpathon(); bx = pop(); es = pop(); - - return sprite; -} - -void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { - // frameNumber takes up 9 bits of ax, and effectsFlag 7. - assert(!(effectsFlag & 1)); - - es = dst; - ds = src; - di = x; - bx = y; - ax = frameNumber | (effectsFlag << 8); - - - si = (ax & 0x1ff) * 6; - if (ds.word(si) == 0) { - *width = 0; - *height = 0; - return; - } - -//notblankshow: - if ((effectsFlag & 128) == 0) { - di += ds.byte(si + 4); - bx += ds.byte(si + 5); - } -//skipoffsets: - cx = ds.word(si + 0); - *width = cl; - *height = ch; - si = ds.word(si+2) + 2080; - - if (effectsFlag) { - if (effectsFlag & 128) { //centred - di -= *width / 2; - bx -= *height / 2; - } - if (effectsFlag & 64) { //diffdest - frameoutfx(es.ptr(0, dx * *height), ds.ptr(si, *width * *height), dx, *width, *height, di, bx); - return; - } - if (effectsFlag & 8) { //printlist - push(ax); - ax = di - data.word(kMapadx); - push(bx); - bx -= data.word(kMapady); - ah = bl; - bx = pop(); - //addtoprintlist(); // NB: Commented in the original asm - ax = pop(); - } - if (effectsFlag & 4) { //flippedx - es = data.word(kWorkspace); - frameoutfx(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); - return; - } - if (effectsFlag & 2) { //nomask - es = data.word(kWorkspace); - frameoutnm(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); - return; - } - if (effectsFlag & 32) { - es = data.word(kWorkspace); - frameoutbh(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); - return; - } - } -//noeffects: - es = data.word(kWorkspace); - frameoutv(es.ptr(0, 65536), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); - return; } -void DreamGenContext::showframe() { - uint8 width, height; - showframe(es, ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); - cl = width; - ch = height; -} - -void DreamGenContext::printsprites() { - for (size_t priority = 0; priority < 7; ++priority) { - Sprite *sprites = spritetable(); - for (size_t j = 0; j < 16; ++j) { - const Sprite &sprite = sprites[j]; - if (READ_LE_UINT16(&sprite.updateCallback) == 0x0ffff) - continue; - if (priority != sprite.priority) - continue; - if (sprite.hidden == 1) - continue; - printasprite(&sprite); - } - } -} - -void DreamGenContext::printasprite(const Sprite *sprite) { +void DreamGenContext::turnpathoffCPP(uint8 param) { + al = param; push(es); push(bx); - ds = READ_LE_UINT16(&sprite->w6); - ax = sprite->y; - if (al >= 220) { - bx = data.word(kMapady) - (256 - al); - } else { - bx = ax + data.word(kMapady); - } - - ax = sprite->x; - if (al >= 220) { - di = data.word(kMapadx) - (256 - al); - } else { - di = ax + data.word(kMapadx); - } - - uint8 c; - if (sprite->b29 != 0) - c = 8; - else - c = 0; - uint8 width, height; - showframe(es, ds, di, bx, sprite->b15, c, &width, &height); - cl = width; - ch = height; - + turnpathoff(); bx = pop(); es = pop(); } -void DreamGenContext::eraseoldobs() { - if (data.byte(kNewobs) == 0) - return; +void DreamGenContext::modifychar() { + al = engine->modifyChar(al); +} - Sprite *sprites = spritetable(); - for (size_t i=0; i < 16; ++i) { - Sprite &sprite = sprites[i]; - if (READ_LE_UINT16(&sprite.obj_data) != 0xffff) { - memset(&sprite, 0xff, sizeof(Sprite)); +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 + // the pause will be read immediately unpause the game. + 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(); } } -void DreamGenContext::clearsprites() { - memset(spritetable(), 0xff, sizeof(Sprite) * 16); +void DreamGenContext::cancelch0() { + data.byte(kCh0repeat) = 0; + data.word(kCh0blockstocopy) = 0; + data.byte(kCh0playing) = 255; + engine->stopSound(0); } -Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi) { - Sprite *sprite = spritetable(); - while (sprite->b15 != 0xff) { // NB: No boundchecking in the original code either - ++sprite; - } +void DreamGenContext::cancelch1() { + data.word(kCh1blockstocopy) = 0; + data.byte(kCh1playing) = 255; + engine->stopSound(1); +} - WRITE_LE_UINT16(&sprite->updateCallback, updateCallback); - sprite->x = x; - sprite->y = y; - WRITE_LE_UINT16(&sprite->w6, somethingInDx); - WRITE_LE_UINT16(&sprite->w8, somethingInDi); - sprite->w2 = 0xffff; - sprite->b15 = 0; - sprite->delay = 0; - return sprite; +void DreamGenContext::getroomspaths() { + es = data.word(kReels); + bx = data.byte(kRoomnum) * 144; +} + +uint8 *DreamGenContext::getroomspathsCPP() { + void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); + return (uint8 *)result; } -void DreamGenContext::makesprite() { // NB: returns new sprite in es:bx - Sprite *sprite = makesprite(si & 0xff, si >> 8, cx, dx, di); +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); @@ -1230,428 +692,391 @@ void DreamGenContext::makesprite() { // NB: returns new sprite in es:bx Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); bx += sizeof(Sprite) * (sprite - sprites); // + sprite->setObjData(si); + if (priority == 255) + priority = 0; + sprite->priority = priority; + sprite->type = type; + sprite->b16 = 0; + sprite->delay = 0; + sprite->frame = 0; } -void DreamGenContext::spriteupdate() { - Sprite *sprites = spritetable(); - sprites[0].hidden = data.byte(kRyanon); - - Sprite *sprite = sprites; - for (size_t i=0; i < 16; ++i) { - uint16 updateCallback = READ_LE_UINT16(&sprite->updateCallback); - if (updateCallback != 0xffff) { - sprite->w24 = sprite->w2; - if (updateCallback == addr_mainman) // NB : Let's consider the callback as an enum while more code is not ported to C++ - mainmanCPP(sprite); - else { - assert(updateCallback == addr_backobject); - backobject(sprite); - } - } - - if (data.byte(kNowinnewroom) == 1) - break; - ++sprite; - } +void DreamGenContext::getroomdata() { + bx = kRoomdata + sizeof(Room) * al; } -void DreamGenContext::initman() { - Sprite *sprite = makesprite(data.byte(kRyanx), data.byte(kRyany), addr_mainman, data.word(kMainsprites), 0); - sprite->priority = 4; - sprite->b22 = 0; - sprite->b29 = 0; - - // Recover es:bx from sprite - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); - bx += 32 * (sprite - sprites); - // +void DreamGenContext::getroomdata(uint8 roomIndex) { + getroomdata(roomIndex); } -void DreamGenContext::mainmanCPP(Sprite *sprite) { - push(es); - push(ds); +void DreamGenContext::startloading() { + const Room *room = (Room *)cs.ptr(bx, sizeof(Room)); + startloading(room); +} - // Recover es:bx from sprite - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); - bx += 32 * (sprite - sprites); - // +void DreamGenContext::readheader() { + ax = engine->readFromFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen); + es = cs; + di = kFiledata; +} - if (data.byte(kResetmanxy) == 1) { - data.byte(kResetmanxy) = 0; - sprite->x = data.byte(kRyanx); - sprite->y = data.byte(kRyany); - sprite->b29 = 0; - } - --sprite->b22; - if (sprite->b22 != 0xff) { - ds = pop(); - es = pop(); - return; +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(); } - sprite->b22 = 0; - if (data.byte(kTurntoface) != data.byte(kFacing)) { - aboutturn(sprite); + findxyfrompath(); +} + +void DreamGenContext::fillspace() { + memset(ds.ptr(dx, cx), al, cx); +} + +void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) { + uint8 type = firstParam - 220; + if (type == 0) { + al = secondParam; + placesetobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 1) { + al = secondParam; + removesetobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 2) { + al = secondParam; + placefreeobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 3) { + al = secondParam; + removefreeobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 4) { + switchryanoff(); + } else if (type == 5) { + data.byte(kTurntoface) = secondParam; + data.byte(kFacing) = secondParam; + switchryanon(); + } else if (type == 6) { + data.byte(kNewlocation) = secondParam; } else { - if ((data.byte(kTurndirection) != 0) && (data.byte(kLinepointer) == 254)) { - data.byte(kReasseschanges) = 1; - if (data.byte(kFacing) == data.byte(kLeavedirection)) - checkforexit(); - } - data.byte(kTurndirection) = 0; - if (data.byte(kLinepointer) == 254) { - sprite->b29 = 0; - } else { - ++sprite->b29; - if (sprite->b29 == 11) - sprite->b29 = 1; - walking(); - if (data.byte(kLinepointer) != 254) { - if ((data.byte(kFacing) & 1) == 0) - walking(); - else if ((sprite->b29 != 2) && (sprite->b29 != 7)) - walking(); - } - if (data.byte(kLinepointer) == 254) { - if (data.byte(kTurntoface) == data.byte(kFacing)) { - data.byte(kReasseschanges) = 1; - if (data.byte(kFacing) == data.byte(kLeavedirection)) - checkforexit(); - } - } - } + movemap(secondParam); } - static const uint8 facelist[] = { 0,60,33,71,11,82,22,93 }; - sprite->b15 = sprite->b29 + facelist[data.byte(kFacing)]; - data.byte(kRyanx) = sprite->x; - data.byte(kRyany) = sprite->y; - - ds = pop(); - es = pop(); } -void DreamGenContext::walking() { - Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); - - uint8 comp; - if (data.byte(kLinedirection) != 0) { - --data.byte(kLinepointer); - comp = 200; - } else { - ++data.byte(kLinepointer); - comp = data.byte(kLinelength); - } - if (data.byte(kLinepointer) < comp) { - sprite->x = data.byte(kLinedata + data.byte(kLinepointer) * 2 + 0); - sprite->y = data.byte(kLinedata + data.byte(kLinepointer) * 2 + 1); - return; +void DreamGenContext::plotreel() { + Reel *reel = getreelstart(); + while (true) { + if (reel->x < 220) + break; + if (reel->x == 255) + break; + dealwithspecial(reel->x, reel->y); + ++data.word(kReelpointer); + reel += 8; } - data.byte(kLinepointer) = 254; - data.byte(kManspath) = data.byte(kDestination); - if (data.byte(kDestination) == data.byte(kFinaldest)) { - facerightway(); - return; + for (size_t i = 0; i < 8; ++i) { + if (reel->frame() != 0xffff) + showreelframe(reel); + ++reel; } - data.byte(kDestination) = data.byte(kFinaldest); - push(es); - push(bx); - autosetwalk(); - bx = pop(); - es = pop(); + soundonreels(); } -void DreamGenContext::aboutturn(Sprite *sprite) { - bool incdir = true; - - if (data.byte(kTurndirection) == 1) - incdir = true; - else if ((int8)data.byte(kTurndirection) == -1) - incdir = false; - else { - if (data.byte(kFacing) < data.byte(kTurntoface)) { - uint8 delta = data.byte(kTurntoface) - data.byte(kFacing); - if (delta >= 4) - incdir = false; - else - incdir = true; - } else { - uint8 delta = data.byte(kFacing) - data.byte(kTurntoface); - if (delta >= 4) - incdir = true; - else - incdir = false; - } - } - - if (incdir) { - data.byte(kTurndirection) = 1; - data.byte(kFacing) = (data.byte(kFacing) + 1) & 7; - sprite->b29 = 0; +void DreamGenContext::crosshair() { + uint8 frame; + if ((data.byte(kCommandtype) != 3) && (data.byte(kCommandtype) < 10)) { + frame = 9; } else { - data.byte(kTurndirection) = -1; - data.byte(kFacing) = (data.byte(kFacing) - 1) & 7; - sprite->b29 = 0; + frame = 29; } + const Frame *src = (const Frame *)segRef(data.word(kIcons1)).ptr(0, 0); + uint8 width, height; + showframe(src, kZoomx + 24, kZoomy + 19, frame, 0, &width, &height); } -void DreamGenContext::backobject(Sprite *sprite) { - push(es); - push(ds); - - // Recover es:bx from sprite - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); - bx += 32 * (sprite - sprites); - // - - ds = data.word(kSetdat); - di = READ_LE_UINT16(&sprite->obj_data); - ObjData *objData = (ObjData *)ds.ptr(di, 0); +void DreamGenContext::deltextline() { + uint16 x = data.word(kTextaddressx); + uint16 y = data.word(kTextaddressy); + if (data.byte(kForeignrelease) != 0) + y -= 3; + multiput(segRef(data.word(kBuffers)).ptr(kTextunder, 0), x, y, kUndertextsizex, kUndertextsizey); +} - if (sprite->delay != 0) { - --sprite->delay; - ds = pop(); - es = pop(); +void DreamGenContext::autosetwalk() { + al = data.byte(kManspath); + if (data.byte(kFinaldest) == al) + return; + const uint8 *roomsPaths = getroomspathsCPP(); + checkdest(roomsPaths); + 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; } - - sprite->delay = objData->delay; - if (objData->type == 6) - widedoor(sprite, objData); - else if (objData->type == 5) - random(sprite, objData); - else if (objData->type == 4) - lockeddoorway(); - else if (objData->type == 3) - liftsprite(sprite, objData); - else if (objData->type == 2) - doorway(sprite, objData); - else if (objData->type == 1) - constant(sprite, objData); - else - steady(sprite, objData); - - ds = pop(); - es = pop(); -} - -void DreamGenContext::constant(Sprite *sprite, ObjData *objData) { - ++sprite->frame; - if (objData->b18[sprite->frame] == 255) { - sprite->frame = 0; + data.byte(kLinepointer) = 0; +} + +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; } - uint8 b18 = objData->b18[sprite->frame]; - objData->b17 = b18; - sprite->b15 = b18; -} - -void DreamGenContext::random(Sprite *sprite, ObjData *objData) { - randomnum1(); - uint16 r = ax; - sprite->b15 = objData->b18[r&7]; -} - -void DreamGenContext::doorway(Sprite *sprite, ObjData *objData) { - data.byte(kDoorcheck1) = -24; - data.byte(kDoorcheck2) = 10; - data.byte(kDoorcheck3) = -30; - data.byte(kDoorcheck4) = 10; - dodoor(sprite, objData); -} - -void DreamGenContext::widedoor(Sprite *sprite, ObjData *objData) { - data.byte(kDoorcheck1) = -24; - data.byte(kDoorcheck2) = 24; - data.byte(kDoorcheck3) = -30; - data.byte(kDoorcheck4) = 24; - dodoor(sprite, objData); -} - -void DreamGenContext::dodoor() { - Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); - ObjData *objData = (ObjData *)ds.ptr(di, 0); - dodoor(sprite, objData); -} - -void DreamGenContext::dodoor(Sprite *sprite, ObjData *objData) { - uint8 ryanx = data.byte(kRyanx); - uint8 ryany = data.byte(kRyany); - int8 deltax = ryanx - sprite->x; - int8 deltay = ryany - sprite->y; - if (ryanx < sprite->x) { - if (deltax < (int8)data.byte(kDoorcheck1)) - goto shutdoor; - } else { - if (deltax >= data.byte(kDoorcheck2)) - goto shutdoor; + data.byte(kDestination) = destination; +} + +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(); + Reel *reel = getreelstart(); + 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; } - if (ryany < sprite->y) { - if (deltay < (int8)data.byte(kDoorcheck3)) - goto shutdoor; + return false; +} + +const uint8 *DreamGenContext::findobname(uint8 type, uint8 index) { + if (type == 5) { + uint16 i = 64 * 2 * (index & 127); + uint16 offset = segRef(data.word(kPeople)).word(kPersontxtdat + i) + kPersontext; + return segRef(data.word(kPeople)).ptr(offset, 0); + } else if (type == 4) { + uint16 offset = segRef(data.word(kExtras)).word(kExtextdat + index * 2) + kExtext; + return segRef(data.word(kExtras)).ptr(offset, 0); + } else if (type == 2) { + uint16 offset = segRef(data.word(kFreedesc)).word(kFreetextdat + index * 2) + kFreetext; + return segRef(data.word(kFreedesc)).ptr(offset, 0); + } else if (type == 1) { + uint16 offset = segRef(data.word(kSetdesc)).word(kSettextdat + index * 2) + kSettext; + return segRef(data.word(kSetdesc)).ptr(offset, 0); } else { - if (deltay >= data.byte(kDoorcheck4)) - goto shutdoor; - } -//opendoor: - if ((data.byte(kThroughdoor) == 1) && (sprite->frame == 0)) - sprite->frame = 6; - - ++sprite->frame; - if (sprite->frame == 1) { //doorsound2 - if (data.byte(kReallocation) == 5) //hoteldoor2 - al = 13; - else - al = 0; - playchannel1(); - } - if (objData->b18[sprite->frame] == 255) { - --sprite->frame; - } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; - data.byte(kThroughdoor) = 1; - return; -shutdoor: - if (sprite->frame == 5) { //doorsound1; - if (data.byte(kReallocation) == 5) //hoteldoor1 - al = 13; - else - al = 1; - playchannel1(); - } - if (sprite->frame != 0) { - --sprite->frame; + uint16 offset = segRef(data.word(kBlockdesc)).word(kBlocktextdat + index * 2) + kBlocktext; + return segRef(data.word(kBlockdesc)).ptr(offset, 0); } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; - if (sprite->frame == 5) //nearly - data.byte(kThroughdoor) = 0; -} - -void DreamGenContext::steady(Sprite *sprite, ObjData *objData) { - uint8 b18 = objData->b18[0]; - objData->b17 = b18; - sprite->b15 = b18; -} - -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(); +void DreamGenContext::copyname() { + copyname(ah, al, cs.ptr(di, 0)); } -void DreamGenContext::liftsprite() { - Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); - ObjData *objData = (ObjData *)ds.ptr(di, 0); - liftsprite(sprite, objData); -} - -void DreamGenContext::liftsprite(Sprite *sprite, ObjData *objData) { - uint8 liftFlag = data.byte(kLiftflag); - if (liftFlag == 0) { //liftclosed - turnpathoffCPP(data.byte(kLiftpath)); - - if (data.byte(kCounttoopen) != 0) { - _dec(data.byte(kCounttoopen)); - if (data.byte(kCounttoopen) == 0) - data.byte(kLiftflag) = 3; - } - sprite->frame = 0; - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; - } - else if (liftFlag == 1) { //liftopen - turnpathonCPP(data.byte(kLiftpath)); - - if (data.byte(kCounttoclose) != 0) { - _dec(data.byte(kCounttoclose)); - if (data.byte(kCounttoclose) == 0) - data.byte(kLiftflag) = 2; - } - sprite->frame = 12; - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; - } - else if (liftFlag == 3) { //openlift - if (sprite->frame == 12) { - data.byte(kLiftflag) = 1; - return; - } - ++sprite->frame; - if (sprite->frame == 1) { - al = 2; - liftnoise(); - } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; - } else { //closeLift - assert(liftFlag == 2); - if (sprite->frame == 0) { - data.byte(kLiftflag) = 0; - return; - } - --sprite->frame; - if (sprite->frame == 11) { - al = 3; - liftnoise(); - } - sprite->b15 = objData->b17 = objData->b18[sprite->frame]; +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; } + dst[i] = 0; } -void DreamGenContext::modifychar() { - al = engine->modifyChar(al); +void DreamGenContext::commandwithob() { + commandwithob(al, bh, bl); } -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 - // the pause will be read immediately unpause the game. - 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(); +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; } -void DreamGenContext::cancelch0() { - data.byte(kCh0repeat) = 0; - data.word(kCh0blockstocopy) = 0; - data.byte(kCh0playing) = 255; - engine->stopSound(0); +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); } -void DreamGenContext::cancelch1() { - data.word(kCh1blockstocopy) = 0; - data.byte(kCh1playing) = 255; - engine->stopSound(1); +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); } - } /*namespace dreamgen */ + diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index b633684f4d..c4385613f6 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -19,7 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ - + uint16 allocatemem(uint16 paragraphs); + uint8 *workspace(); + void allocatework(); + void clearwork(); void multidump(); void multidump(uint16 x, uint16 y, uint8 width, uint8 height); void frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); @@ -28,7 +31,7 @@ void frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); void worktoscreen(); void multiget(); - void multiget(uint16 x, uint16 y, uint8 width, uint8 height); + void multiget(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height); void convertkey(); void cls(); void printsprites(); @@ -38,39 +41,49 @@ void seecommandtail(); void randomnumber(); void quickquit2(); - void getnextword(); - uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount); - void printboth(); - void printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c); + uint8 getnextword(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount); + void printboth(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); - void printchar(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height); + void printchar(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height); void printdirect(); - void printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered); + void printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered); void usetimedtext(); + void dumptimedtext(); + void setuptimedtemp(); + void setuptimedtemp(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8 y, uint16 countToTimed, uint16 timeCount); void getundertimed(); void putundertimed(); - uint8 printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered); + uint8 printslow(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered); void printslow(); void dumptextline(); void getnumber(); - uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset); + uint8 getnumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset); void kernchars(); uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); + void getroomdata(); + void getroomdata(uint8 roomIndex); + void readheader(); + void fillspace(); + void startloading(); + void startloading(const Room *room); Sprite *spritetable(); void showframe(); - void showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); + void showframe(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); void printasprite(const Sprite *sprite); void width160(); - void multiput(uint16 x, uint16 y, uint8 width, uint8 height); + void multiput(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height); void multiput(); void eraseoldobs(); void clearsprites(); void makesprite(); - Sprite *makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi); + Sprite *makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi); void spriteupdate(); void initman(); - void mainmanCPP(Sprite *sprite); - void walking(); + void mainman(Sprite *sprite); + void facerightway(); + void walking(Sprite *sprite); + void autosetwalk(); + void checkdest(const uint8 *roomsPaths); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, ObjData *objData); @@ -80,11 +93,42 @@ void dodoor(Sprite *sprite, ObjData *objData); void doorway(Sprite *sprite, ObjData *objData); void widedoor(Sprite *sprite, ObjData *objData); - void liftsprite(); + void lockeddoorway(Sprite *sprite, ObjData *objData); void liftsprite(Sprite *sprite, ObjData *objData); + void findsource(); + Frame *findsourceCPP(); + void showgamereel(); + void showreelframe(); + void showreelframe(Reel *reel); + const Frame *getreelframeax(uint16 frame); void turnpathonCPP(uint8 param); void turnpathoffCPP(uint8 param); + void getroomspaths(); + uint8 *getroomspathsCPP(); + void makebackob(); void modifychar(); void lockmon(); void cancelch0(); void cancelch1(); + void plotreel(); + Reel *getreelstart(); + void dealwithspecial(uint8 firstParam, uint8 secondParam); + void zoom(); + void crosshair(); + void showrain(); + void deltextline(); + void doblocks(); + void checkifperson(); + bool checkifperson(uint8 x, uint8 y); + const uint8 *findobname(uint8 type, uint8 index); + void copyname(); + void copyname(uint8 type, uint8 index, uint8 *dst); + void commandwithob(); + void commandwithob(uint8 command, uint8 type, uint8 index); + void showpanel(); + void updatepeople(); + void madmantext(); + void madmode(); + void movemap(uint8 param); + bool isCD(); + diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp new file mode 100644 index 0000000000..c87e27a8c4 --- /dev/null +++ b/engines/dreamweb/vgagrafx.cpp @@ -0,0 +1,452 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "dreamweb/dreamweb.h" +#include "engines/util.h" +#include "graphics/surface.h" + +namespace DreamGen { + +uint8 *DreamGenContext::workspace() { + uint8 *result = segRef(data.word(kWorkspace)).ptr(0, 0); + return result; +} + +void DreamGenContext::allocatework() { + data.word(kWorkspace) = allocatemem(0x1000); +} + +void DreamGenContext::multiget() { + multiget(ds.ptr(si, 0), di, bx, cl, ch); + si += cl * ch; + di += bx * kScreenwidth + kScreenwidth * ch; + cx = 0; +} + +void DreamGenContext::multiget(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) { + const uint8 *src = workspace() + x + y * kScreenwidth; + if (y + h > 200) + h = 200 - y; + if (x + w > 320) + w = 320 - x; + //debug(1, "multiget %u,%u %ux%u -> segment: %04x->%04x", x, y, w, h, (uint16)ds, (uint16)es); + for(unsigned l = 0; l < h; ++l) { + const uint8 *src_p = src + kScreenwidth * l; + uint8 *dst_p = dst + w * l; + memcpy(dst_p, src_p, w); + } +} + +void DreamGenContext::multiput() { + multiput(ds.ptr(si, 0), di, bx, cl, ch); + si += cl * ch; + di += bx * kScreenwidth + kScreenwidth * ch; + cx = 0; +} + +void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) { + uint8 *dst = workspace() + x + y * kScreenwidth; + if (y + h > 200) + h = 200 - y; + if (x + w > 320) + w = 320 - x; + //debug(1, "multiput %ux%u -> segment: %04x->%04x", w, h, (uint16)ds, (uint16)es); + for(unsigned l = 0; l < h; ++l) { + const uint8 *src_p = src + w * l; + uint8 *dst_p = dst + kScreenwidth * l; + memcpy(dst_p, src_p, w); + } +} + +void DreamGenContext::multidump(uint16 x, uint16 y, uint8 width, uint8 height) { + unsigned offset = x + y * kScreenwidth; + //debug(1, "multidump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset); + engine->blit(workspace() + offset, kScreenwidth, x, y, width, height); +} + +void DreamGenContext::multidump() { + multidump(di, bx, cl, ch); + unsigned offset = di + bx * kScreenwidth; + si = di = offset + ch * kScreenwidth; + cx = 0; +} + +void DreamGenContext::worktoscreen() { + uint size = 320 * 200; + engine->blit(workspace(), 320, 0, 0, 320, 200); + di = si = size; + cx = 0; +} + +void DreamGenContext::printundermon() { + engine->printUnderMonitor(); +} + +void DreamGenContext::cls() { + engine->cls(); +} + +void DreamGenContext::frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { + dst += pitch * y + x; + + for (uint16 j = 0; j < height; ++j) { + memcpy(dst, src, width); + dst += pitch; + src += width; + } +} + +void DreamGenContext::frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { + uint16 stride = pitch - width; + dst += y * pitch + x; + + for (uint16 i = 0; i < height; ++i) { + for (uint16 j = 0; j < width; ++j) { + if (*dst == 0xff) { + *dst = *src; + } + ++src; + ++dst; + } + dst += stride; + } +} + +void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { + uint16 stride = pitch - width; + dst += y * pitch + x; + dst -= width; + + for (uint16 j = 0; j < height; ++j) { + for (uint16 i = 0; i < width; ++i) { + uint8 pixel = src[width - i - 1]; + if (pixel) + *dst = pixel; + ++dst; + } + src += width; + dst += stride; + } +} + +void DreamGenContext::doshake() { + uint8 &counter = data.byte(kShakecounter); + _cmp(counter, 48); + if (flags.z()) + return; + + _add(counter, 1); + static const int shakeTable[] = { + 0, -2, 3, -2, 0, 2, 4, -1, + 1, -3, 3, 2, 0, -2, 3, -2, + 0, 2, 4, -1, 1, -3, 3, 2, + 0, -2, 3, -2, 0, 2, 4, -1, + + 1, -3, 3, 2, 0, -2, 3, -2, + 0, 2, 4, -1, 1, -3, 3, 2, + 0, -2, 3, -2, 0, 2, 4, -1, + 1, -3, 3, 2, 0, -2, 3, -2, + + 0, 2, 4, -1, 1, -3, 3, 2, + 0, -2, 3, -2, 0, 2, 4, -1, + 1, -3, 3, 2, 0, -2, 3, -2, + 0, 2, 4, -1, 1, -3, 3, 2, + + 0, -2, 3, -2, 0, 2, 4, -1, + 1, -3, 3, 0, + }; + int offset = shakeTable[counter]; + engine->setShakePos(offset >= 0 ? offset : -offset); +} + +void DreamGenContext::vsync() { + push(ax); + push(bx); + push(cx); + push(dx); + push(si); + push(di); + push(es); + push(ds); + engine->waitForVSync(); + ds = pop(); + es = pop(); + di = pop(); + si = pop(); + dx = pop(); + cx = pop(); + bx = pop(); + ax = pop(); +} + +void DreamGenContext::setmode() { + vsync(); + initGraphics(320, 200, false); +} + +static Common::String getFilename(Context &context) { + uint16 name_ptr = context.dx; + Common::String name; + uint8 c; + while((c = context.cs.byte(name_ptr++)) != 0) + name += (char)c; + return name; +} + +void DreamGenContext::showpcx() { + Common::String name = getFilename(*this); + Common::File pcxFile; + + if (!pcxFile.open(name)) { + warning("showpcx: Could not open '%s'", name.c_str()); + return; + } + + uint8 *maingamepal; + int i, j; + + // Read the 16-color palette into the 'maingamepal' buffer. Note that + // the color components have to be adjusted from 8 to 6 bits. + + pcxFile.seek(16, SEEK_SET); + es = data.word(kBuffers); + maingamepal = es.ptr(kMaingamepal, 768); + pcxFile.read(maingamepal, 48); + + memset(maingamepal + 48, 0xff, 720); + for (i = 0; i < 48; i++) { + maingamepal[i] >>= 2; + } + + // Decode the image data. + + Graphics::Surface *s = g_system->lockScreen(); + Common::Rect rect(640, 480); + + s->fillRect(rect, 0); + pcxFile.seek(128, SEEK_SET); + + for (int y = 0; y < 480; y++) { + byte *dst = (byte *)s->getBasePtr(0, y); + int decoded = 0; + + while (decoded < 320) { + byte col = pcxFile.readByte(); + byte len; + + if ((col & 0xc0) == 0xc0) { + len = col & 0x3f; + col = pcxFile.readByte(); + } else { + len = 1; + } + + // The image uses 16 colors and is stored as four bit + // planes, one for each bit of the color, least + // significant bit plane first. + + for (i = 0; i < len; i++) { + int plane = decoded / 80; + int pos = decoded % 80; + + for (j = 0; j < 8; j++) { + byte bit = (col >> (7 - j)) & 1; + dst[8 * pos + j] |= (bit << plane); + } + + decoded++; + } + } + } + + g_system->unlockScreen(); + pcxFile.close(); +} + +void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) { + // NB : These resilience checks were not in the original engine, but did they result in undefined behaviour + // or was something broken during porting to C++? + assert(pitch == 320); + + if(x >= 320) + return; + if(y >= 200) + return; + if(x + width > 320) { + width = 320 - x; + } + if(y + height > 200) { + height = 200 - y; + } + + uint16 stride = pitch - width; + dst += pitch * y + x; + + for (uint16 j = 0; j < height; ++j) { + for (uint16 i = 0; i < width; ++i) { + uint8 pixel = *src++; + if (pixel) + *dst = pixel; + ++dst; + } + dst += stride; + } +} + +void DreamGenContext::showframe(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { + const Frame *frame = frameData + frameNumber; + if ((frame->width == 0) && (frame->height == 0)) { + *width = 0; + *height = 0; + return; + } + +//notblankshow: + if ((effectsFlag & 128) == 0) { + x += frame->x; + y += frame->y; + } +//skipoffsets: + + *width = frame->width; + *height = frame->height; + const uint8 *pSrc = ((const uint8 *)frameData) + frame->ptr() + 2080; + + if (effectsFlag) { + if (effectsFlag & 128) { //centred + x -= *width / 2; + y -= *height / 2; + } + if (effectsFlag & 64) { //diffdest + frameoutfx(es.ptr(0, dx * *height), pSrc, dx, *width, *height, x, y); + return; + } + if (effectsFlag & 8) { //printlist + /* + push(ax); + al = x - data.word(kMapadx); + ah = y - data.word(kMapady); + //addtoprintlist(); // NB: Commented in the original asm + ax = pop(); + */ + } + if (effectsFlag & 4) { //flippedx + frameoutfx(workspace(), pSrc, 320, *width, *height, x, y); + return; + } + if (effectsFlag & 2) { //nomask + frameoutnm(workspace(), pSrc, 320, *width, *height, x, y); + return; + } + if (effectsFlag & 32) { + frameoutbh(workspace(), pSrc, 320, *width, *height, x, y); + return; + } + } +//noeffects: + frameoutv(workspace(), pSrc, 320, *width, *height, x, y); + return; +} + +void DreamGenContext::showframe() { + uint8 width, height; + showframe((Frame *)ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); + cl = width; + ch = height; +} + +void DreamGenContext::clearwork() { + memset(workspace(), 0, 320*200); +} + +void DreamGenContext::doblocks() { + uint16 dstOffset = data.word(kMapady) * 320 + data.word(kMapadx); + uint16 mapOffset = kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx); + ds = data.word(kMapdata); + const uint8 *mapData = ds.ptr(mapOffset, 0); + ds = data.word(kBackdrop); + const uint8 *blocks = ds.ptr(kBlocks, 0); + es = data.word(kWorkspace); + uint8 *dstBuffer = es.ptr(dstOffset, 0); + + for (size_t i = 0; i < 10; ++i) { + for (size_t j = 0; j < 11; ++j) { + uint16 blockType = mapData[j]; + if (blockType != 0) { + uint8 *dst = dstBuffer + i * 320 * 16 + j * 16; + const uint8 *block = blocks + blockType * 256; + for (size_t k = 0; k < 4; ++k) { + memcpy(dst, block, 16); + block += 16; + dst += 320; + } + for (size_t k = 0; k < 12; ++k) { + memcpy(dst, block, 16); + memset(dst + 16, 0xdf, 4); + block += 16; + dst += 320; + } + dst += 4; + ax = 0x0dfdf; + memset(dst, 0xdf, 16); + dst += 320; + memset(dst, 0xdf, 16); + dst += 320; + memset(dst, 0xdf, 16); + dst += 320; + memset(dst, 0xdf, 16); + } + } + mapData += kMapwidth; + } +} + +void DreamGenContext::zoom() { + if (data.word(kWatchingtime) != 0) + return; + if (data.byte(kZoomon) != 1) + return; + if (data.byte(kCommandtype) >= 199) { + putunderzoom(); + return; + } + uint16 srcOffset = (data.word(kOldpointery) - 9) * 320 + (data.word(kOldpointerx) - 11); + uint16 dstOffset = (kZoomy + 4) * 320 + (kZoomx + 5); + const uint8 *src = workspace() + srcOffset; + uint8 *dst = workspace() + dstOffset; + for(size_t i=0; i<20; ++i) { + for(size_t j=0; j<23; ++j) { + uint8 v = src[j]; + dst[2*j+0] = v; + dst[2*j+1] = v; + dst[2*j+320] = v; + dst[2*j+321] = v; + } + src += 320; + dst += 320*2; + } + crosshair(); + data.byte(kDidzoom) = 1; +} + +} /*namespace dreamgen */ + |