From d1812fda52615f62d24b467e5a9c8784ab9e1dfd Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 25 Jul 2011 22:08:06 +0200 Subject: DREAMWEB: Fix (underlined object names) in 'printchar' parameter interpretation --- engines/dreamweb/stubs.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index ec94ffc40c..28c52e17d5 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -309,7 +309,8 @@ void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uin push(di); if (data.byte(kForeignrelease) != 0) y -= 3; - showframe(dst, src, *x, y, c - 32 + data.word(kCharshift), 0, width, height); + uint16 tmp = c - 32 + data.word(kCharshift); + showframe(dst, src, *x, y, tmp & 0xff, tmp >> 8, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); -- cgit v1.2.3 From fcd698c289a801e6e6b1e9fb76d22c3753c3ca41 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 25 Jul 2011 10:46:35 +0200 Subject: DREAMWEB: Fixed what is very probably a typo in original code and regenerated the source --- engines/dreamweb/dreamgen.cpp | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index c05cab5238..1aac7311d5 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3023,7 +3023,7 @@ opendoor2: goto mustbeopen; _cmp(data.byte(kLockstatus), 1); if (flags.z()) - goto shutdoor; + goto shutdoor2; mustbeopen: cl = es.byte(bx+19); _cmp(cl, 1); @@ -3104,38 +3104,6 @@ atlast4: 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() { -- cgit v1.2.3 From a101204422db7928aafcea1ff1e110979aa82c1b Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 25 Jul 2011 10:50:00 +0200 Subject: DREAMWEB: Ported 'lockeddoorway' --- engines/dreamweb/dreamgen.cpp | 123 ------------------------------------------ engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/stubs.cpp | 82 +++++++++++++++++++++++++++- engines/dreamweb/stubs.h | 2 + 4 files changed, 84 insertions(+), 126 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 1aac7311d5..7ec64263da 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2984,128 +2984,6 @@ void DreamGenContext::widedoor() { 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 shutdoor2; -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; -} - void DreamGenContext::updatepeople() { STACK_CHECK; es = data.word(kBuffers); @@ -21048,7 +20926,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index c2aa204942..037fd2ad2a 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -657,7 +657,6 @@ public: 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; @@ -1338,7 +1337,7 @@ public: void clearbuffers(); void neterror(); void storeit(); - void lockeddoorway(); + //void lockeddoorway(); void isitworn(); //void putundertimed(); void dumpmap(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 28c52e17d5..dff3756745 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1273,7 +1273,7 @@ void DreamGenContext::backobject(Sprite *sprite) { else if (objData->type == 5) random(sprite, objData); else if (objData->type == 4) - lockeddoorway(); + lockeddoorway(sprite, objData); else if (objData->type == 3) liftsprite(sprite, objData); else if (objData->type == 2) @@ -1402,6 +1402,86 @@ void DreamGenContext::turnpathoffCPP(uint8 param) { es = pop(); } +void DreamGenContext::lockeddoorway() { + Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); + ObjData *objData = (ObjData *)ds.ptr(di, 0); + lockeddoorway(sprite, objData); +} + +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) { + al = data.byte(kDoorpath); + push(es); + push(bx); + turnpathon(); + bx = pop(); + es = pop(); + } + + 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) { + al = data.byte(kDoorpath); + push(es); + push(bx); + turnpathoff(); + bx = pop(); + es = pop(); + data.byte(kLockstatus) = 1; + } +} + void DreamGenContext::liftsprite() { Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); ObjData *objData = (ObjData *)ds.ptr(di, 0); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 20d987d374..f173a84b83 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -80,6 +80,8 @@ void dodoor(Sprite *sprite, ObjData *objData); void doorway(Sprite *sprite, ObjData *objData); void widedoor(Sprite *sprite, ObjData *objData); + void lockeddoorway(); + void lockeddoorway(Sprite *sprite, ObjData *objData); void liftsprite(); void liftsprite(Sprite *sprite, ObjData *objData); void turnpathonCPP(uint8 param); -- cgit v1.2.3 From c0795b4b43e31d791e1e29dda02e18d4336a36e3 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 25 Jul 2011 23:54:54 +0200 Subject: DREAMWEB: Less register pollution --- engines/dreamweb/stubs.cpp | 20 +++++++------------- engines/dreamweb/stubs.h | 1 + 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index dff3756745..27c58bcf7b 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1155,12 +1155,12 @@ void DreamGenContext::mainmanCPP(Sprite *sprite) { ++sprite->b29; if (sprite->b29 == 11) sprite->b29 = 1; - walking(); + walking(sprite); if (data.byte(kLinepointer) != 254) { if ((data.byte(kFacing) & 1) == 0) - walking(); + walking(sprite); else if ((sprite->b29 != 2) && (sprite->b29 != 7)) - walking(); + walking(sprite); } if (data.byte(kLinepointer) == 254) { if (data.byte(kTurntoface) == data.byte(kFacing)) { @@ -1180,9 +1180,13 @@ void DreamGenContext::mainmanCPP(Sprite *sprite) { es = pop(); } + void DreamGenContext::walking() { Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); + walking(sprite); +} +void DreamGenContext::walking(Sprite *sprite) { uint8 comp; if (data.byte(kLinedirection) != 0) { --data.byte(kLinepointer); @@ -1246,16 +1250,8 @@ void DreamGenContext::aboutturn(Sprite *sprite) { } 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); @@ -1263,7 +1259,6 @@ void DreamGenContext::backobject(Sprite *sprite) { if (sprite->delay != 0) { --sprite->delay; ds = pop(); - es = pop(); return; } @@ -1284,7 +1279,6 @@ void DreamGenContext::backobject(Sprite *sprite) { steady(sprite, objData); ds = pop(); - es = pop(); } void DreamGenContext::constant(Sprite *sprite, ObjData *objData) { diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index f173a84b83..fcf72e0727 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -71,6 +71,7 @@ void initman(); void mainmanCPP(Sprite *sprite); void walking(); + void walking(Sprite *sprite); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, ObjData *objData); -- cgit v1.2.3 From 8233a37b4a17ff6a5b0e722b4dcdedb7d748da5e Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 26 Jul 2011 00:04:14 +0200 Subject: DREAMWEB: Extraction of sprite.cpp from stubs.cpp --- engines/dreamweb/module.mk | 1 + engines/dreamweb/sprite.cpp | 558 ++++++++++++++++++++++++++++++++++++++++++++ engines/dreamweb/stubs.cpp | 529 ----------------------------------------- 3 files changed, 559 insertions(+), 529 deletions(-) create mode 100644 engines/dreamweb/sprite.cpp (limited to 'engines') diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index 3b0c7f3325..fcda4fd6f4 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ detection.o \ dreamweb.o \ dreamgen.o \ + sprite.o \ stubs.o # This module can be built as a plugin diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp new file mode 100644 index 0000000000..5b0449f5b2 --- /dev/null +++ b/engines/dreamweb/sprite.cpp @@ -0,0 +1,558 @@ +/* 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() { + push(es); + push(bx); + + es = data.word(kBuffers); + bx = kSpritetable; + Sprite *sprite = (Sprite *)es.ptr(bx, 16 * sizeof(Sprite)); + + bx = pop(); + es = pop(); + + 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 (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) { + 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; + + bx = pop(); + es = pop(); +} + +void DreamGenContext::clearsprites() { + memset(spritetable(), 0xff, sizeof(Sprite) * 16); +} + +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; + } + + 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::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 = 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::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::mainmanCPP(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 = (Sprite *)es.ptr(bx, sizeof(Sprite)); + walking(sprite); +} + +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(Sprite *sprite) { + push(ds); + + ds = data.word(kSetdat); + di = READ_LE_UINT16(&sprite->obj_data); + ObjData *objData = (ObjData *)ds.ptr(di, 0); + + if (sprite->delay != 0) { + --sprite->delay; + ds = pop(); + 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); + + ds = pop(); +} + +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); + 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; + } + if (ryany < sprite->y) { + if (deltay < (int8)data.byte(kDoorcheck3)) + goto shutdoor; + } 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; + } + 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 = (Sprite *)es.ptr(bx, sizeof(Sprite)); + ObjData *objData = (ObjData *)ds.ptr(di, 0); + lockeddoorway(sprite, objData); +} + +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) { + al = data.byte(kDoorpath); + push(es); + push(bx); + turnpathon(); + bx = pop(); + es = pop(); + } + + 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) { + al = data.byte(kDoorpath); + push(es); + push(bx); + turnpathoff(); + bx = pop(); + es = pop(); + data.byte(kLockstatus) = 1; + } +} + +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]; + } +} + +} /*namespace dreamgen */ + diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 27c58bcf7b..b5373649ef 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -898,20 +898,6 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint } } -Sprite *DreamGenContext::spritetable() { - push(es); - push(bx); - - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprite = (Sprite *)es.ptr(bx, 16 * sizeof(Sprite)); - - bx = pop(); - es = pop(); - - return sprite; -} - void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { es = dst; ds = src; @@ -986,54 +972,6 @@ void DreamGenContext::showframe() { 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) { - 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; - - bx = pop(); - es = pop(); -} - void DreamGenContext::eraseoldobs() { if (data.byte(kNewobs) == 0) return; @@ -1047,337 +985,6 @@ void DreamGenContext::eraseoldobs() { } } -void DreamGenContext::clearsprites() { - memset(spritetable(), 0xff, sizeof(Sprite) * 16); -} - -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; - } - - 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::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 = 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::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::mainmanCPP(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 = (Sprite *)es.ptr(bx, sizeof(Sprite)); - walking(sprite); -} - -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(Sprite *sprite) { - push(ds); - - ds = data.word(kSetdat); - di = READ_LE_UINT16(&sprite->obj_data); - ObjData *objData = (ObjData *)ds.ptr(di, 0); - - if (sprite->delay != 0) { - --sprite->delay; - ds = pop(); - 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); - - ds = pop(); -} - -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); - 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; - } - if (ryany < sprite->y) { - if (deltay < (int8)data.byte(kDoorcheck3)) - goto shutdoor; - } 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; - } - 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); @@ -1396,142 +1003,6 @@ void DreamGenContext::turnpathoffCPP(uint8 param) { es = pop(); } -void DreamGenContext::lockeddoorway() { - Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); - ObjData *objData = (ObjData *)ds.ptr(di, 0); - lockeddoorway(sprite, objData); -} - -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) { - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathon(); - bx = pop(); - es = pop(); - } - - 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) { - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathoff(); - bx = pop(); - es = pop(); - data.byte(kLockstatus) = 1; - } -} - -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::modifychar() { al = engine->modifyChar(al); } -- cgit v1.2.3 From 521ffc5b5627fd3894c4088c0a69cae8c56784cf Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 26 Jul 2011 00:34:41 +0200 Subject: DREAMWEB: Extraction of print.cpp from stubs.cpp --- engines/dreamweb/module.mk | 1 + engines/dreamweb/print.cpp | 251 +++++++++++++++++++++++++++++++++++++++++++++ engines/dreamweb/stubs.cpp | 221 --------------------------------------- 3 files changed, 252 insertions(+), 221 deletions(-) create mode 100644 engines/dreamweb/print.cpp (limited to 'engines') diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index fcda4fd6f4..9c8106db90 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ detection.o \ dreamweb.o \ dreamgen.o \ + print.o \ sprite.o \ stubs.o diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp new file mode 100644 index 0000000000..f2a7450cc1 --- /dev/null +++ b/engines/dreamweb/print.cpp @@ -0,0 +1,251 @@ +/* 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() { + 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); + if (data.byte(kForeignrelease) != 0) + y -= 3; + uint16 tmp = c - 32 + data.word(kCharshift); + showframe(dst, src, *x, y, tmp & 0xff, tmp >> 8, width, height); + di = pop(); + si = pop(); + _cmp(data.byte(kKerning), 0); + if (flags.z()) + kernchars(); + (*x) += *width; +} + +void DreamGenContext::printslow() { + al = printslow(di, bx, dl, (bool)(dl & 1)); +} + +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); + 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::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; + } + 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/stubs.cpp b/engines/dreamweb/stubs.cpp index b5373649ef..0eb2d6de1f 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -246,83 +246,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); - if (data.byte(kForeignrelease) != 0) - y -= 3; - uint16 tmp = c - 32 + data.word(kCharshift); - showframe(dst, src, *x, y, tmp & 0xff, tmp >> 8, width, height); - di = pop(); - si = pop(); - _cmp(data.byte(kKerning), 0); - if (flags.z()) - kernchars(); - (*x) += *width; -} - -void DreamGenContext::printslow() { - al = printslow(di, bx, dl, (bool)(dl & 1)); -} - void DreamGenContext::dumptextline() { if (data.byte(kNewtextline) != 1) return; @@ -334,92 +257,6 @@ 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); - 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)) @@ -460,64 +297,6 @@ void DreamGenContext::usetimedtext() { 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; - } - 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); -} - void DreamGenContext::gettime() { TimeDate t; g_system->getTimeAndDate(t); -- cgit v1.2.3 From dfec38c615279dad5f6bc41ad7843e20bcd27d22 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 26 Jul 2011 00:56:24 +0200 Subject: DREAMWEB: Misc. register usage cleaning --- engines/dreamweb/sprite.cpp | 48 ++++++++++++++------------------------------- engines/dreamweb/stubs.h | 3 ++- 2 files changed, 17 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 5b0449f5b2..6ed0421a93 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -28,19 +28,17 @@ namespace DreamGen { Sprite *DreamGenContext::spritetable() { push(es); - push(bx); - es = data.word(kBuffers); - bx = kSpritetable; - Sprite *sprite = (Sprite *)es.ptr(bx, 16 * sizeof(Sprite)); - - bx = pop(); + Sprite *sprite = (Sprite *)es.ptr(kSpritetable, 16 * sizeof(Sprite)); es = pop(); - return sprite; } void DreamGenContext::printsprites() { + printsprites(es); +} + +void DreamGenContext::printsprites(uint16 dst) { for (size_t priority = 0; priority < 7; ++priority) { Sprite *sprites = spritetable(); for (size_t j = 0; j < 16; ++j) { @@ -51,27 +49,23 @@ void DreamGenContext::printsprites() { continue; if (sprite.hidden == 1) continue; - printasprite(&sprite); + printasprite(dst, &sprite); } } } -void DreamGenContext::printasprite(const Sprite *sprite) { - push(es); - push(bx); - ds = READ_LE_UINT16(&sprite->w6); - ax = sprite->y; - if (al >= 220) { - bx = data.word(kMapady) - (256 - al); +void DreamGenContext::printasprite(uint16 dst, const Sprite *sprite) { + uint16 x, y; + if (sprite->y >= 220) { + y = data.word(kMapady) - (256 - sprite->y); } else { - bx = ax + data.word(kMapady); + y = sprite->y + data.word(kMapady); } - ax = sprite->x; - if (al >= 220) { - di = data.word(kMapadx) - (256 - al); + if (sprite->x >= 220) { + x = data.word(kMapadx) - (256 - sprite->x); } else { - di = ax + data.word(kMapadx); + x = sprite->x + data.word(kMapadx); } uint8 c; @@ -80,12 +74,7 @@ void DreamGenContext::printasprite(const Sprite *sprite) { else c = 0; uint8 width, height; - showframe(es, ds, di, bx, sprite->b15, c, &width, &height); - cl = width; - ch = height; - - bx = pop(); - es = pop(); + showframe(es, READ_LE_UINT16(&sprite->w6), x, y, sprite->b15, c, &width, &height); } void DreamGenContext::clearsprites() { @@ -148,13 +137,6 @@ void DreamGenContext::initman() { 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::mainmanCPP(Sprite *sprite) { diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index fcf72e0727..b1e4be5f06 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -32,6 +32,7 @@ void convertkey(); void cls(); void printsprites(); + void printsprites(uint16 dst); void quickquit(); void readoneblock(); void printundermon(); @@ -59,7 +60,7 @@ Sprite *spritetable(); void showframe(); void showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); - void printasprite(const Sprite *sprite); + void printasprite(uint16 dst, const Sprite *sprite); void width160(); void multiput(uint16 x, uint16 y, uint8 width, uint8 height); void multiput(); -- cgit v1.2.3 From 5fc6a6e385813bb2b060e79f7853cd6ad112cad7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 26 Jul 2011 07:54:25 +0200 Subject: DREAMWEB: 'getroomspaths' and 'facerightway' ported to C++ --- engines/dreamweb/dreamgen.cpp | 31 ------------------------------- engines/dreamweb/dreamgen.h | 6 ++---- engines/dreamweb/sprite.cpp | 7 +++++++ engines/dreamweb/stubs.cpp | 13 +++++++++++++ engines/dreamweb/stubs.h | 3 +++ 5 files changed, 25 insertions(+), 35 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 7ec64263da..182a4411dd 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2395,24 +2395,6 @@ decdir: 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); @@ -18566,17 +18548,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); @@ -20908,7 +20879,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; @@ -21457,7 +21427,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 037fd2ad2a..130e0f0b5b 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -123,7 +123,6 @@ public: 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; @@ -674,7 +673,6 @@ 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; @@ -1513,7 +1511,7 @@ public: void fillopen(); //void usetimedtext(); void delsprite(); - void getroomspaths(); + //void getroomspaths(); //void dumptextline(); void fadescreendownhalf(); void useplate(); @@ -1902,7 +1900,7 @@ public: void checkdest(); //void initman(); void loadpalfromiff(); - void facerightway(); + //void facerightway(); void startup1(); void findlen(); void showsymbol(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 6ed0421a93..ed54ea12f7 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -536,5 +536,12 @@ void DreamGenContext::liftsprite(Sprite *sprite, ObjData *objData) { } } +void DreamGenContext::facerightway() { + uint8 *paths = getroomspathsCPP(); + uint8 dir = paths[8 * data.byte(kManspath) + 7]; + data.byte(kTurntoface) = dir; + data.byte(kLeavedirection) = dir; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 0eb2d6de1f..dc9d60082b 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -825,5 +825,18 @@ void DreamGenContext::cancelch1() { engine->stopSound(1); } +void DreamGenContext::getroomspaths() { + es = data.word(kReels); + bx = data.byte(kRoomnum) * 144; +} + +uint8 *DreamGenContext::getroomspathsCPP() { + push(es); + es = data.word(kReels); + void *result = es.ptr(data.byte(kRoomnum) * 144, 144); + es = pop(); + return (uint8 *)result; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index b1e4be5f06..6c12ce4807 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -71,6 +71,7 @@ void spriteupdate(); void initman(); void mainmanCPP(Sprite *sprite); + void facerightway(); void walking(); void walking(Sprite *sprite); void aboutturn(Sprite *sprite); @@ -88,6 +89,8 @@ void liftsprite(Sprite *sprite, ObjData *objData); void turnpathonCPP(uint8 param); void turnpathoffCPP(uint8 param); + void getroomspaths(); + uint8 *getroomspathsCPP(); void modifychar(); void lockmon(); void cancelch0(); -- cgit v1.2.3 From f657d4800a93d6111d723f702aebf42d98ccbf0f Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 27 Jul 2011 14:56:02 +0200 Subject: DREAMWEB: Cleanings and less register use --- engines/dreamweb/sprite.cpp | 14 ++-------- engines/dreamweb/stubs.cpp | 64 ++++++++++++++++++--------------------------- engines/dreamweb/stubs.h | 2 +- 3 files changed, 29 insertions(+), 51 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index ed54ea12f7..00d778c477 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -434,12 +434,7 @@ void DreamGenContext::lockeddoorway(Sprite *sprite, ObjData *objData) { } if (sprite->frame == 6) { - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathon(); - bx = pop(); - es = pop(); + turnpathonCPP(data.byte(kDoorpath)); } if ((data.byte(kThroughdoor) == 1) && (sprite->frame == 0)) { @@ -470,12 +465,7 @@ shutdoor2: sprite->b15 = objData->b17 = objData->b18[sprite->frame]; if (sprite->frame == 0) { - al = data.byte(kDoorpath); - push(es); - push(bx); - turnpathoff(); - bx = pop(); - es = pop(); + turnpathoffCPP(data.byte(kDoorpath)); data.byte(kLockstatus) = 1; } } diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index dc9d60082b..bf649aeb02 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -35,6 +35,14 @@ Common::String getFilename(Context &context) { return name; } +uint8 *DreamGenContext::workspace() { + push(es); + es = data.word(kWorkspace); + uint8 *result = es.ptr(0, 0); + es = pop(); + return result; +} + void DreamGenContext::multiget() { multiget(di, bx, cl, ch); } @@ -97,9 +105,8 @@ void DreamGenContext::multidump() { } void DreamGenContext::worktoscreen() { - ds = data.word(kWorkspace); uint size = 320 * 200; - engine->blit(ds.ptr(0, size), 320, 0, 0, 320, 200); + engine->blit(workspace(), 320, 0, 0, 320, 200); di = si = size; cx = 0; } @@ -634,19 +641,6 @@ void DreamGenContext::showpcx() { 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++? @@ -680,8 +674,6 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { es = dst; ds = src; - di = x; - bx = y; al = frameNumber; ah = effectsFlag; @@ -694,53 +686,49 @@ void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint //notblankshow: if ((effectsFlag & 128) == 0) { - di += ds.byte(si + 4); - bx += ds.byte(si + 5); + x += ds.byte(si + 4); + y += ds.byte(si + 5); } //skipoffsets: - cx = ds.word(si + 0); - *width = cl; - *height = ch; + + *width = ds.byte(si + 0); + *height = ds.byte(si + 1); si = ds.word(si+2) + 2080; + const uint8 *pSrc = ds.ptr(si, *width * *height); if (effectsFlag) { if (effectsFlag & 128) { //centred - di -= *width / 2; - bx -= *height / 2; + x -= *width / 2; + y -= *height / 2; } if (effectsFlag & 64) { //diffdest - frameoutfx(es.ptr(0, dx * *height), ds.ptr(si, *width * *height), dx, *width, *height, di, bx); + frameoutfx(es.ptr(0, dx * *height), pSrc, dx, *width, *height, x, y); return; } if (effectsFlag & 8) { //printlist + /* push(ax); - ax = di - data.word(kMapadx); - push(bx); - bx -= data.word(kMapady); - ah = bl; - bx = pop(); + al = x - data.word(kMapadx); + ah = y - data.word(kMapady); //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); + frameoutfx(workspace(), pSrc, 320, *width, *height, x, y); 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); + frameoutnm(workspace(), pSrc, 320, *width, *height, x, y); return; } if (effectsFlag & 32) { - es = data.word(kWorkspace); - frameoutbh(es.ptr(0, 320 * *height), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); + frameoutbh(workspace(), pSrc, 320, *width, *height, x, y); return; } } //noeffects: - es = data.word(kWorkspace); - frameoutv(es.ptr(0, 65536), ds.ptr(si, *width * *height), 320, *width, *height, di, bx); + frameoutv(workspace(), pSrc, 320, *width, *height, x, y); return; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 6c12ce4807..d48d634371 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ - + uint8 *workspace(); 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); -- cgit v1.2.3 From b5c6ac150b81d49dad0a9d2f6327cb85a7c525ff Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 27 Jul 2011 17:42:11 +0200 Subject: DREAMWEB: diffDest blitting in 'showframe' doesn't pollute the interface any more --- engines/dreamweb/print.cpp | 20 +++++++++----------- engines/dreamweb/sprite.cpp | 10 +++------- engines/dreamweb/stubs.cpp | 5 ++--- engines/dreamweb/stubs.h | 11 +++++------ 4 files changed, 19 insertions(+), 27 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index f2a7450cc1..a73e9f0792 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -28,14 +28,14 @@ namespace DreamGen { void DreamGenContext::printboth() { uint16 x = di; - printboth(es, ds, &x, bx, al); + printboth(ds, &x, bx, al); di = x; } -void DreamGenContext::printboth(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c) { +void DreamGenContext::printboth(uint16 src, uint16 *x, uint16 y, uint8 c) { uint16 newX = *x; uint8 width, height; - printchar(dst, src, &newX, y, c, &width, &height); + printchar(src, &newX, y, c, &width, &height); multidump(*x, y, width, height); *x = newX; } @@ -76,13 +76,13 @@ void DreamGenContext::getnextword() { void DreamGenContext::printchar() { uint16 x = di; uint8 width, height; - printchar(es, ds, &x, bx, al, &width, &height); + printchar(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) { +void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 *width, uint8 *height) { if (c == 255) return; push(si); @@ -90,7 +90,7 @@ void DreamGenContext::printchar(uint16 dst, uint16 src, uint16* x, uint16 y, uin if (data.byte(kForeignrelease) != 0) y -= 3; uint16 tmp = c - 32 + data.word(kCharshift); - showframe(dst, src, *x, y, tmp & 0xff, tmp >> 8, width, height); + showframe(src, *x, y, tmp & 0xff, tmp >> 8, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); @@ -117,7 +117,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center push(es); push(ds); c0 = engine->modifyChar(c0); - printboth(es, ds, &offset, y, c0); + printboth(ds, &offset, y, c0); ds = pop(); es = pop(); uint8 c1 = es.byte(si+1); @@ -133,7 +133,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center c1 = engine->modifyChar(c1); data.word(kCharshift) = 91; uint16 offset2 = offset; - printboth(es, ds, &offset2, y, c1); + printboth(ds, &offset2, y, c1); data.word(kCharshift) = 0; es = pop(); ds = pop(); @@ -179,9 +179,7 @@ void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool cent } c = engine->modifyChar(c); uint8 width, height; - push(es); - printchar(es, ds, &i, *y, c, &width, &height); - es = pop(); + printchar(ds, &i, *y, c, &width, &height); data.word(kLastxpos) = i; --charCount; } while(charCount); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 00d778c477..d6347b62bf 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -35,10 +35,6 @@ Sprite *DreamGenContext::spritetable() { } void DreamGenContext::printsprites() { - printsprites(es); -} - -void DreamGenContext::printsprites(uint16 dst) { for (size_t priority = 0; priority < 7; ++priority) { Sprite *sprites = spritetable(); for (size_t j = 0; j < 16; ++j) { @@ -49,12 +45,12 @@ void DreamGenContext::printsprites(uint16 dst) { continue; if (sprite.hidden == 1) continue; - printasprite(dst, &sprite); + printasprite(&sprite); } } } -void DreamGenContext::printasprite(uint16 dst, const Sprite *sprite) { +void DreamGenContext::printasprite(const Sprite *sprite) { uint16 x, y; if (sprite->y >= 220) { y = data.word(kMapady) - (256 - sprite->y); @@ -74,7 +70,7 @@ void DreamGenContext::printasprite(uint16 dst, const Sprite *sprite) { else c = 0; uint8 width, height; - showframe(es, READ_LE_UINT16(&sprite->w6), x, y, sprite->b15, c, &width, &height); + showframe(READ_LE_UINT16(&sprite->w6), x, y, sprite->b15, c, &width, &height); } void DreamGenContext::clearsprites() { diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index bf649aeb02..140e278d1d 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -671,8 +671,7 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint } } -void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { - es = dst; +void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { ds = src; al = frameNumber; ah = effectsFlag; @@ -734,7 +733,7 @@ void DreamGenContext::showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint void DreamGenContext::showframe() { uint8 width, height; - showframe(es, ds, di, bx, al, ah, &width, &height); + showframe(ds, di, bx, al, ah, &width, &height); cl = width; ch = height; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index d48d634371..559c95625d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -32,7 +32,6 @@ void convertkey(); void cls(); void printsprites(); - void printsprites(uint16 dst); void quickquit(); void readoneblock(); void printundermon(); @@ -42,9 +41,9 @@ 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); + void printboth(uint16 src, uint16 *x, uint16 y, uint8 c); void printchar(); - void printchar(uint16 dst, uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height); + void printchar(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height); void printdirect(); void printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered); void usetimedtext(); @@ -54,13 +53,13 @@ void printslow(); void dumptextline(); void getnumber(); - uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset); + uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16 *offset); void kernchars(); uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); Sprite *spritetable(); void showframe(); - void showframe(uint16 dst, uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); - void printasprite(uint16 dst, const Sprite *sprite); + void showframe(uint16 src, uint16 x, uint16 y, uint8 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(); -- cgit v1.2.3 From fe73a2407820000d0321173a50e0d98dbcfc213f Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 27 Jul 2011 17:53:50 +0200 Subject: DREAMWEB: 'makebackob' ported --- engines/dreamweb/dreamgen.cpp | 35 ----------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/structs.h | 3 ++- engines/dreamweb/stubs.cpp | 23 +++++++++++++++++++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 27 insertions(+), 38 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 182a4411dd..9fa7f16995 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -7476,40 +7476,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); @@ -21046,7 +21012,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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 130e0f0b5b..2b7149621b 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -505,7 +505,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; @@ -1559,7 +1558,7 @@ public: void discops(); //void printdirect(); void delthisone(); - void makebackob(); + //void makebackob(); void middlepanel(); void dumpwatch(); void saveload(); diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index e274375cf4..ac304ae2c2 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -31,7 +31,8 @@ struct Sprite { uint16 w12; uint8 b14; uint8 b15; - uint16 w16; + uint8 b16; + uint8 b17; uint8 delay; uint8 frame; uint16 obj_data; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 140e278d1d..8c278b5990 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -825,5 +825,28 @@ uint8 *DreamGenContext::getroomspathsCPP() { return (uint8 *)result; } +void DreamGenContext::makebackob() { + if (data.byte(kNewobs) == 0) + return; + uint8 priority = es.byte(si+5); + uint8 type = es.byte(si+8); + Sprite *sprite = makesprite(data.word(kObjectx), data.word(kObjecty), addr_backobject, data.word(kSetframes), 0); + + // Recover es:bx from sprite + es = data.word(kBuffers); + bx = kSpritetable; + Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); + bx += sizeof(Sprite) * (sprite - sprites); + // + WRITE_LE_UINT16(&sprite->obj_data, si); + if (priority == 255) + priority = 0; + sprite->priority = priority; + sprite->type = type; + sprite->b16 = 0; + sprite->delay = 0; + sprite->frame = 0; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 559c95625d..e72229639b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -90,6 +90,7 @@ void turnpathoffCPP(uint8 param); void getroomspaths(); uint8 *getroomspathsCPP(); + void makebackob(); void modifychar(); void lockmon(); void cancelch0(); -- cgit v1.2.3 From 27482d2de2d2112526e70123febd1527902913be Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 29 Jul 2011 00:00:45 +0200 Subject: DREAMWEB: Fixed showframe ABI to conform to wjp's patch c626394f2b6566bc310f7fb02b9449acc2e8f00f --- engines/dreamweb/print.cpp | 2 +- engines/dreamweb/stubs.cpp | 7 +++---- engines/dreamweb/stubs.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index a73e9f0792..46d7d45b1a 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -90,7 +90,7 @@ void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 if (data.byte(kForeignrelease) != 0) y -= 3; uint16 tmp = c - 32 + data.word(kCharshift); - showframe(src, *x, y, tmp & 0xff, tmp >> 8, width, height); + showframe(src, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 8c278b5990..688ad82d92 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -671,12 +671,11 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint } } -void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { +void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { ds = src; - al = frameNumber; ah = effectsFlag; - si = (ax & 0x1ff) * 6; + si = frameNumber * 6; if (ds.word(si) == 0) { *width = 0; *height = 0; @@ -733,7 +732,7 @@ void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint8 frameNumbe void DreamGenContext::showframe() { uint8 width, height; - showframe(ds, di, bx, al, ah, &width, &height); + showframe(ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); cl = width; ch = height; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index e72229639b..33b272efc6 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -58,7 +58,7 @@ uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); Sprite *spritetable(); void showframe(); - void showframe(uint16 src, uint16 x, uint16 y, uint8 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); + void showframe(uint16 src, 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); -- cgit v1.2.3 From d6ed3ed013b75f05c7e2ba8195b08e537a82c972 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 29 Jul 2011 00:05:43 +0200 Subject: DREAMWEB: 'kernchar' fix --- engines/dreamweb/print.cpp | 22 ++++++++++++---------- engines/dreamweb/stubs.h | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 46d7d45b1a..882b4578ce 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -28,14 +28,14 @@ namespace DreamGen { void DreamGenContext::printboth() { uint16 x = di; - printboth(ds, &x, bx, al); + printboth(ds, &x, bx, al, ah); di = x; } -void DreamGenContext::printboth(uint16 src, uint16 *x, uint16 y, uint8 c) { +void DreamGenContext::printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; - printchar(src, &newX, y, c, &width, &height); + printchar(src, &newX, y, c, nextChar, &width, &height); multidump(*x, y, width, height); *x = newX; } @@ -76,13 +76,13 @@ void DreamGenContext::getnextword() { void DreamGenContext::printchar() { uint16 x = di; uint8 width, height; - printchar(ds, &x, bx, al, &width, &height); + printchar(ds, &x, bx, al, ah, &width, &height); di = x; cl = width; ch = height; } -void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 *width, uint8 *height) { +void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { if (c == 255) return; push(si); @@ -95,7 +95,7 @@ void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 si = pop(); _cmp(data.byte(kKerning), 0); if (flags.z()) - kernchars(); + *width = kernchars(c, nextChar, *width); (*x) += *width; } @@ -114,13 +114,14 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center push(si); push(es); uint8 c0 = es.byte(si); + uint8 c1 = es.byte(si+1); + uint8 c2 = es.byte(si+2); push(es); push(ds); c0 = engine->modifyChar(c0); - printboth(ds, &offset, y, c0); + printboth(ds, &offset, y, c0, c1); ds = pop(); es = pop(); - uint8 c1 = es.byte(si+1); ++si; if ((c1 == 0) || (c1 == ':')) { es = pop(); @@ -133,7 +134,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center c1 = engine->modifyChar(c1); data.word(kCharshift) = 91; uint16 offset2 = offset; - printboth(ds, &offset2, y, c1); + printboth(ds, &offset2, y, c1, c2); data.word(kCharshift) = 0; es = pop(); ds = pop(); @@ -173,13 +174,14 @@ void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool cent uint16 i = offset; do { uint8 c = es.byte(si); + uint8 nextChar = es.byte(si+1); ++si; if ((c == 0) || (c == ':')) { return; } c = engine->modifyChar(c); uint8 width, height; - printchar(ds, &i, *y, c, &width, &height); + printchar(ds, &i, *y, c, nextChar, &width, &height); data.word(kLastxpos) = i; --charCount; } while(charCount); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 33b272efc6..3a00c16d4d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -41,9 +41,9 @@ void getnextword(); uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount); void printboth(); - void printboth(uint16 src, uint16 *x, uint16 y, uint8 c); + void printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); - void printchar(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 *width, uint8 *height); + void printchar(uint16 src, 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 usetimedtext(); -- cgit v1.2.3 From 5de064f1e4416d03daf9728a7f552c8a270424dd Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Fri, 29 Jul 2011 01:12:29 +0200 Subject: DREAMWEB: Use of the new feature of the generator to stop generating code for 'backobject' and 'mainman' (because addr_backobject is used) --- engines/dreamweb/dreamgen.cpp | 152 ------------------------------------------ engines/dreamweb/sprite.cpp | 12 +++- engines/dreamweb/stubs.h | 2 +- 3 files changed, 11 insertions(+), 155 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index fbd7c079e0..ed9481fb13 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2258,104 +2258,6 @@ over1001: 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); @@ -2841,60 +2743,6 @@ 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); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index d6347b62bf..76755a007e 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -115,7 +115,7 @@ void DreamGenContext::spriteupdate() { 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); + mainman(sprite); else { assert(updateCallback == addr_backobject); backobject(sprite); @@ -135,7 +135,11 @@ void DreamGenContext::initman() { sprite->b29 = 0; } -void DreamGenContext::mainmanCPP(Sprite *sprite) { +void DreamGenContext::mainman() { + assert(false); +} + +void DreamGenContext::mainman(Sprite *sprite) { push(es); push(ds); @@ -267,6 +271,10 @@ void DreamGenContext::aboutturn(Sprite *sprite) { } } +void DreamGenContext::backobject() { + assert(false); +} + void DreamGenContext::backobject(Sprite *sprite) { push(ds); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 3a00c16d4d..0ae76419e9 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -69,7 +69,7 @@ Sprite *makesprite(uint8 x, uint8 y, uint16 updateCallback, uint16 somethingInDx, uint16 somethingInDi); void spriteupdate(); void initman(); - void mainmanCPP(Sprite *sprite); + void mainman(Sprite *sprite); void facerightway(); void walking(); void walking(Sprite *sprite); -- cgit v1.2.3 From 69f7a6bcdf7b7667894b6167fb5b3fbc9be116d6 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 15:52:28 +0200 Subject: DREAMWEB: Encapsulated some endian conversions in accessors --- engines/dreamweb/sprite.cpp | 8 ++++---- engines/dreamweb/structs.h | 10 ++++++++-- engines/dreamweb/stubs.cpp | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 76755a007e..9987224cd7 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -39,7 +39,7 @@ void DreamGenContext::printsprites() { Sprite *sprites = spritetable(); for (size_t j = 0; j < 16; ++j) { const Sprite &sprite = sprites[j]; - if (READ_LE_UINT16(&sprite.updateCallback) == 0x0ffff) + if (sprite.updateCallback() == 0x0ffff) continue; if (priority != sprite.priority) continue; @@ -83,7 +83,7 @@ Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uin ++sprite; } - WRITE_LE_UINT16(&sprite->updateCallback, updateCallback); + sprite->setUpdateCallback(updateCallback); sprite->x = x; sprite->y = y; WRITE_LE_UINT16(&sprite->w6, somethingInDx); @@ -111,7 +111,7 @@ void DreamGenContext::spriteupdate() { Sprite *sprite = sprites; for (size_t i=0; i < 16; ++i) { - uint16 updateCallback = READ_LE_UINT16(&sprite->updateCallback); + 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++ @@ -279,7 +279,7 @@ void DreamGenContext::backobject(Sprite *sprite) { push(ds); ds = data.word(kSetdat); - di = READ_LE_UINT16(&sprite->obj_data); + di = sprite->objData(); ObjData *objData = (ObjData *)ds.ptr(di, 0); if (sprite->delay != 0) { diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index ac304ae2c2..b4d8c7e1c9 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -20,8 +20,12 @@ * */ +#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; @@ -35,7 +39,9 @@ struct Sprite { 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; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 3aebe02a43..2051b5299d 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -892,7 +892,7 @@ void DreamGenContext::eraseoldobs() { Sprite *sprites = spritetable(); for (size_t i=0; i < 16; ++i) { Sprite &sprite = sprites[i]; - if (READ_LE_UINT16(&sprite.obj_data) != 0xffff) { + if (sprite.objData() != 0xffff) { memset(&sprite, 0xff, sizeof(Sprite)); } } @@ -985,7 +985,7 @@ void DreamGenContext::makebackob() { Sprite *sprites = (Sprite *)es.ptr(bx, sizeof(Sprite) * 16); bx += sizeof(Sprite) * (sprite - sprites); // - WRITE_LE_UINT16(&sprite->obj_data, si); + sprite->setObjData(si); if (priority == 255) priority = 0; sprite->priority = priority; -- cgit v1.2.3 From 8b0ac65f68e4fd2829b6c0205f72ef53d7a888b0 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 14:13:34 +0200 Subject: DREAMWEB: Extracted vgagrafx.cpp from stubs.cpp --- engines/dreamweb/module.mk | 3 +- engines/dreamweb/stubs.cpp | 350 +------------------------------------- engines/dreamweb/vgagrafx.cpp | 387 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 390 insertions(+), 350 deletions(-) create mode 100644 engines/dreamweb/vgagrafx.cpp (limited to 'engines') diff --git a/engines/dreamweb/module.mk b/engines/dreamweb/module.mk index 9c8106db90..6c4c506695 100644 --- a/engines/dreamweb/module.mk +++ b/engines/dreamweb/module.mk @@ -7,7 +7,8 @@ MODULE_OBJS := \ dreamgen.o \ print.o \ sprite.o \ - stubs.o + stubs.o \ + vgagrafx.o # This module can be built as a plugin ifeq ($(ENABLE_DREAMWEB), DYNAMIC_PLUGIN) diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 2051b5299d..dfb1a4a8c1 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,133 +183,6 @@ Common::String getFilename(Context &context) { return name; } -uint8 *DreamGenContext::workspace() { - push(es); - es = data.word(kWorkspace); - uint8 *result = es.ptr(0, 0); - es = pop(); - return result; -} - -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() { - 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::seecommandtail() { data.word(kSoundbaseadd) = 0x220; data.byte(kSoundint) = 5; @@ -664,227 +537,6 @@ 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(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(uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { - ds = src; - ah = effectsFlag; - - si = frameNumber * 6; - if (ds.word(si) == 0) { - *width = 0; - *height = 0; - return; - } - -//notblankshow: - if ((effectsFlag & 128) == 0) { - x += ds.byte(si + 4); - y += ds.byte(si + 5); - } -//skipoffsets: - - *width = ds.byte(si + 0); - *height = ds.byte(si + 1); - si = ds.word(si+2) + 2080; - const uint8 *pSrc = ds.ptr(si, *width * *height); - - 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(ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); - cl = width; - ch = height; -} - void DreamGenContext::eraseoldobs() { if (data.byte(kNewobs) == 0) return; diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp new file mode 100644 index 0000000000..25e5a93ebf --- /dev/null +++ b/engines/dreamweb/vgagrafx.cpp @@ -0,0 +1,387 @@ +/* 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() { + push(es); + es = data.word(kWorkspace); + uint8 *result = es.ptr(0, 0); + es = pop(); + return result; +} + +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() { + 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(uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { + ds = src; + ah = effectsFlag; + + si = frameNumber * 6; + if (ds.word(si) == 0) { + *width = 0; + *height = 0; + return; + } + +//notblankshow: + if ((effectsFlag & 128) == 0) { + x += ds.byte(si + 4); + y += ds.byte(si + 5); + } +//skipoffsets: + + *width = ds.byte(si + 0); + *height = ds.byte(si + 1); + si = ds.word(si+2) + 2080; + const uint8 *pSrc = ds.ptr(si, *width * *height); + + 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(ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); + cl = width; + ch = height; +} + +} /*namespace dreamgen */ + -- cgit v1.2.3 From 2d0dfffe00628125da8aa43ebe188377ab9331f7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 14:32:19 +0200 Subject: DREAMWEB: Introduced the Frame struct --- engines/dreamweb/structs.h | 11 +++++++++++ engines/dreamweb/vgagrafx.cpp | 14 +++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index b4d8c7e1c9..0e0215f126 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -73,3 +73,14 @@ 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; +}; + diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 25e5a93ebf..b10ef811b3 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -321,8 +321,8 @@ void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumb ds = src; ah = effectsFlag; - si = frameNumber * 6; - if (ds.word(si) == 0) { + const Frame *frame = (const Frame *)ds.ptr(frameNumber * sizeof(Frame), 6); + if ((frame->width == 0) && (frame->height == 0)) { *width = 0; *height = 0; return; @@ -330,14 +330,14 @@ void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumb //notblankshow: if ((effectsFlag & 128) == 0) { - x += ds.byte(si + 4); - y += ds.byte(si + 5); + x += frame->x; + y += frame->y; } //skipoffsets: - *width = ds.byte(si + 0); - *height = ds.byte(si + 1); - si = ds.word(si+2) + 2080; + *width = frame->width; + *height = frame->height; + si = frame->ptr() + 2080; const uint8 *pSrc = ds.ptr(si, *width * *height); if (effectsFlag) { -- cgit v1.2.3 From b2748740dbf5c9a8d7b648428d005e102ae41d7e Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 15:04:25 +0200 Subject: DREAMWEB: Better API for 'showframe' and no more registers used (expect es:bx for diffdest blitting) --- engines/dreamweb/print.cpp | 3 ++- engines/dreamweb/sprite.cpp | 7 ++++--- engines/dreamweb/structs.h | 4 +++- engines/dreamweb/stubs.h | 4 ++-- engines/dreamweb/vgagrafx.cpp | 12 ++++-------- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 882b4578ce..d29a073960 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -90,7 +90,8 @@ void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 if (data.byte(kForeignrelease) != 0) y -= 3; uint16 tmp = c - 32 + data.word(kCharshift); - showframe(src, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); + ds = src; + showframe(ds.ptr(0, 0), *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 9987224cd7..9b8b060475 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -70,14 +70,15 @@ void DreamGenContext::printasprite(const Sprite *sprite) { else c = 0; uint8 width, height; - showframe(READ_LE_UINT16(&sprite->w6), x, y, sprite->b15, c, &width, &height); + ds = sprite->frameData(); + showframe(ds.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 somethingInDx, uint16 somethingInDi) { +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; @@ -86,7 +87,7 @@ Sprite *DreamGenContext::makesprite(uint8 x, uint8 y, uint16 updateCallback, uin sprite->setUpdateCallback(updateCallback); sprite->x = x; sprite->y = y; - WRITE_LE_UINT16(&sprite->w6, somethingInDx); + sprite->setFrameData(frameData); WRITE_LE_UINT16(&sprite->w8, somethingInDi); sprite->w2 = 0xffff; sprite->b15 = 0; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 0e0215f126..917c83b745 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -28,7 +28,9 @@ struct Sprite { 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; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 0ae76419e9..cb0a87c22e 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -58,7 +58,7 @@ uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); Sprite *spritetable(); void showframe(); - void showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); + void showframe(const void *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); @@ -66,7 +66,7 @@ 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 mainman(Sprite *sprite); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index b10ef811b3..e1622d69af 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -317,11 +317,8 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint } } -void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { - ds = src; - ah = effectsFlag; - - const Frame *frame = (const Frame *)ds.ptr(frameNumber * sizeof(Frame), 6); +void DreamGenContext::showframe(const void *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { + const Frame *frame = ((const Frame *)frameData) + frameNumber; if ((frame->width == 0) && (frame->height == 0)) { *width = 0; *height = 0; @@ -337,8 +334,7 @@ void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumb *width = frame->width; *height = frame->height; - si = frame->ptr() + 2080; - const uint8 *pSrc = ds.ptr(si, *width * *height); + const uint8 *pSrc = ((const uint8 *)frameData) + frame->ptr() + 2080; if (effectsFlag) { if (effectsFlag & 128) { //centred @@ -378,7 +374,7 @@ void DreamGenContext::showframe(uint16 src, uint16 x, uint16 y, uint16 frameNumb void DreamGenContext::showframe() { uint8 width, height; - showframe(ds, di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); + showframe(ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); cl = width; ch = height; } -- cgit v1.2.3 From 1f0eccb296b0177775dd3cba2fc58961b743e819 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 15:12:50 +0200 Subject: DREAMWEB: 'aboutturn' does not need to be generated now --- engines/dreamweb/dreamgen.cpp | 40 ---------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- 2 files changed, 1 insertion(+), 42 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index ed9481fb13..5b0ed0975b 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2258,45 +2258,6 @@ over1001: data.word(kTakeoff) = 320; } -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::checkforexit() { STACK_CHECK; cl = data.byte(kRyanx); @@ -20560,7 +20521,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_checkone: checkone(); break; case addr_findsource: findsource(); break; case addr_mainman: mainman(); break; - case addr_aboutturn: aboutturn(); break; case addr_checkforexit: checkforexit(); break; case addr_adjustdown: adjustdown(); break; case addr_adjustup: adjustup(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 2b7149621b..400e5a6898 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -672,7 +672,6 @@ public: static const uint16 addr_adjustup = 0xc150; static const uint16 addr_adjustdown = 0xc14c; static const uint16 addr_checkforexit = 0xc148; - static const uint16 addr_aboutturn = 0xc13c; static const uint16 addr_mainman = 0xc138; static const uint16 addr_findsource = 0xc130; static const uint16 addr_checkone = 0xc12c; @@ -1470,7 +1469,7 @@ public: void loadold(); void loadtempcharset(); void useslab(); - void aboutturn(); + //void aboutturn(); void usealtar(); void createpanel2(); void turnonpower(); -- cgit v1.2.3 From 95fa7451d63ad674308f1134e954387c967fb9c8 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 15:19:22 +0200 Subject: DREAMWEB: 'findsource' ported to C++ --- engines/dreamweb/dreamgen.cpp | 22 ---------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/sprite.cpp | 14 ++++++++++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 16 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 5b0ed0975b..2157d4e9de 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2237,27 +2237,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::checkforexit() { STACK_CHECK; cl = data.byte(kRyanx); @@ -20519,7 +20498,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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_checkforexit: checkforexit(); break; case addr_adjustdown: adjustdown(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 400e5a6898..ec4199856b 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -673,7 +673,6 @@ public: static const uint16 addr_adjustdown = 0xc14c; static const uint16 addr_checkforexit = 0xc148; 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; @@ -1382,7 +1381,7 @@ public: void fadeupmonfirst(); void drawfloor(); void loadkeypad(); - void findsource(); + //void findsource(); void clearendpal(); void findtext1(); void isryanholding(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 9b8b060475..72c8c1299e 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -538,5 +538,19 @@ void DreamGenContext::facerightway() { 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; + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index cb0a87c22e..0c2f4389e0 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -86,6 +86,7 @@ void lockeddoorway(Sprite *sprite, ObjData *objData); void liftsprite(); void liftsprite(Sprite *sprite, ObjData *objData); + void findsource(); void turnpathonCPP(uint8 param); void turnpathoffCPP(uint8 param); void getroomspaths(); -- cgit v1.2.3 From 92938f810fc4da74ef4872728ccf19833ad12773 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 15:25:28 +0200 Subject: DREAMWEB: 'showreelframe' ported to C++ --- engines/dreamweb/dreamgen.cpp | 19 ------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/sprite.cpp | 10 ++++++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 12 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 2157d4e9de..fd497a3567 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3025,24 +3025,6 @@ void DreamGenContext::getreelstart() { _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); @@ -20525,7 +20507,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index ec4199856b..84f8759381 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -645,7 +645,6 @@ public: 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; @@ -1684,7 +1683,7 @@ public: void playguitar(); void lastfolder(); void transfermap(); - void showreelframe(); + //void showreelframe(); void showmonk(); void diarykeyn(); void set16colpalette(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 72c8c1299e..a438356e1c 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -552,5 +552,15 @@ void DreamGenContext::findsource() { } } +void DreamGenContext::showreelframe() { + uint16 x = es.byte(si+2) + data.word(kMapadx); + uint16 y = es.byte(si+3) + data.word(kMapady); + data.word(kCurrentframe) = es.word(si); + findsource(); + uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); + uint8 width, height; + showframe(ds.ptr(0, 0), x, y, frame, 8, &width, &height); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 0c2f4389e0..6dafdc9e14 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -87,6 +87,7 @@ void liftsprite(); void liftsprite(Sprite *sprite, ObjData *objData); void findsource(); + void showreelframe(); void turnpathonCPP(uint8 param); void turnpathoffCPP(uint8 param); void getroomspaths(); -- cgit v1.2.3 From 031651e996a7e072a49f9c9bb653b3b54f2fc4f4 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 16:01:52 +0200 Subject: DREAMWEB: Introduction of a Reel struct --- engines/dreamweb/sprite.cpp | 11 ++++++++--- engines/dreamweb/structs.h | 9 +++++++++ engines/dreamweb/stubs.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index a438356e1c..3e9914a71f 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -553,9 +553,14 @@ void DreamGenContext::findsource() { } void DreamGenContext::showreelframe() { - uint16 x = es.byte(si+2) + data.word(kMapadx); - uint16 y = es.byte(si+3) + data.word(kMapady); - data.word(kCurrentframe) = es.word(si); + 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(); findsource(); uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); uint8 width, height; diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 917c83b745..2af2788c0c 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -86,3 +86,12 @@ struct Frame { uint8 y; }; +struct Reel { + uint16 _frame; + uint16 frame() const { return READ_LE_UINT16(&_frame); } + void setFrame(uint16 v) { WRITE_LE_UINT16(&_frame, v); } + uint8 x; + uint8 y; + uint8 b4; +}; + diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 6dafdc9e14..ee8fe70109 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -88,6 +88,7 @@ void liftsprite(Sprite *sprite, ObjData *objData); void findsource(); void showreelframe(); + void showreelframe(Reel *reel); void turnpathonCPP(uint8 param); void turnpathoffCPP(uint8 param); void getroomspaths(); -- cgit v1.2.3 From 74a943667fc612639f48d39926bf6e7e8121d4b8 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 19:54:53 +0200 Subject: DREAMWEB: 'getroomdata' ported to C++ --- engines/dreamweb/dreamgen.cpp | 10 ---------- engines/dreamweb/dreamgen.h | 9 ++++----- engines/dreamweb/structs.h | 26 ++++++++++++++++++++++++++ engines/dreamweb/stubs.cpp | 8 ++++++++ engines/dreamweb/stubs.h | 2 ++ 5 files changed, 40 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index fd497a3567..36bede22f7 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -19699,15 +19699,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; @@ -21088,7 +21079,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 84f8759381..e1d7e4c7b8 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -61,7 +61,6 @@ public: 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; @@ -1504,7 +1503,6 @@ public: void showrain(); void openpoolboss(); void buttontwo(); - void fillopen(); //void usetimedtext(); void delsprite(); //void getroomspaths(); @@ -1539,6 +1537,7 @@ public: //void printchar(); void showkeypad(); void obtoinv(); + //void getroomdata(); void removeobfrominv(); void usecoveredbox(); void openyourneighbour(); @@ -1844,13 +1843,13 @@ public: 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(); @@ -2027,7 +2026,7 @@ public: void intro(); void hangonp(); void fadescreendowns(); - void showloadops(); + void openhoteldoor2(); void getridoftempsp(); void scanfornames(); void setallchanges(); diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 2af2788c0c..23f3dcad80 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -95,3 +95,29 @@ struct Reel { uint8 b4; }; +struct Room { + uint8 name[10]; + uint8 b10; + uint8 b11; + uint8 b12; + uint8 b13; + uint8 b14; + uint8 b15; + uint8 b16; + uint8 b17; + uint8 b18; + uint8 b19; + uint8 b20; + uint8 b21; + uint8 b22; + uint8 b23; + uint8 b24; + uint8 b25; + uint8 b26; + uint8 b27; + uint8 b28; + uint8 b29; + uint8 b30; + uint8 b31; +}; + diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index dfb1a4a8c1..947854ac9f 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -647,5 +647,13 @@ void DreamGenContext::makebackob() { sprite->frame = 0; } +void DreamGenContext::getroomdata() { + bx = kRoomdata + sizeof(Room) * al; +} + +void DreamGenContext::getroomdata(uint8 roomIndex) { + getroomdata(roomIndex); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ee8fe70109..bf49b2edf2 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -56,6 +56,8 @@ uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16 *offset); void kernchars(); uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); + void getroomdata(); + void getroomdata(uint8 roomIndex); Sprite *spritetable(); void showframe(); void showframe(const void *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); -- cgit v1.2.3 From 0cbc291cbd0266a6522568dea9950ee35c234c55 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 21:46:59 +0200 Subject: DREAMWEB: 'startloading' ported to C++ --- engines/dreamweb/dreamgen.cpp | 137 ------------------------------------------ engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/structs.h | 14 ++--- engines/dreamweb/stubs.cpp | 132 ++++++++++++++++++++++++++++++++++++++++ engines/dreamweb/stubs.h | 2 + 5 files changed, 142 insertions(+), 146 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 36bede22f7..9436480b53 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -19494,142 +19494,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); @@ -21075,7 +20939,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index e1d7e4c7b8..83e0a3f005 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -64,7 +64,6 @@ public: 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; @@ -1480,7 +1479,7 @@ public: void endgame(); void monprint(); void usepipe(); - void startloading(); + //void startloading(); void getunderzoom(); void candles(); void backobject(); diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 23f3dcad80..a54c42d79d 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -100,19 +100,19 @@ struct Room { uint8 b10; uint8 b11; uint8 b12; - uint8 b13; + uint8 roomsSample; uint8 b14; - uint8 b15; - uint8 b16; + uint8 mapX; + uint8 mapY; uint8 b17; uint8 b18; uint8 b19; - uint8 b20; + uint8 liftFlag; uint8 b21; uint8 b22; - uint8 b23; - uint8 b24; - uint8 b25; + uint8 countToOpen; + uint8 liftPath; + uint8 doorPath; uint8 b26; uint8 b27; uint8 b28; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 947854ac9f..e16795c6db 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -655,5 +655,137 @@ void DreamGenContext::getroomdata(uint8 roomIndex) { getroomdata(roomIndex); } +void DreamGenContext::startloading() { + const Room *room = (Room *)cs.ptr(bx, sizeof(Room)); + startloading(room); +} + +void DreamGenContext::startloading(const Room *room) { + data.byte(kCombatcount) = 0; + data.byte(kRoomssample) = room->roomsSample; + data.byte(kMapx) = room->mapX; + data.byte(kMapy) = room->mapY; + data.byte(kLiftflag) = room->liftFlag; + data.byte(kManspath) = room->b21; + data.byte(kDestination) = room->b21; + data.byte(kFinaldest) = room->b21; + data.byte(kFacing) = room->b22; + data.byte(kTurntoface) = room->b22; + data.byte(kCounttoopen) = room->countToOpen; + data.byte(kLiftpath) = room->liftPath; + data.byte(kDoorpath) = room->doorPath; + data.byte(kLastweapon) = -1; + al = room->b27; + push(ax); + al = room->b31; + ah = data.byte(kReallocation); + data.byte(kReallocation) = al; + dx = bx; + Common::String name = getFilename(*this); + engine->openFile(name); + cs.word(kHandle) = 1; //only one handle + flags._c = false; + readheader(); + allocateload(); + ds = ax; + data.word(kBackdrop) = ax; + dx = (0); + loadseg(); + ds = data.word(kWorkspace); + dx = (0); + cx = 132*66; + al = 0; + fillspace(); + loadseg(); + sortoutmap(); + allocateload(); + data.word(kSetframes) = ax; + ds = ax; + dx = (0); + loadseg(); + ds = data.word(kSetdat); + dx = 0; + cx = (64*128); + al = 255; + fillspace(); + loadseg(); + allocateload(); + data.word(kReel1) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kReel2) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kReel3) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kReels) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kPeople) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kSetdesc) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kBlockdesc) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kRoomdesc) = ax; + ds = ax; + dx = 0; + loadseg(); + allocateload(); + data.word(kFreeframes) = ax; + ds = ax; + dx = 0; + loadseg(); + ds = data.word(kFreedat); + dx = 0; + cx = (16*80); + al = 255; + fillspace(); + loadseg(); + allocateload(); + data.word(kFreedesc) = ax; + ds = ax; + dx = (0); + loadseg(); + closefile(); + findroominloc(); + deletetaken(); + setallchanges(); + autoappear(); + al = data.byte(kNewlocation); + getroomdata(); + data.byte(kLastweapon) = -1; + data.byte(kMandead) = 0; + data.word(kLookcounter) = 160; + data.byte(kNewlocation) = 255; + data.byte(kLinepointer) = 254; + ax = pop(); + if (al != 255) { + data.byte(kManspath) = al; + push(bx); + autosetwalk(); + bx = pop(); + } + findxyfrompath(); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index bf49b2edf2..29b73acb47 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -58,6 +58,8 @@ uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); void getroomdata(); void getroomdata(uint8 roomIndex); + void startloading(); + void startloading(const Room *room); Sprite *spritetable(); void showframe(); void showframe(const void *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height); -- cgit v1.2.3 From a607b78ec0fda1bb029dc9e215b397eadc408eca Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 21:56:33 +0200 Subject: DREAMWEB: 'readheader' ported to C++ --- engines/dreamweb/dreamgen.cpp | 11 ----------- engines/dreamweb/dreamgen.h | 7 +++---- engines/dreamweb/stubs.cpp | 6 ++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 10 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 9436480b53..43a1ee3ee8 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -19563,16 +19563,6 @@ lookx: data.byte(kRoomnum) = cl; } -void DreamGenContext::readheader() { - STACK_CHECK; - ds = cs; - dx = 6091; - cx = (6187-6091); - readfromfile(); - es = cs; - di = 6141; -} - void DreamGenContext::allocateload() { STACK_CHECK; push(es); @@ -20942,7 +20932,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_disablepath: disablepath(); break; case addr_findxyfrompath: findxyfrompath(); break; case addr_findroominloc: findroominloc(); break; - case addr_readheader: readheader(); break; case addr_dontloadseg: dontloadseg(); break; case addr_allocateload: allocateload(); break; case addr_fillspace: fillspace(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 83e0a3f005..75ca47e460 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -60,7 +60,6 @@ public: 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_findroominloc = 0xcb58; static const uint16 addr_findxyfrompath = 0xcb54; static const uint16 addr_disablepath = 0xcb50; @@ -1314,7 +1313,7 @@ public: void bothchannels(); void usewire(); void getnamepos(); - void drawitall(); + void loadtemptext(); void clearstartpal(); void femalefan(); void showgamereel(); @@ -1702,7 +1701,7 @@ public: void getridofpit(); void convnum(); void nothelderror(); - void readheader(); + //void readheader(); void getsetad(); void getyad(); void reconstruct(); @@ -1804,7 +1803,7 @@ public: void printmessage(); void reexfromopen(); void fillryan(); - void loadtemptext(); + void drawitall(); void usestereo(); void showcurrentfile(); void copyname(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index e16795c6db..2b330c831f 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -660,6 +660,12 @@ void DreamGenContext::startloading() { startloading(room); } +void DreamGenContext::readheader() { + ax = engine->readFromFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen); + es = cs; + di = kFiledata; +} + void DreamGenContext::startloading(const Room *room) { data.byte(kCombatcount) = 0; data.byte(kRoomssample) = room->roomsSample; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 29b73acb47..fc3b7c9127 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -58,6 +58,7 @@ uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); void getroomdata(); void getroomdata(uint8 roomIndex); + void readheader(); void startloading(); void startloading(const Room *room); Sprite *spritetable(); -- cgit v1.2.3 From fa232d93b1e7530ba07067533412cc5e84b7c41e Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 22:03:28 +0200 Subject: DREAMWEB: 'allocatemem' has a nicer API --- engines/dreamweb/stubs.cpp | 11 ++++++++--- engines/dreamweb/stubs.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 2b330c831f..8c3086aebb 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -338,12 +338,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() { diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index fc3b7c9127..35f54b6c6e 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + uint16 allocatemem(uint16 paragraphs); uint8 *workspace(); void multidump(); void multidump(uint16 x, uint16 y, uint8 width, uint8 height); -- cgit v1.2.3 From a4f05b36e4a866bf686ba1810f6aea8b584a9f7c Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 22:56:29 +0200 Subject: DREAMWEB: 'fillspace' ported to C++ --- engines/dreamweb/dreamgen.cpp | 18 ------------------ engines/dreamweb/dreamgen.h | 7 +++---- engines/dreamweb/stubs.cpp | 4 ++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 8 insertions(+), 22 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 43a1ee3ee8..15a48df484 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -19575,23 +19575,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); @@ -20934,7 +20917,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_findroominloc: findroominloc(); 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 75ca47e460..9f987893fe 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -57,7 +57,6 @@ 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_findroominloc = 0xcb58; @@ -1373,6 +1372,7 @@ public: //void worktoscreen(); void getexpos(); void fadedos(); + //void fillspace(); //void multiget(); void fadeupmonfirst(); void drawfloor(); @@ -1661,7 +1661,7 @@ public: void steady(); void pixelcheckset(); void reexfrominv(); - void fillspace(); + void examinventory(); void talk(); void usedryer(); void dumpeverything(); @@ -1873,7 +1873,6 @@ public: void turnanypathon(); void restorereels(); void setwalk(); - //void printboth(); void useroutine(); void zoomicon(); void hotelcontrol(); @@ -2029,7 +2028,7 @@ public: void scanfornames(); void setallchanges(); void newgame(); - void examinventory(); + //void printboth(); void standardload(); void undertextline(); void findroominloc(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 8c3086aebb..5ef8b18317 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -798,5 +798,9 @@ void DreamGenContext::startloading(const Room *room) { findxyfrompath(); } +void DreamGenContext::fillspace() { + memset(ds.ptr(dx, cx), al, cx); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 35f54b6c6e..c218707d9b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -60,6 +60,7 @@ void getroomdata(); void getroomdata(uint8 roomIndex); void readheader(); + void fillspace(); void startloading(); void startloading(const Room *room); Sprite *spritetable(); -- cgit v1.2.3 From 5d13e2f837f897e46a8a574c9a3b3c992151b9c2 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 23:11:48 +0200 Subject: DREAMWEB: Ported 'clearwork' --- engines/dreamweb/dreamgen.cpp | 13 ------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.h | 1 + engines/dreamweb/vgagrafx.cpp | 4 ++++ 4 files changed, 6 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 15a48df484..41a249942c 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3267,18 +3267,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); @@ -20347,7 +20335,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 9f987893fe..e2caf43107 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -628,7 +628,6 @@ public: 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; @@ -1367,7 +1366,7 @@ public: void turnanypathoff(); void openfilefromc(); void gettime(); - void clearwork(); + //void clearwork(); void loadtraveltext(); //void worktoscreen(); void getexpos(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index c218707d9b..01dcbde349 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -21,6 +21,7 @@ */ uint16 allocatemem(uint16 paragraphs); uint8 *workspace(); + 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); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index e1622d69af..b0bfd12a8f 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -379,5 +379,9 @@ void DreamGenContext::showframe() { ch = height; } +void DreamGenContext::clearwork() { + memset(workspace(), 0, 320*200); +} + } /*namespace dreamgen */ -- cgit v1.2.3 From 7c40d798de8f650f6178ea94c62042a850c1d604 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 23:21:43 +0200 Subject: DREAMWEB: 'dealwithspecial' ported to C++ --- engines/dreamweb/dreamgen.cpp | 59 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 31 +++++++++++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 4 files changed, 34 insertions(+), 61 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 41a249942c..f448fb2d84 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2923,64 +2923,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); @@ -20320,7 +20262,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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_deleverything: deleverything(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index e2caf43107..fc141fa5d3 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -642,7 +642,6 @@ public: static const uint16 addr_deleverything = 0xc1c0; 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; @@ -1449,7 +1448,7 @@ public: void printcurs(); //void convertkey(); void outofopen(); - void dealwithspecial(); + //void dealwithspecial(); //void eraseoldobs(); void dircom(); //void liftsprite(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 5ef8b18317..a9e0ef5929 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -802,5 +802,36 @@ void DreamGenContext::fillspace() { memset(ds.ptr(dx, cx), al, cx); } +void DreamGenContext::dealwithspecial() { + uint8 type = al - 220; + if (type == 0) { + al = ah; + placesetobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 1) { + al = ah; + removesetobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 2) { + al = ah; + placefreeobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 3) { + al = ah; + removefreeobject(); + data.byte(kHavedoneobs) = 1; + } else if (type == 4) { + switchryanoff(); + } else if (type == 5) { + data.byte(kTurntoface) = ah; + data.byte(kFacing) = ah; + switchryanon(); + } else if (type == 6) { + data.byte(kNewlocation) = ah; + } else { + movemap(); + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 01dcbde349..4d35a597c4 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -106,3 +106,5 @@ void lockmon(); void cancelch0(); void cancelch1(); + void dealwithspecial(); + -- cgit v1.2.3 From 52fef5a59949e915d1785c094dda64e2db5edea2 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Sat, 30 Jul 2011 23:37:18 +0200 Subject: DREAMWEB: 'plotreel' ported to C++ --- engines/dreamweb/dreamgen.cpp | 43 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 34 ++++++++++++++++++++++++++++++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 36 insertions(+), 45 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index f448fb2d84..12126fce78 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2816,48 +2816,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); @@ -20259,7 +20217,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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_movemap: movemap(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index fc141fa5d3..264fece0b0 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -644,7 +644,6 @@ public: static const uint16 addr_movemap = 0xc1b4; 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; @@ -1857,7 +1856,7 @@ public: void opentvdoor(); void triggermessage(); void finalframe(); - void plotreel(); + //void plotreel(); void swapwithopen(); //void makesprite(); void dreamweb(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index a9e0ef5929..0dcaa9e72b 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -833,5 +833,39 @@ void DreamGenContext::dealwithspecial() { } } +void DreamGenContext::plotreel() { + getreelstart(); + while (true) { + push(es); + push(si); + ax = es.word(si+2); + if (al < 220) + break; + if (al == 255) + break; + dealwithspecial(); + _inc(data.word(kReelpointer)); + si = pop(); + es = pop(); + _add(si, 40); + } + + for (size_t i = 0; i < 8; ++i) { + push(cx); + push(es); + push(si); + ax = es.word(si); + if (ax != 0xffff) + showreelframe(); + si = pop(); + es = pop(); + cx = pop(); + _add(si, 5); + } + soundonreels(); + bx = pop(); + es = pop(); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 4d35a597c4..a8bcd019c5 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -106,5 +106,6 @@ void lockmon(); void cancelch0(); void cancelch1(); + void plotreel(); void dealwithspecial(); -- cgit v1.2.3 From 7fd8895de62ad0421d8038cdb0618b493aecec1c Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 12:21:46 +0200 Subject: DREAMWEB: 'allocatework' ported to C++ --- engines/dreamweb/dreamgen.cpp | 8 -------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.h | 1 + engines/dreamweb/vgagrafx.cpp | 4 ++++ 4 files changed, 6 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 12126fce78..a43816153e 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2999,13 +2999,6 @@ dumpevery2: goto dumpevery2; } -void DreamGenContext::allocatework() { - STACK_CHECK; - bx = 0x1000; - allocatemem(); - data.word(kWorkspace) = ax; -} - void DreamGenContext::loadpalfromiff() { STACK_CHECK; dx = 2481; @@ -20223,7 +20216,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_getreelstart: getreelstart(); 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 264fece0b0..026ba1c3aa 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -637,7 +637,6 @@ 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_getreelstart = 0xc1b8; @@ -1819,7 +1818,7 @@ public: void afterintroroom(); void blockget(); void usetrainer(); - void allocatework(); + //void allocatework(); void addtopresslist(); void walkandexamine(); void dmaend(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index a8bcd019c5..ddcde72da6 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -21,6 +21,7 @@ */ uint16 allocatemem(uint16 paragraphs); uint8 *workspace(); + void allocatework(); void clearwork(); void multidump(); void multidump(uint16 x, uint16 y, uint8 width, uint8 height); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index b0bfd12a8f..e61532fdb9 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -34,6 +34,10 @@ uint8 *DreamGenContext::workspace() { return result; } +void DreamGenContext::allocatework() { + data.word(kWorkspace) = allocatemem(0x1000); +} + void DreamGenContext::multiget() { multiget(di, bx, cl, ch); } -- cgit v1.2.3 From 4e39a41e6218c7206e706734eb608e9706e2678a Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 12:24:06 +0200 Subject: DREAWMEB: Ported 'zoom' to C++ --- engines/dreamweb/dreamgen.cpp | 51 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.h | 1 + engines/dreamweb/vgagrafx.cpp | 28 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 53 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index a43816153e..99ad3b36a9 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3160,56 +3160,6 @@ void DreamGenContext::createpanel2() { showframe(); } -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); @@ -20227,7 +20177,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_createpanel2: createpanel2(); 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 026ba1c3aa..3e6a720a15 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -625,7 +625,6 @@ public: 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_createpanel2 = 0xc200; @@ -1662,7 +1661,7 @@ public: void usedryer(); void dumpeverything(); void usehatch(); - void zoom(); + //void zoom(); void outofinv(); void viewfolder(); //void walking(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ddcde72da6..0f2202d28b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -109,4 +109,5 @@ void cancelch1(); void plotreel(); void dealwithspecial(); + void zoom(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index e61532fdb9..5acd2ec01f 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -387,5 +387,33 @@ void DreamGenContext::clearwork() { memset(workspace(), 0, 320*200); } +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 */ -- cgit v1.2.3 From c6049ac0c49c83d6367c77c23aafec0369d0e335 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 13:54:03 +0200 Subject: DREAMWEB: 'crosshair' ported to C++ --- engines/dreamweb/dreamgen.cpp | 27 --------------------------- engines/dreamweb/dreamgen.h | 7 +++---- engines/dreamweb/stubs.cpp | 15 +++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 4 files changed, 20 insertions(+), 31 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 99ad3b36a9..e619dcae13 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -18632,32 +18632,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(); @@ -20706,7 +20680,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 3e6a720a15..3642627763 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -93,7 +93,6 @@ public: 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; @@ -1343,7 +1342,7 @@ public: void getreelstart(); void buttonenter(); void checkinput(); - void crosshair(); + //void crosshair(); void bresenhams(); void getbackfromops(); //void frameoutv(); @@ -1458,6 +1457,7 @@ public: void fadescreenup(); void loadold(); void loadtempcharset(); + void showbyte(); void useslab(); //void aboutturn(); void usealtar(); @@ -1563,7 +1563,7 @@ public: void wearwatch(); void runintroseq(); void doblocks(); - void showbyte(); + void opensarters(); void allpalette(); void findormake(); void nextsymbol(); @@ -1933,7 +1933,6 @@ public: //void dodoor(); void greyscalesum(); void buttoneight(); - void opensarters(); void findexobject(); void errormessage2(); void usechurchhole(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 0dcaa9e72b..c1cef6c79b 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -867,5 +867,20 @@ void DreamGenContext::plotreel() { es = pop(); } +void DreamGenContext::crosshair() { + uint8 frame; + if ((data.byte(kCommandtype) != 3) && (data.byte(kCommandtype) < 10)) { + frame = 9; + } else { + frame = 29; + } + push(ds); + ds = data.word(kIcons1); + uint8 *src = ds.ptr(0, 0); + ds = pop(); + uint8 width, height; + showframe(src, kZoomx + 24, kZoomy + 19, frame, 0, &width, &height); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 0f2202d28b..466a486e7b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -110,4 +110,6 @@ void plotreel(); void dealwithspecial(); void zoom(); + void crosshair(); + -- cgit v1.2.3 From f7752243196e83b9191735634a764c26f24d7427 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 14:16:09 +0200 Subject: DREAMWEB: Ported 'showrain' to C++ --- engines/dreamweb/dreamgen.cpp | 88 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/sprite.cpp | 44 ++++++++++++++++++++++ engines/dreamweb/structs.h | 11 ++++++ engines/dreamweb/stubs.h | 1 + 5 files changed, 57 insertions(+), 90 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index e619dcae13..f25bff3995 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2596,93 +2596,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::liftnoise() { STACK_CHECK; _cmp(data.byte(kReallocation), 5); @@ -20123,7 +20036,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 3642627763..1995858a03 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -651,7 +651,6 @@ public: 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; @@ -1493,7 +1492,7 @@ public: void disablesoundint(); void checkifset(); void showallex(); - void showrain(); + //void showrain(); void openpoolboss(); void buttontwo(); //void usetimedtext(); diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 3e9914a71f..42c1b70d3a 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -567,5 +567,49 @@ void DreamGenContext::showreelframe(Reel *reel) { showframe(ds.ptr(0, 0), x, y, frame, 8, &width, &height); } +void DreamGenContext::showrain() { + ds = data.word(kMainsprites); + si = 6*58; + ax = ds.word(si+2); + si = ax + 2080; + es = data.word(kBuffers); + Rain *rain = (Rain *)es.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; + } + } +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index a54c42d79d..a567384c00 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -121,3 +121,14 @@ struct Room { 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.h b/engines/dreamweb/stubs.h index 466a486e7b..635d6c733a 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -111,5 +111,6 @@ void dealwithspecial(); void zoom(); void crosshair(); + void showrain(); -- cgit v1.2.3 From c04a250c936b7de73215cd99e0476992cb3216d7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 15:58:18 +0200 Subject: DREAMWEB: 'findsource' has a new C++ flavour --- engines/dreamweb/sprite.cpp | 12 ++++++++++-- engines/dreamweb/stubs.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 42c1b70d3a..00cbd2c4dc 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -552,6 +552,14 @@ void DreamGenContext::findsource() { } } +void *DreamGenContext::findsourceCPP() { + push(ds); + findsource(); + void *result = ds.ptr(0, 0); + ds = pop(); + return result; +} + void DreamGenContext::showreelframe() { Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); showreelframe(reel); @@ -561,10 +569,10 @@ void DreamGenContext::showreelframe(Reel *reel) { uint16 x = reel->x + data.word(kMapadx); uint16 y = reel->y + data.word(kMapady); data.word(kCurrentframe) = reel->frame(); - findsource(); + void *source = findsourceCPP(); uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); uint8 width, height; - showframe(ds.ptr(0, 0), x, y, frame, 8, &width, &height); + showframe(source, x, y, frame, 8, &width, &height); } void DreamGenContext::showrain() { diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 635d6c733a..c2b1172eef 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -96,6 +96,7 @@ void liftsprite(); void liftsprite(Sprite *sprite, ObjData *objData); void findsource(); + void *findsourceCPP(); void showreelframe(); void showreelframe(Reel *reel); void turnpathonCPP(uint8 param); -- cgit v1.2.3 From 095689ab49ae9aa93b3e675576a2ab16afbd9bb1 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 16:14:39 +0200 Subject: DREAMWEB: Some sound mixing was not needed anymore --- engines/dreamweb/dreamgen.cpp | 279 ------------------------------------------ engines/dreamweb/dreamgen.h | 15 +-- 2 files changed, 5 insertions(+), 289 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index f25bff3995..f61bd282c6 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -15445,46 +15445,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); @@ -15506,162 +15466,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); @@ -16084,84 +15888,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; @@ -20485,16 +20211,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; @@ -20517,7 +20239,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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 1995858a03..92fee38f27 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -168,7 +168,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; @@ -190,16 +189,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; @@ -1480,7 +1475,7 @@ public: void reminders(); void selectslot2(); void runtap(); - void domix(); + //void domix(); void priesttext(); void paneltomap(); void obname(); @@ -1584,7 +1579,7 @@ public: void nextcolon(); void placefreeobject(); void delpointer(); - void loopchannel0(); + //void loopchannel0(); void initrain(); void showleftpage(); void rockstar(); @@ -1924,7 +1919,7 @@ public: void quitkey(); void openfile(); void usecharset1(); - void makenextblock(); + //void makenextblock(); void showpuztext(); void addalong(); //void width160(); @@ -1980,9 +1975,9 @@ public: void redrawmainscrn(); void finishedwalking(); void findallryan(); - void channel0tran(); + //void channel0tran(); void buttonpress(); - void parseblaster(); + //void parseblaster(); void callhotellift(); void makemainscreen(); void intromonks2(); -- cgit v1.2.3 From 2b03076149535d29c83b5ab5f165456a6238e57c Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 16:19:27 +0200 Subject: DREAMWEB: 'deltextline' ported to C++ --- engines/dreamweb/dreamgen.cpp | 17 ----------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 10 ++++++++++ engines/dreamweb/stubs.h | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index f61bd282c6..410abff178 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -18443,22 +18443,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); @@ -20317,7 +20301,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 92fee38f27..4abcd87719 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -88,7 +88,6 @@ 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; @@ -1398,7 +1397,7 @@ public: void useelevator2(); void buttonone(); void keyboardread(); - void deltextline(); + //void deltextline(); void entercode(); void getopenedsize(); void getpersframe(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index c1cef6c79b..be75abaf0d 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -882,5 +882,15 @@ void DreamGenContext::crosshair() { showframe(src, kZoomx + 24, kZoomy + 19, frame, 0, &width, &height); } +void DreamGenContext::deltextline() { + uint16 x = data.word(kTextaddressx); + uint16 y = data.word(kTextaddressy); + if (data.byte(kForeignrelease) != 0) + y -= 3; + ds = data.word(kBuffers); + si = kTextunder; + multiput(x, y, kUndertextsizex, kUndertextsizey); +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index c2b1172eef..61761a4c8c 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -113,5 +113,5 @@ void zoom(); void crosshair(); void showrain(); - + void deltextline(); -- cgit v1.2.3 From 135efa50a1f96632dae985b593888eb706006d75 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 16:44:29 +0200 Subject: DREAMWEB: Less register interaction in 'multiput' and 'multiget' --- engines/dreamweb/stubs.cpp | 6 +++--- engines/dreamweb/stubs.h | 4 ++-- engines/dreamweb/vgagrafx.cpp | 29 +++++++++++++---------------- 3 files changed, 18 insertions(+), 21 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index be75abaf0d..12e3905657 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -291,7 +291,7 @@ void DreamGenContext::getundertimed() { 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() { @@ -300,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() { @@ -889,7 +889,7 @@ void DreamGenContext::deltextline() { y -= 3; ds = data.word(kBuffers); si = kTextunder; - multiput(x, y, kUndertextsizex, kUndertextsizey); + multiput(ds.ptr(si, 0), x, y, kUndertextsizex, kUndertextsizey); } } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 61761a4c8c..d7f71aed5f 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -31,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(); @@ -70,7 +70,7 @@ void showframe(const void *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(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 5acd2ec01f..a4f8d83117 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -39,13 +39,14 @@ void DreamGenContext::allocatework() { } void DreamGenContext::multiget() { - multiget(di, bx, cl, ch); + multiget(ds.ptr(si, 0), di, bx, cl, ch); + si += cl * ch; + di += bx * kScreenwidth + kScreenwidth * ch; + cx = 0; } -void DreamGenContext::multiget(uint16 x, uint16 y, uint8 w, uint8 h) { +void DreamGenContext::multiget(uint8 *dst, 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; @@ -53,21 +54,20 @@ void DreamGenContext::multiget(uint16 x, uint16 y, uint8 w, uint8 h) { 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); + const uint8 *src_p = ds.ptr(src + kScreenwidth * l, w); + uint8 *dst_p = dst + w * l; memcpy(dst_p, src_p, w); } - si += w * h; - di = src + kScreenwidth * h; - cx = 0; } void DreamGenContext::multiput() { - multiput(di, bx, cl, ch); + multiput(ds.ptr(si, 0), di, bx, cl, ch); + si += cl * ch; + di += bx * kScreenwidth + kScreenwidth * ch; + cx = 0; } -void DreamGenContext::multiput(uint16 x, uint16 y, uint8 w, uint8 h) { - unsigned src = (uint16)si; +void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) { unsigned dst = x + y * kScreenwidth; es = data.word(kWorkspace); if (y + h > 200) @@ -76,13 +76,10 @@ void DreamGenContext::multiput(uint16 x, uint16 y, uint8 w, uint8 h) { 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); + const uint8 *src_p = src + w * l; 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) { -- cgit v1.2.3 From 8ee7ed10664c9c4c6ed944acf489e973be37b327 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 18:11:19 +0200 Subject: DREAMWEB: Less register usage in 'plotreel' --- engines/dreamweb/structs.h | 7 ++++--- engines/dreamweb/stubs.cpp | 24 +++++++----------------- 2 files changed, 11 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index a567384c00..48b3f914d0 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -87,9 +87,10 @@ struct Frame { }; struct Reel { - uint16 _frame; - uint16 frame() const { return READ_LE_UINT16(&_frame); } - void setFrame(uint16 v) { WRITE_LE_UINT16(&_frame, v); } + 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; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 12e3905657..c95091a464 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -835,36 +835,26 @@ void DreamGenContext::dealwithspecial() { void DreamGenContext::plotreel() { getreelstart(); + Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); while (true) { - push(es); - push(si); - ax = es.word(si+2); + al = reel->x; + ah = reel->y; if (al < 220) break; if (al == 255) break; dealwithspecial(); _inc(data.word(kReelpointer)); - si = pop(); - es = pop(); - _add(si, 40); + reel += 8; } for (size_t i = 0; i < 8; ++i) { - push(cx); - push(es); - push(si); - ax = es.word(si); + ax = reel->frame(); if (ax != 0xffff) - showreelframe(); - si = pop(); - es = pop(); - cx = pop(); - _add(si, 5); + showreelframe(reel); + ++reel; } soundonreels(); - bx = pop(); - es = pop(); } void DreamGenContext::crosshair() { -- cgit v1.2.3 From 3427d07de07032b203f7aa02486b8073a65bca26 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 3 Aug 2011 18:48:43 +0200 Subject: DREAMWEB: 'doblocks' ported to C++ --- engines/dreamweb/dreamgen.cpp | 78 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +- engines/dreamweb/stubs.h | 1 + engines/dreamweb/vgagrafx.cpp | 42 +++++++++++++++++++++++ 4 files changed, 44 insertions(+), 80 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 410abff178..83951bd19c 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -3117,83 +3117,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); @@ -19774,7 +19697,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_vsync: vsync(); break; case addr_doshake: doshake(); 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 4abcd87719..9c89fead42 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -616,7 +616,6 @@ 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_doshake = 0xc20c; static const uint16 addr_vsync = 0xc208; @@ -1555,7 +1554,7 @@ public: void locklightoff(); void wearwatch(); void runintroseq(); - void doblocks(); + //void doblocks(); void opensarters(); void allpalette(); void findormake(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index d7f71aed5f..5ba83c3014 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -114,4 +114,5 @@ void crosshair(); void showrain(); void deltextline(); + void doblocks(); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index a4f8d83117..ca86fc44b0 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -384,6 +384,48 @@ 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; -- cgit v1.2.3 From a3c8c1334ba5c948912e35ca8bdc30d479190df0 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 4 Aug 2011 11:03:08 +0200 Subject: DREAMWEB: Helper function to acquire a temporary segment ref to avoid ds and es pollution --- engines/dreamweb/runtime.h | 6 ++++++ engines/dreamweb/sprite.cpp | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h index 714a8d5850..ba16f03d1c 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 index 00cbd2c4dc..8cf0da1de7 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -580,8 +580,7 @@ void DreamGenContext::showrain() { si = 6*58; ax = ds.word(si+2); si = ax + 2080; - es = data.word(kBuffers); - Rain *rain = (Rain *)es.ptr(kRainlist, 0); + Rain *rain = (Rain *)segRef(data.word(kBuffers)).ptr(kRainlist, 0); if (rain->x == 255) return; while (true) { -- cgit v1.2.3 From 5bf9c42c4551e702741ed36427168ad52dd57816 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 4 Aug 2011 11:07:02 +0200 Subject: DREAMWEB: Deprecated functions suppressed --- engines/dreamweb/sprite.cpp | 12 ------------ engines/dreamweb/stubs.h | 2 -- 2 files changed, 14 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 8cf0da1de7..7701983df2 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -405,12 +405,6 @@ void DreamGenContext::steady(Sprite *sprite, ObjData *objData) { sprite->b15 = b18; } -void DreamGenContext::lockeddoorway() { - Sprite *sprite = (Sprite *)es.ptr(bx, sizeof(Sprite)); - ObjData *objData = (ObjData *)ds.ptr(di, 0); - lockeddoorway(sprite, objData); -} - void DreamGenContext::lockeddoorway(Sprite *sprite, ObjData *objData) { if (data.byte(kRyanx) < sprite->x) { if (sprite->x - data.byte(kRyanx) > 24) @@ -475,12 +469,6 @@ shutdoor2: } } -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 diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 5ba83c3014..7e92ed847e 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -91,9 +91,7 @@ void dodoor(Sprite *sprite, ObjData *objData); void doorway(Sprite *sprite, ObjData *objData); void widedoor(Sprite *sprite, ObjData *objData); - void lockeddoorway(); void lockeddoorway(Sprite *sprite, ObjData *objData); - void liftsprite(); void liftsprite(Sprite *sprite, ObjData *objData); void findsource(); void *findsourceCPP(); -- cgit v1.2.3 From baa109f0582ff3f602d9a856adc01b6e3ea3c693 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 4 Aug 2011 11:13:59 +0200 Subject: DREAMWEB: Less register usage in misc. places --- engines/dreamweb/sprite.cpp | 17 +++-------------- engines/dreamweb/vgagrafx.cpp | 5 +---- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 7701983df2..9941fb2c2d 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -27,10 +27,7 @@ namespace DreamGen { Sprite *DreamGenContext::spritetable() { - push(es); - es = data.word(kBuffers); - Sprite *sprite = (Sprite *)es.ptr(kSpritetable, 16 * sizeof(Sprite)); - es = pop(); + Sprite *sprite = (Sprite *)segRef(data.word(kBuffers)).ptr(kSpritetable, 16 * sizeof(Sprite)); return sprite; } @@ -70,8 +67,7 @@ void DreamGenContext::printasprite(const Sprite *sprite) { else c = 0; uint8 width, height; - ds = sprite->frameData(); - showframe(ds.ptr(0, 0), x, y, sprite->b15, c, &width, &height); + showframe(segRef(sprite->frameData()).ptr(0, 0), x, y, sprite->b15, c, &width, &height); } void DreamGenContext::clearsprites() { @@ -277,15 +273,10 @@ void DreamGenContext::backobject() { } void DreamGenContext::backobject(Sprite *sprite) { - push(ds); - - ds = data.word(kSetdat); - di = sprite->objData(); - ObjData *objData = (ObjData *)ds.ptr(di, 0); + ObjData *objData = (ObjData *)segRef(data.word(kSetdat)).ptr(sprite->objData(), 0); if (sprite->delay != 0) { --sprite->delay; - ds = pop(); return; } @@ -304,8 +295,6 @@ void DreamGenContext::backobject(Sprite *sprite) { constant(sprite, objData); else steady(sprite, objData); - - ds = pop(); } void DreamGenContext::constant(Sprite *sprite, ObjData *objData) { diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index ca86fc44b0..ed195aa551 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -27,10 +27,7 @@ namespace DreamGen { uint8 *DreamGenContext::workspace() { - push(es); - es = data.word(kWorkspace); - uint8 *result = es.ptr(0, 0); - es = pop(); + uint8 *result = segRef(data.word(kWorkspace)).ptr(0, 0); return result; } -- cgit v1.2.3 From 3407f2803aec89fcf091900b841f83683fcc8675 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Mon, 8 Aug 2011 22:26:31 +0200 Subject: DREAMWEB: 'autosetwalk' ported to C++ --- engines/dreamweb/dreamgen.cpp | 54 ------------------------------------------- engines/dreamweb/dreamgen.h | 7 +++--- engines/dreamweb/stubs.cpp | 20 ++++++++++++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 24 insertions(+), 58 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 83951bd19c..291078169f 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -17359,59 +17359,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); @@ -20190,7 +20137,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 9c89fead42..18be264a9e 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -120,7 +120,6 @@ public: 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; @@ -1360,6 +1359,7 @@ public: void fadedos(); //void fillspace(); //void multiget(); + //void autosetwalk(); void fadeupmonfirst(); void drawfloor(); void loadkeypad(); @@ -1385,7 +1385,7 @@ public: void additionaltext(); //void kernchars(); void othersmoker(); - void autosetwalk(); + void dofade(); void setuptimedtemp(); void blocknametext(); void useelevator5(); @@ -1431,7 +1431,6 @@ public: void addtopeoplelist(); void hangoncurs(); void sparkydrip(); - //void modifychar(); void compare(); void printcurs(); //void convertkey(); @@ -1759,7 +1758,7 @@ public: void readfromfile(); void initialinv(); void showslots(); - void dofade(); + //void modifychar(); void hangon(); void settopright(); void findsetobject(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index c95091a464..6d2fee1ecd 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -882,5 +882,25 @@ void DreamGenContext::deltextline() { multiput(ds.ptr(si, 0), x, y, kUndertextsizex, kUndertextsizey); } +void DreamGenContext::autosetwalk() { + al = data.byte(kManspath); + if (data.byte(kFinaldest) == al) + return; + getroomspaths(); + uint8 *roomsPaths = getroomspathsCPP(); + checkdest(); + data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12; + data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12; + data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12; + data.word(kLineendy) = roomsPaths[data.byte(kDestination) * 8 + 1] - 12; + bresenhams(); + if (data.byte(kLinedirection) != 0) { + data.byte(kLinepointer) = data.byte(kLinelength) - 1; + data.byte(kLinedirection) = 1; + return; + } + data.byte(kLinepointer) = 0; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 7e92ed847e..809e5f45f7 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -82,6 +82,7 @@ void facerightway(); void walking(); void walking(Sprite *sprite); + void autosetwalk(); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, ObjData *objData); -- cgit v1.2.3 From 4ad8b54241fb04aca95618637b50e4220e461034 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Tue, 9 Aug 2011 22:04:06 +0200 Subject: DREAMWEB: 'checkdest' ported to C++ --- engines/dreamweb/dreamgen.cpp | 51 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 27 ++++++++++++++++++++--- engines/dreamweb/stubs.h | 1 + 4 files changed, 26 insertions(+), 56 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 291078169f..2a7c67e889 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -17359,56 +17359,6 @@ holdingreel: data.byte(kWatchmode) = 2; } -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(); @@ -20137,7 +20087,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_walktotext: walktotext(); break; case addr_getflagunderp: getflagunderp(); break; case addr_setwalk: setwalk(); break; - case addr_checkdest: checkdest(); break; case addr_bresenhams: bresenhams(); break; case addr_workoutframes: workoutframes(); break; case addr_copyname: copyname(); break; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 18be264a9e..60abf44c01 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -119,7 +119,6 @@ public: static const uint16 addr_copyname = 0xca5c; static const uint16 addr_workoutframes = 0xca54; static const uint16 addr_bresenhams = 0xca50; - static const uint16 addr_checkdest = 0xca4c; static const uint16 addr_setwalk = 0xca44; static const uint16 addr_getflagunderp = 0xca40; static const uint16 addr_walktotext = 0xca3c; @@ -1875,7 +1874,7 @@ public: void makecaps(); void read(); void fadescreenups(); - void checkdest(); + //void checkdest(); //void initman(); void loadpalfromiff(); //void facerightway(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 6d2fee1ecd..cd6a9d6b4f 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -886,9 +886,8 @@ void DreamGenContext::autosetwalk() { al = data.byte(kManspath); if (data.byte(kFinaldest) == al) return; - getroomspaths(); - uint8 *roomsPaths = getroomspathsCPP(); - checkdest(); + 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; @@ -902,5 +901,27 @@ void DreamGenContext::autosetwalk() { 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; + } + data.byte(kDestination) = destination; +} + } /*namespace dreamgen */ diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 809e5f45f7..746a75b97b 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -83,6 +83,7 @@ void walking(); 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); -- cgit v1.2.3 From edbec1cccbe52a85b579cdfb4ecbe5f6276a2506 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 16:54:23 +0200 Subject: DREAMWEB: Improvement of 'printchar' signature --- engines/dreamweb/print.cpp | 12 ++++++------ engines/dreamweb/stubs.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index d29a073960..98cb4f612d 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -35,7 +35,7 @@ void DreamGenContext::printboth() { void DreamGenContext::printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; - printchar(src, &newX, y, c, nextChar, &width, &height); + printchar(segRef(src).ptr(0, 0), &newX, y, c, nextChar, &width, &height); multidump(*x, y, width, height); *x = newX; } @@ -76,13 +76,13 @@ void DreamGenContext::getnextword() { void DreamGenContext::printchar() { uint16 x = di; uint8 width, height; - printchar(ds, &x, bx, al, ah, &width, &height); + printchar(ds.ptr(0, 0), &x, bx, al, ah, &width, &height); di = x; cl = width; ch = height; } -void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { +void DreamGenContext::printchar(const void *src, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { if (c == 255) return; push(si); @@ -90,8 +90,7 @@ void DreamGenContext::printchar(uint16 src, uint16* x, uint16 y, uint8 c, uint8 if (data.byte(kForeignrelease) != 0) y -= 3; uint16 tmp = c - 32 + data.word(kCharshift); - ds = src; - showframe(ds.ptr(0, 0), *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); + showframe(src, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); @@ -169,6 +168,7 @@ void DreamGenContext::printdirect() { void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool centered) { data.word(kLastxpos) = x; ds = data.word(kCurrentset); + const void *src = ds.ptr(0, 0); while (true) { uint16 offset = x; uint8 charCount = getnumber(si, maxWidth, centered, &offset); @@ -182,7 +182,7 @@ void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool cent } c = engine->modifyChar(c); uint8 width, height; - printchar(ds, &i, *y, c, nextChar, &width, &height); + printchar(src, &i, *y, c, nextChar, &width, &height); data.word(kLastxpos) = i; --charCount; } while(charCount); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 746a75b97b..b9c5936907 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -46,7 +46,7 @@ void printboth(); void printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); - void printchar(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height); + void printchar(const void *src, 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 usetimedtext(); -- cgit v1.2.3 From d8cbea02f9aa9d2795ccc683c02ab9a20479b067 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 17:03:02 +0200 Subject: DREAMWEB: Improvement of 'getnumber' signature --- engines/dreamweb/print.cpp | 12 ++++++------ engines/dreamweb/stubs.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 98cb4f612d..36cfc7695d 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -109,7 +109,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center ds = data.word(kCharset1); do { uint16 offset = x; - uint16 charCount = getnumber(si, maxWidth, centered, &offset); + uint16 charCount = getnumber(es.ptr(si, 0), maxWidth, centered, &offset); do { push(si); push(es); @@ -171,7 +171,7 @@ void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool cent const void *src = ds.ptr(0, 0); while (true) { uint16 offset = x; - uint8 charCount = getnumber(si, maxWidth, centered, &offset); + uint8 charCount = getnumber(es.ptr(si, 0), maxWidth, centered, &offset); uint16 i = offset; do { uint8 c = es.byte(si); @@ -192,17 +192,17 @@ void DreamGenContext::printdirect(uint16 x, uint16 *y, uint8 maxWidth, bool cent void DreamGenContext::getnumber() { uint16 offset = di; - cl = getnumber(si, dl, (bool)(dl & 1), &offset); + cl = getnumber(es.ptr(si, 0), dl, (bool)(dl & 1), &offset); di = offset; } -uint8 DreamGenContext::getnumber(uint16 index, uint16 maxWidth, bool centered, uint16* offset) { +uint8 DreamGenContext::getnumber(const uint8 *string, 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; + uint8 done = getnextword(string, &wordTotalWidth, &wordCharCount); + string += wordCharCount; if (done == 1) { //endoftext ax = totalWidth + wordTotalWidth - 10; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index b9c5936907..10cb6568d2 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -56,7 +56,7 @@ void printslow(); void dumptextline(); void getnumber(); - uint8 getnumber(uint16 index, uint16 maxWidth, bool centered, uint16 *offset); + uint8 getnumber(const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset); void kernchars(); uint8 kernchars(uint8 firstChar, uint8 secondChar, uint8 width); void getroomdata(); -- cgit v1.2.3 From 78e337203d35000ac0f4b7fe653db230d50beec3 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 17:12:26 +0200 Subject: DREAMWEB: Improvement of 'printdirect' signature and register usage --- engines/dreamweb/print.cpp | 16 ++++++++++------ engines/dreamweb/stubs.cpp | 3 ++- engines/dreamweb/stubs.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 36cfc7695d..5859722633 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -161,22 +161,26 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center void DreamGenContext::printdirect() { uint16 y = bx; - printdirect(di, &y, dl, (bool)(dl & 1)); + 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(uint16 x, uint16 *y, uint8 maxWidth, bool centered) { +void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { data.word(kLastxpos) = x; ds = data.word(kCurrentset); const void *src = ds.ptr(0, 0); while (true) { uint16 offset = x; - uint8 charCount = getnumber(es.ptr(si, 0), maxWidth, centered, &offset); + uint8 charCount = getnumber(*string, maxWidth, centered, &offset); uint16 i = offset; do { - uint8 c = es.byte(si); - uint8 nextChar = es.byte(si+1); - ++si; + uint8 c = (*string)[0]; + uint8 nextChar = (*string)[1]; + ++(*string); if ((c == 0) || (c == ':')) { return; } diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index cd6a9d6b4f..4bc631cef0 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -320,8 +320,9 @@ 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; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 10cb6568d2..b0c0370803 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -48,7 +48,7 @@ void printchar(); void printchar(const void *src, 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 getundertimed(); void putundertimed(); -- cgit v1.2.3 From 81a522e03ee05716f06cb541511f165d138e104a Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 17:20:34 +0200 Subject: DREAMWEB: Improvement of 'printslow' signature --- engines/dreamweb/print.cpp | 11 ++++++----- engines/dreamweb/stubs.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 5859722633..e1f446a978 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -28,14 +28,14 @@ namespace DreamGen { void DreamGenContext::printboth() { uint16 x = di; - printboth(ds, &x, bx, al, ah); + printboth(ds.ptr(0, 0), &x, bx, al, ah); di = x; } -void DreamGenContext::printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { +void DreamGenContext::printboth(const void* src, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; - printchar(segRef(src).ptr(0, 0), &newX, y, c, nextChar, &width, &height); + printchar(src, &newX, y, c, nextChar, &width, &height); multidump(*x, y, width, height); *x = newX; } @@ -107,6 +107,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center data.byte(kPointerframe) = 1; data.byte(kPointermode) = 3; ds = data.word(kCharset1); + const void* src = ds.ptr(0, 0); do { uint16 offset = x; uint16 charCount = getnumber(es.ptr(si, 0), maxWidth, centered, &offset); @@ -119,7 +120,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center push(es); push(ds); c0 = engine->modifyChar(c0); - printboth(ds, &offset, y, c0, c1); + printboth(src, &offset, y, c0, c1); ds = pop(); es = pop(); ++si; @@ -134,7 +135,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center c1 = engine->modifyChar(c1); data.word(kCharshift) = 91; uint16 offset2 = offset; - printboth(ds, &offset2, y, c1, c2); + printboth(src, &offset2, y, c1, c2); data.word(kCharshift) = 0; es = pop(); ds = pop(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index b0c0370803..840a47384d 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -44,7 +44,7 @@ void getnextword(); uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount); void printboth(); - void printboth(uint16 src, uint16 *x, uint16 y, uint8 c, uint8 nextChar); + void printboth(const void *src, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); void printchar(const void *src, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height); void printdirect(); -- cgit v1.2.3 From 80f712b5b9d15e87f29aea8992fbd1896a7eddfd Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 17:34:41 +0200 Subject: DREAMWEB: 'multidump' doesn't dirty ds anymore --- engines/dreamweb/vgagrafx.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index ed195aa551..bb7f30fdb5 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -80,10 +80,9 @@ void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, ui } 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); + engine->blit(workspace() + offset, kScreenwidth, x, y, width, height); } void DreamGenContext::multidump() { -- cgit v1.2.3 From a710b32c615d2d8bdf3c07f5e9674d37d40a009d Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 10 Aug 2011 17:35:55 +0200 Subject: DREAMWEB: Removed useless push/pops --- engines/dreamweb/print.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index e1f446a978..105f7e14f9 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -117,12 +117,8 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center uint8 c0 = es.byte(si); uint8 c1 = es.byte(si+1); uint8 c2 = es.byte(si+2); - push(es); - push(ds); c0 = engine->modifyChar(c0); printboth(src, &offset, y, c0, c1); - ds = pop(); - es = pop(); ++si; if ((c1 == 0) || (c1 == ':')) { es = pop(); @@ -130,15 +126,11 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center return 0; } if (charCount != 1) { - push(ds); - push(es); c1 = engine->modifyChar(c1); data.word(kCharshift) = 91; uint16 offset2 = offset; printboth(src, &offset2, y, c1, c2); data.word(kCharshift) = 0; - es = pop(); - ds = pop(); for (int i=0; i<2; ++i) { waitframes(); if (ax == 0) -- cgit v1.2.3 From 3e9773a858b5d710845d7a188dbebbada1101887 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 02:27:41 +0200 Subject: DREAMWEB: Stricter typing in the printing subsystem --- engines/dreamweb/print.cpp | 38 +++++++++++++++++++------------------- engines/dreamweb/stubs.h | 8 ++++---- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 105f7e14f9..f8dddf3f4e 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -28,19 +28,19 @@ namespace DreamGen { void DreamGenContext::printboth() { uint16 x = di; - printboth(ds.ptr(0, 0), &x, bx, al, ah); + printboth((const Frame *)ds.ptr(0, 0), &x, bx, al, ah); di = x; } -void DreamGenContext::printboth(const void* src, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { +void DreamGenContext::printboth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; - printchar(src, &newX, y, c, nextChar, &width, &height); + printchar(charSet, &newX, y, c, nextChar, &width, &height); multidump(*x, y, width, height); *x = newX; } -uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount) { +uint8 DreamGenContext::getnextword(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount) { *totalWidth = 0; *charCount = 0; while(true) { @@ -58,7 +58,7 @@ uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 firstChar = engine->modifyChar(firstChar); if (firstChar != 255) { uint8 secondChar = *string; - uint8 width = ds.byte(6*(firstChar - 32 + data.word(kCharshift))); + uint8 width = charSet[firstChar - 32 + data.word(kCharshift)].width; width = kernchars(firstChar, secondChar, width); *totalWidth += width; } @@ -67,7 +67,7 @@ uint8 DreamGenContext::getnextword(const uint8 *string, uint8 *totalWidth, uint8 void DreamGenContext::getnextword() { uint8 totalWidth, charCount; - al = getnextword(es.ptr(di, 0), &totalWidth, &charCount); + al = getnextword((Frame *)ds.ptr(0, 0), es.ptr(di, 0), &totalWidth, &charCount); bl = totalWidth; bh = charCount; di += charCount; @@ -76,13 +76,13 @@ void DreamGenContext::getnextword() { void DreamGenContext::printchar() { uint16 x = di; uint8 width, height; - printchar(ds.ptr(0, 0), &x, bx, al, ah, &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 void *src, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *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); @@ -90,7 +90,7 @@ void DreamGenContext::printchar(const void *src, uint16* x, uint16 y, uint8 c, u if (data.byte(kForeignrelease) != 0) y -= 3; uint16 tmp = c - 32 + data.word(kCharshift); - showframe(src, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); + showframe(charSet, *x, y, tmp & 0x1ff, (tmp >> 8) & 0xfe, width, height); di = pop(); si = pop(); _cmp(data.byte(kKerning), 0); @@ -107,10 +107,10 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center data.byte(kPointerframe) = 1; data.byte(kPointermode) = 3; ds = data.word(kCharset1); - const void* src = ds.ptr(0, 0); + const Frame* charSet = (const Frame *)ds.ptr(0, 0); do { uint16 offset = x; - uint16 charCount = getnumber(es.ptr(si, 0), maxWidth, centered, &offset); + uint16 charCount = getnumber(charSet, es.ptr(si, 0), maxWidth, centered, &offset); do { push(si); push(es); @@ -118,7 +118,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center uint8 c1 = es.byte(si+1); uint8 c2 = es.byte(si+2); c0 = engine->modifyChar(c0); - printboth(src, &offset, y, c0, c1); + printboth(charSet, &offset, y, c0, c1); ++si; if ((c1 == 0) || (c1 == ':')) { es = pop(); @@ -129,7 +129,7 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center c1 = engine->modifyChar(c1); data.word(kCharshift) = 91; uint16 offset2 = offset; - printboth(src, &offset2, y, c1, c2); + printboth(charSet, &offset2, y, c1, c2); data.word(kCharshift) = 0; for (int i=0; i<2; ++i) { waitframes(); @@ -165,10 +165,10 @@ void DreamGenContext::printdirect() { void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { data.word(kLastxpos) = x; ds = data.word(kCurrentset); - const void *src = ds.ptr(0, 0); + const Frame *charSet = (const Frame *)ds.ptr(0, 0); while (true) { uint16 offset = x; - uint8 charCount = getnumber(*string, maxWidth, centered, &offset); + uint8 charCount = getnumber(charSet, *string, maxWidth, centered, &offset); uint16 i = offset; do { uint8 c = (*string)[0]; @@ -179,7 +179,7 @@ void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uin } c = engine->modifyChar(c); uint8 width, height; - printchar(src, &i, *y, c, nextChar, &width, &height); + printchar(charSet, &i, *y, c, nextChar, &width, &height); data.word(kLastxpos) = i; --charCount; } while(charCount); @@ -189,16 +189,16 @@ void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uin void DreamGenContext::getnumber() { uint16 offset = di; - cl = getnumber(es.ptr(si, 0), dl, (bool)(dl & 1), &offset); + cl = getnumber((Frame *)ds.ptr(0, 0), es.ptr(si, 0), dl, (bool)(dl & 1), &offset); di = offset; } -uint8 DreamGenContext::getnumber(const uint8 *string, uint16 maxWidth, bool centered, uint16* 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(string, &wordTotalWidth, &wordCharCount); + uint8 done = getnextword(charSet, string, &wordTotalWidth, &wordCharCount); string += wordCharCount; if (done == 1) { //endoftext diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 840a47384d..5ac340feea 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -42,11 +42,11 @@ void randomnumber(); void quickquit2(); void getnextword(); - uint8 getnextword(const uint8 *string, uint8 *totalWidth, uint8 *charCount); + uint8 getnextword(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount); void printboth(); - void printboth(const void *src, uint16 *x, uint16 y, uint8 c, uint8 nextChar); + void printboth(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); - void printchar(const void *src, uint16 *x, uint16 y, uint8 c, uint8 nextChar, 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(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered); void usetimedtext(); @@ -56,7 +56,7 @@ void printslow(); void dumptextline(); void getnumber(); - uint8 getnumber(const uint8 *string, 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(); -- cgit v1.2.3 From b701deed4f192f29b92fadb50275e2bdb5c39959 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 02:30:25 +0200 Subject: DREAMWEB: Less ds pollution in 'printslow' and 'printdirect' --- engines/dreamweb/print.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index f8dddf3f4e..9e4c416015 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -106,8 +106,7 @@ void DreamGenContext::printslow() { uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered) { data.byte(kPointerframe) = 1; data.byte(kPointermode) = 3; - ds = data.word(kCharset1); - const Frame* charSet = (const Frame *)ds.ptr(0, 0); + const Frame* charSet = (const Frame *)segRef(data.word(kCharset1)).ptr(0, 0); do { uint16 offset = x; uint16 charCount = getnumber(charSet, es.ptr(si, 0), maxWidth, centered, &offset); @@ -164,8 +163,7 @@ void DreamGenContext::printdirect() { void DreamGenContext::printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { data.word(kLastxpos) = x; - ds = data.word(kCurrentset); - const Frame *charSet = (const Frame *)ds.ptr(0, 0); + 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); -- cgit v1.2.3 From 707c6ed01c6f19ec192efe915636f256e12898b0 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 03:19:51 +0200 Subject: DREAMWEB: 'printslow' API improved --- engines/dreamweb/print.cpp | 29 +++++++---------------------- engines/dreamweb/stubs.h | 3 +-- 2 files changed, 8 insertions(+), 24 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 9e4c416015..3d571f939e 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -26,12 +26,6 @@ namespace DreamGen { -void DreamGenContext::printboth() { - uint16 x = di; - printboth((const Frame *)ds.ptr(0, 0), &x, bx, al, ah); - di = x; -} - void DreamGenContext::printboth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; @@ -100,28 +94,23 @@ void DreamGenContext::printchar(const Frame *charSet, uint16* x, uint16 y, uint8 } void DreamGenContext::printslow() { - al = printslow(di, bx, dl, (bool)(dl & 1)); + al = printslow(es.ptr(si, 0), di, bx, dl, (bool)(dl & 1)); } -uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool centered) { +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, es.ptr(si, 0), maxWidth, centered, &offset); + uint16 charCount = getnumber(charSet, string, maxWidth, centered, &offset); do { - push(si); - push(es); - uint8 c0 = es.byte(si); - uint8 c1 = es.byte(si+1); - uint8 c2 = es.byte(si+2); + uint8 c0 = string[0]; + uint8 c1 = string[1]; + uint8 c2 = string[2]; c0 = engine->modifyChar(c0); printboth(charSet, &offset, y, c0, c1); - ++si; if ((c1 == 0) || (c1 == ':')) { - es = pop(); - si = pop(); return 0; } if (charCount != 1) { @@ -135,16 +124,12 @@ uint8 DreamGenContext::printslow(uint16 x, uint16 y, uint8 maxWidth, bool center if (ax == 0) continue; if (ax != data.word(kOldbutton)) { - es = pop(); - si = pop(); return 1; } } } - es = pop(); - si = pop(); - ++si; + ++string; --charCount; } while (charCount); y += 10; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 5ac340feea..3140bbd8bc 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -43,7 +43,6 @@ void quickquit2(); void getnextword(); uint8 getnextword(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount); - void printboth(); void printboth(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar); void printchar(); void printchar(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height); @@ -52,7 +51,7 @@ void usetimedtext(); 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(); -- cgit v1.2.3 From c2e9f01ae448287670a398a2e6881b66d1f8fb39 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 03:23:22 +0200 Subject: DREAMWEB: A stub has become useless --- engines/dreamweb/print.cpp | 8 -------- engines/dreamweb/stubs.h | 1 - 2 files changed, 9 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 3d571f939e..26084c35d1 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -59,14 +59,6 @@ uint8 DreamGenContext::getnextword(const Frame *charSet, const uint8 *string, ui } } -void DreamGenContext::getnextword() { - uint8 totalWidth, charCount; - al = getnextword((Frame *)ds.ptr(0, 0), es.ptr(di, 0), &totalWidth, &charCount); - bl = totalWidth; - bh = charCount; - di += charCount; -} - void DreamGenContext::printchar() { uint16 x = di; uint8 width, height; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 3140bbd8bc..e7b6a152b5 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -41,7 +41,6 @@ void seecommandtail(); void randomnumber(); void quickquit2(); - void getnextword(); 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(); -- cgit v1.2.3 From d5a184e2f058f89fa4b5297078ca8fd035c4a6a7 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 03:30:41 +0200 Subject: DREAMWEB: 'showframe' takes a Frame --- engines/dreamweb/sprite.cpp | 8 ++++---- engines/dreamweb/stubs.cpp | 2 +- engines/dreamweb/stubs.h | 4 ++-- engines/dreamweb/vgagrafx.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 9941fb2c2d..c1fe3a9e95 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -67,7 +67,7 @@ void DreamGenContext::printasprite(const Sprite *sprite) { else c = 0; uint8 width, height; - showframe(segRef(sprite->frameData()).ptr(0, 0), x, y, sprite->b15, c, &width, &height); + showframe((const Frame *)segRef(sprite->frameData()).ptr(0, 0), x, y, sprite->b15, c, &width, &height); } void DreamGenContext::clearsprites() { @@ -529,10 +529,10 @@ void DreamGenContext::findsource() { } } -void *DreamGenContext::findsourceCPP() { +Frame *DreamGenContext::findsourceCPP() { push(ds); findsource(); - void *result = ds.ptr(0, 0); + Frame *result = (Frame *)ds.ptr(0, 0); ds = pop(); return result; } @@ -546,7 +546,7 @@ void DreamGenContext::showreelframe(Reel *reel) { uint16 x = reel->x + data.word(kMapadx); uint16 y = reel->y + data.word(kMapady); data.word(kCurrentframe) = reel->frame(); - void *source = findsourceCPP(); + Frame *source = findsourceCPP(); uint16 frame = data.word(kCurrentframe) - data.word(kTakeoff); uint8 width, height; showframe(source, x, y, frame, 8, &width, &height); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 4bc631cef0..70d4364031 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -867,7 +867,7 @@ void DreamGenContext::crosshair() { } push(ds); ds = data.word(kIcons1); - uint8 *src = ds.ptr(0, 0); + Frame *src = (Frame *)ds.ptr(0, 0); ds = pop(); uint8 width, height; showframe(src, kZoomx + 24, kZoomy + 19, frame, 0, &width, &height); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index e7b6a152b5..edaded67df 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -65,7 +65,7 @@ void startloading(const Room *room); Sprite *spritetable(); void showframe(); - void showframe(const void *frameData, 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(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height); @@ -94,7 +94,7 @@ void lockeddoorway(Sprite *sprite, ObjData *objData); void liftsprite(Sprite *sprite, ObjData *objData); void findsource(); - void *findsourceCPP(); + Frame *findsourceCPP(); void showreelframe(); void showreelframe(Reel *reel); void turnpathonCPP(uint8 param); diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index bb7f30fdb5..ebf1bff23c 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -314,8 +314,8 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint } } -void DreamGenContext::showframe(const void *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) { - const Frame *frame = ((const Frame *)frameData) + frameNumber; +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; @@ -371,7 +371,7 @@ void DreamGenContext::showframe(const void *frameData, uint16 x, uint16 y, uint1 void DreamGenContext::showframe() { uint8 width, height; - showframe(ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); + showframe((Frame *)ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height); cl = width; ch = height; } -- cgit v1.2.3 From b6a8e2e98cb59f4edc3c6e9441b894dd1237a745 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 12:26:30 +0200 Subject: DREAMWEB: Misc cleanings in stubs.cpp --- engines/dreamweb/stubs.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 70d4364031..41f834b3d5 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -623,10 +623,7 @@ void DreamGenContext::getroomspaths() { } uint8 *DreamGenContext::getroomspathsCPP() { - push(es); - es = data.word(kReels); - void *result = es.ptr(data.byte(kRoomnum) * 144, 144); - es = pop(); + void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); return (uint8 *)result; } @@ -845,13 +842,12 @@ void DreamGenContext::plotreel() { if (al == 255) break; dealwithspecial(); - _inc(data.word(kReelpointer)); + ++data.word(kReelpointer); reel += 8; } for (size_t i = 0; i < 8; ++i) { - ax = reel->frame(); - if (ax != 0xffff) + if (reel->frame() != 0xffff) showreelframe(reel); ++reel; } @@ -865,10 +861,7 @@ void DreamGenContext::crosshair() { } else { frame = 29; } - push(ds); - ds = data.word(kIcons1); - Frame *src = (Frame *)ds.ptr(0, 0); - ds = pop(); + 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); } @@ -878,9 +871,7 @@ void DreamGenContext::deltextline() { uint16 y = data.word(kTextaddressy); if (data.byte(kForeignrelease) != 0) y -= 3; - ds = data.word(kBuffers); - si = kTextunder; - multiput(ds.ptr(si, 0), x, y, kUndertextsizex, kUndertextsizey); + multiput(segRef(data.word(kBuffers)).ptr(kTextunder, 0), x, y, kUndertextsizex, kUndertextsizey); } void DreamGenContext::autosetwalk() { -- cgit v1.2.3 From a8c619d7ad3d78cd218c2f1af5ec13a58a02e0be Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 12:33:33 +0200 Subject: DREAMWEB: 'dealwithspecial' has a better signature --- engines/dreamweb/stubs.cpp | 26 ++++++++++++-------------- engines/dreamweb/stubs.h | 2 +- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 41f834b3d5..688fd936a6 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -800,32 +800,32 @@ void DreamGenContext::fillspace() { memset(ds.ptr(dx, cx), al, cx); } -void DreamGenContext::dealwithspecial() { - uint8 type = al - 220; +void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) { + uint8 type = firstParam - 220; if (type == 0) { - al = ah; + al = secondParam; placesetobject(); data.byte(kHavedoneobs) = 1; } else if (type == 1) { - al = ah; + al = secondParam; removesetobject(); data.byte(kHavedoneobs) = 1; } else if (type == 2) { - al = ah; + al = secondParam; placefreeobject(); data.byte(kHavedoneobs) = 1; } else if (type == 3) { - al = ah; + al = secondParam; removefreeobject(); data.byte(kHavedoneobs) = 1; } else if (type == 4) { switchryanoff(); } else if (type == 5) { - data.byte(kTurntoface) = ah; - data.byte(kFacing) = ah; + data.byte(kTurntoface) = secondParam; + data.byte(kFacing) = secondParam; switchryanon(); } else if (type == 6) { - data.byte(kNewlocation) = ah; + data.byte(kNewlocation) = secondParam; } else { movemap(); } @@ -835,13 +835,11 @@ void DreamGenContext::plotreel() { getreelstart(); Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); while (true) { - al = reel->x; - ah = reel->y; - if (al < 220) + if (reel->x < 220) break; - if (al == 255) + if (reel->x == 255) break; - dealwithspecial(); + dealwithspecial(reel->x, reel->y); ++data.word(kReelpointer); reel += 8; } diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index edaded67df..7485f095c2 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -107,7 +107,7 @@ void cancelch0(); void cancelch1(); void plotreel(); - void dealwithspecial(); + void dealwithspecial(uint8 firstParam, uint8 secondParam); void zoom(); void crosshair(); void showrain(); -- cgit v1.2.3 From cea283644fb78d4e113fa5c994bfcfce61ba7381 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 13:29:33 +0200 Subject: DREAMWEB: 'getreelstart' ported to C++ --- engines/dreamweb/sprite.cpp | 5 +++++ engines/dreamweb/stubs.cpp | 3 +-- engines/dreamweb/stubs.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index c1fe3a9e95..53c972008c 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -537,6 +537,11 @@ Frame *DreamGenContext::findsourceCPP() { return result; } +Reel *DreamGenContext::getreelstartCPP() { + 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); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 688fd936a6..64067c0d62 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -832,8 +832,7 @@ void DreamGenContext::dealwithspecial(uint8 firstParam, uint8 secondParam) { } void DreamGenContext::plotreel() { - getreelstart(); - Reel *reel = (Reel *)es.ptr(si, sizeof(Reel)); + Reel *reel = getreelstartCPP(); while (true) { if (reel->x < 220) break; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 7485f095c2..8e87b962dc 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -107,6 +107,7 @@ void cancelch0(); void cancelch1(); void plotreel(); + Reel *getreelstartCPP(); void dealwithspecial(uint8 firstParam, uint8 secondParam); void zoom(); void crosshair(); -- cgit v1.2.3 From 701776a73aee44d18a729b1cc7f51ff97e2fbc3d Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 15:18:41 +0200 Subject: DREAMWEB: 'multiget' and 'multiput' don't dirty segments anymore --- engines/dreamweb/vgagrafx.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index ebf1bff23c..c87e27a8c4 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -43,15 +43,14 @@ void DreamGenContext::multiget() { } void DreamGenContext::multiget(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) { - unsigned src = x + y * kScreenwidth; - ds = data.word(kWorkspace); + 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 = ds.ptr(src + kScreenwidth * l, w); + const uint8 *src_p = src + kScreenwidth * l; uint8 *dst_p = dst + w * l; memcpy(dst_p, src_p, w); } @@ -65,8 +64,7 @@ void DreamGenContext::multiput() { } void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) { - unsigned dst = x + y * kScreenwidth; - es = data.word(kWorkspace); + uint8 *dst = workspace() + x + y * kScreenwidth; if (y + h > 200) h = 200 - y; if (x + w > 320) @@ -74,7 +72,7 @@ void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, ui //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 = es.ptr(dst + kScreenwidth * l, w); + uint8 *dst_p = dst + kScreenwidth * l; memcpy(dst_p, src_p, w); } } -- cgit v1.2.3 From 2250c10ffeddad9b1b1796b6946cfd285f48207f Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 15:24:06 +0200 Subject: DREAMWEB: 'dumptimedtext' ported to C++ --- engines/dreamweb/dreamgen.cpp | 23 ----------------------- engines/dreamweb/dreamgen.h | 5 ++--- engines/dreamweb/stubs.cpp | 11 +++++++++++ engines/dreamweb/stubs.h | 1 + 4 files changed, 14 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 2a7c67e889..dc576314a4 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -12084,28 +12084,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); @@ -19892,7 +19870,6 @@ 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 60abf44c01..5a74ed6ad0 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -315,7 +315,6 @@ public: 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; @@ -1500,7 +1499,7 @@ public: void loadspeech(); //void cls(); //void printsprites(); - void checkifperson(); + //void dumptimedtext(); void showallobs(); //void getnumber(); void adjustleft(); @@ -1568,7 +1567,7 @@ public: void folderhints(); void openhoteldoor(); void removesetobject(); - void dumptimedtext(); + void checkifperson(); //void frameoutfx(); void blank(); void drinker(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 64067c0d62..361b22dac8 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -326,6 +326,17 @@ void DreamGenContext::usetimedtext() { data.byte(kNeedtodumptimed) = 1; } +void DreamGenContext::dumptimedtext() { + if (data.byte(kNeedtodumptimed) != 1) + return; + uint8 y = data.byte(kTimedy); + if (data.byte(kForeignrelease) != 0) + y -= 3; + + multidump(data.byte(kTimedx), y, 240, kUndertimedysize); + data.byte(kNeedtodumptimed) = 0; +} + void DreamGenContext::gettime() { TimeDate t; g_system->getTimeAndDate(t); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 8e87b962dc..1baad44524 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -48,6 +48,7 @@ void printdirect(); void printdirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered); void usetimedtext(); + void dumptimedtext(); void getundertimed(); void putundertimed(); uint8 printslow(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered); -- cgit v1.2.3 From b08b31eed3e31fb485a9091829f23cfb9006551f Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Thu, 11 Aug 2011 16:59:20 +0200 Subject: DREAMWEB: 'setuptimedtemp' ported to C++ --- engines/dreamweb/dreamgen.cpp | 53 ------------------------------------------- engines/dreamweb/dreamgen.h | 3 +-- engines/dreamweb/stubs.cpp | 41 +++++++++++++++++++++++++++++++++ engines/dreamweb/stubs.h | 2 ++ 4 files changed, 44 insertions(+), 55 deletions(-) (limited to 'engines') diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index dc576314a4..12bfcb413f 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -12106,58 +12106,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(); @@ -19871,7 +19819,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case addr_dochange: dochange(); break; case addr_autoappear: autoappear(); 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; diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index 5a74ed6ad0..42d135fa9a 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -313,7 +313,6 @@ 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_autoappear = 0xc70c; static const uint16 addr_dochange = 0xc708; @@ -1384,7 +1383,7 @@ public: //void kernchars(); void othersmoker(); void dofade(); - void setuptimedtemp(); + //void setuptimedtemp(); void blocknametext(); void useelevator5(); void useelevator4(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 361b22dac8..da37df99e1 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -326,6 +326,47 @@ void DreamGenContext::usetimedtext() { data.byte(kNeedtodumptimed) = 1; } +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(); + } + dx = pop(); + cx = pop(); + bx = pop(); + ax = pop(); + if ((data.byte(kSpeechloaded) == 1) && (data.byte(kSubtitles) != 1)) + return; + } +#endif + + 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; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 1baad44524..5886630821 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -49,6 +49,8 @@ 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(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered); -- cgit v1.2.3