aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/vgagrafx.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-04-18 23:35:23 +0200
committerWillem Jan Palenstijn2013-05-08 20:40:58 +0200
commit9c2341678ef4984bf92b3878295250faf980b066 (patch)
tree2fb4805e05e16b9924e80c9947e6bad723b28c4b /engines/dreamweb/vgagrafx.cpp
parent8172d679df5148a4a32f46074b20cb6caf91844f (diff)
parenta5f4ff36ffc386d48f2da49387a9655ce9295a4d (diff)
downloadscummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.gz
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.tar.bz2
scummvm-rg350-9c2341678ef4984bf92b3878295250faf980b066.zip
Merge branch 'master'
Diffstat (limited to 'engines/dreamweb/vgagrafx.cpp')
-rw-r--r--engines/dreamweb/vgagrafx.cpp373
1 files changed, 187 insertions, 186 deletions
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 53db811313..a66f156a1d 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -24,25 +24,12 @@
#include "engines/util.h"
#include "graphics/surface.h"
-namespace DreamGen {
+namespace DreamWeb {
-uint8 *DreamGenContext::workspace() {
- uint8 *result = segRef(data.word(kWorkspace)).ptr(0, 0);
- return result;
-}
-
-void DreamGenContext::allocatework() {
- data.word(kWorkspace) = allocatemem(0x1000);
-}
-
-void DreamGenContext::multiget() {
- multiget(ds.ptr(si, 0), di, bx, cl, ch);
- si += cl * ch;
- di += bx * kScreenwidth + kScreenwidth * ch;
- cx = 0;
-}
+const uint16 kZoomx = 8;
+const uint16 kZoomy = 132;
-void DreamGenContext::multiget(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) {
+void DreamWebEngine::multiGet(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) {
assert(x < 320);
assert(y < 200);
const uint8 *src = workspace() + x + y * kScreenwidth;
@@ -50,22 +37,15 @@ void DreamGenContext::multiget(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h)
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) {
+ //debug(1, "multiGet %u,%u %ux%u -> segment: %04x->%04x", x, y, w, h, (uint16)ds, (uint16)es);
+ for (unsigned l = 0; l < h; ++l) {
const uint8 *src_p = src + kScreenwidth * l;
uint8 *dst_p = dst + w * l;
memcpy(dst_p, src_p, w);
}
}
-void DreamGenContext::multiput() {
- multiput(ds.ptr(si, 0), di, bx, cl, ch);
- si += cl * ch;
- di += bx * kScreenwidth + kScreenwidth * ch;
- cx = 0;
-}
-
-void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) {
+void DreamWebEngine::multiPut(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) {
assert(x < 320);
assert(y < 200);
uint8 *dst = workspace() + x + y * kScreenwidth;
@@ -73,43 +53,25 @@ void DreamGenContext::multiput(const uint8 *src, uint16 x, uint16 y, uint8 w, ui
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) {
+ //debug(1, "multiPut %ux%u -> segment: %04x->%04x", w, h, (uint16)ds, (uint16)es);
+ for (unsigned l = 0; l < h; ++l) {
const uint8 *src_p = src + w * l;
uint8 *dst_p = dst + kScreenwidth * l;
memcpy(dst_p, src_p, w);
}
}
-void DreamGenContext::multidump(uint16 x, uint16 y, uint8 width, uint8 height) {
+void DreamWebEngine::multiDump(uint16 x, uint16 y, uint8 width, uint8 height) {
unsigned offset = x + y * kScreenwidth;
- //debug(1, "multidump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
- engine->blit(workspace() + offset, kScreenwidth, x, y, width, height);
-}
-
-void DreamGenContext::multidump() {
- multidump(di, bx, cl, ch);
- unsigned offset = di + bx * kScreenwidth;
- si = di = offset + ch * kScreenwidth;
- cx = 0;
-}
-
-void DreamGenContext::worktoscreen() {
- uint size = 320 * 200;
- engine->blit(workspace(), 320, 0, 0, 320, 200);
- di = si = size;
- cx = 0;
-}
-
-void DreamGenContext::printundermon() {
- engine->printUnderMonitor();
+ //debug(1, "multiDump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
+ blit(workspace() + offset, kScreenwidth, x, y, width, height);
}
-void DreamGenContext::cls() {
- engine->cls();
+void DreamWebEngine::workToScreen() {
+ blit(workspace(), 320, 0, 0, 320, 200);
}
-void DreamGenContext::frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamWebEngine::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) {
@@ -119,7 +81,7 @@ void DreamGenContext::frameoutnm(uint8 *dst, const uint8 *src, uint16 pitch, uin
}
}
-void DreamGenContext::frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamWebEngine::frameOutBh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
uint16 stride = pitch - width;
dst += y * pitch + x;
@@ -135,7 +97,7 @@ void DreamGenContext::frameoutbh(uint8 *dst, const uint8 *src, uint16 pitch, uin
}
}
-void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y) {
+void DreamWebEngine::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;
@@ -152,8 +114,8 @@ void DreamGenContext::frameoutfx(uint8 *dst, const uint8 *src, uint16 pitch, uin
}
}
-void DreamGenContext::doshake() {
- uint8 &counter = data.byte(kShakecounter);
+void DreamWebEngine::doShake() {
+ uint8 &counter = _vars._shakeCounter;
if (counter == 48)
return;
@@ -177,46 +139,22 @@ void DreamGenContext::doshake() {
0, -2, 3, -2, 0, 2, 4, -1,
1, -3, 3, 0,
};
+ assert(counter < ARRAYSIZE(shakeTable));
int offset = shakeTable[counter];
- engine->setShakePos(offset >= 0 ? offset : -offset);
+ 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 DreamWebEngine::vSync() {
+ waitForVSync();
}
-void DreamGenContext::setmode() {
- vsync();
+void DreamWebEngine::setMode() {
+ waitForVSync();
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);
+void DreamWebEngine::showPCX(const Common::String &suffix) {
+ Common::String name = getDatafilePrefix() + suffix;
Common::File pcxFile;
if (!pcxFile.open(name)) {
@@ -224,20 +162,19 @@ void DreamGenContext::showpcx() {
return;
}
- uint8 *maingamepal;
+ 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);
+ mainGamePal = _mainPal;
+ pcxFile.read(mainGamePal, 48);
- memset(maingamepal + 48, 0xff, 720);
+ memset(mainGamePal + 48, 0xff, 720);
for (i = 0; i < 48; i++) {
- maingamepal[i] >>= 2;
+ mainGamePal[i] >>= 2;
}
// Decode the image data.
@@ -285,31 +222,31 @@ void DreamGenContext::showpcx() {
pcxFile.close();
}
-void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y) {
+void DreamWebEngine::frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 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 < 0) {
+ if (x < 0) {
assert(width >= -x);
width -= -x;
src += -x;
x = 0;
}
- if(y < 0) {
+ if (y < 0) {
assert(height >= -y);
height -= -y;
src += (-y) * width;
y = 0;
}
- if(x >= 320)
+ if (x >= 320)
return;
- if(y >= 200)
+ if (y >= 200)
return;
- if(x + width > 320) {
+ if (x + width > 320) {
width = 320 - x;
}
- if(y + height > 200) {
+ if (y + height > 200) {
height = 200 - y;
}
@@ -327,92 +264,114 @@ void DreamGenContext::frameoutv(uint8 *dst, const uint8 *src, uint16 pitch, uint
}
}
-void DreamGenContext::showframe(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
+void DreamWebEngine::showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
uint8 width, height;
- showframe(frameData, x, y, frameNumber, effectsFlag, &width, &height);
+ showFrame(frameData, x, y, frameNumber, effectsFlag, &width, &height);
}
-void DreamGenContext::showframe(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
- const Frame *frame = frameData + frameNumber;
- if ((frame->width == 0) && (frame->height == 0)) {
- *width = 0;
- *height = 0;
- return;
- }
-
-//notblankshow:
- if ((effectsFlag & 128) == 0) {
- x += frame->x;
- y += frame->y;
- }
-//skipoffsets:
-
- *width = frame->width;
- *height = frame->height;
- const uint8 *pSrc = ((const uint8 *)frameData) + frame->ptr() + 2080;
-
+void DreamWebEngine::showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 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;
+ x -= width / 2;
+ y -= height / 2;
}
- if (effectsFlag & 8) { //printlist
+ if (effectsFlag & 64) { // diffDest
+ error("Unsupported DreamWebEngine::showFrame effectsFlag %d", effectsFlag);
/*
- push(ax);
- al = x - data.word(kMapadx);
- ah = y - data.word(kMapady);
- //addtoprintlist(); // NB: Commented in the original asm
- ax = pop();
+ frameOutFx(es.ptr(0, dx * *height), pSrc, dx, *width, *height, x, y);
+ return;
*/
}
- if (effectsFlag & 4) { //flippedx
- frameoutfx(workspace(), pSrc, 320, *width, *height, x, y);
+ if (effectsFlag & 8) { // printList
+ //addToPrintList(x - _mapAdX, y - _mapAdY); // NB: Commented in the original asm
+ }
+ 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);
+ if (effectsFlag & 2) { // noMask
+ frameOutNm(workspace(), pSrc, 320, width, height, x, y);
return;
}
if (effectsFlag & 32) {
- frameoutbh(workspace(), pSrc, 320, *width, *height, x, y);
+ frameOutBh(workspace(), pSrc, 320, width, height, x, y);
return;
}
}
-//noeffects:
- frameoutv(workspace(), pSrc, 320, *width, *height, x, y);
- return;
+ // "noEffects"
+ frameOutV(workspace(), pSrc, 320, width, height, x, y);
}
-void DreamGenContext::showframe() {
- uint8 width, height;
- showframe((Frame *)ds.ptr(0, 0), di, bx, ax & 0x1ff, ah & 0xfe, &width, &height);
- cl = width;
- ch = height;
+void DreamWebEngine::showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
+ const Frame *frame = &frameData._frames[frameNumber];
+ if ((frame->width == 0) && (frame->height == 0)) {
+ *width = 0;
+ *height = 0;
+ return;
+ }
+
+ // "notBlankShow"
+ if ((effectsFlag & 128) == 0) {
+ x += frame->x;
+ y += frame->y;
+ }
+
+ // "skipOffsets"
+ *width = frame->width;
+ *height = frame->height;
+ const uint8 *pSrc = frameData.getFrameData(frameNumber);
+
+ showFrameInternal(pSrc, x, y, effectsFlag, *width, *height);
}
-void DreamGenContext::clearwork() {
+void DreamWebEngine::clearWork() {
memset(workspace(), 0, 320*200);
}
-void DreamGenContext::zoom() {
- if (data.word(kWatchingtime) != 0)
+void DreamWebEngine::dumpZoom() {
+ if (_vars._zoomOn == 1)
+ multiDump(kZoomx + 5, kZoomy + 4, 46, 40);
+}
+
+void DreamWebEngine::crosshair() {
+ uint8 frame;
+ if ((_commandType != 3) && (_commandType < 10)) {
+ frame = 9;
+ } else {
+ frame = 29;
+ }
+ showFrame(_icons1, kZoomx + 24, kZoomy + 19, frame, 0);
+}
+
+void DreamWebEngine::getUnderZoom() {
+ multiGet(_zoomSpace, kZoomx + 5, kZoomy + 4, 46, 40);
+}
+
+void DreamWebEngine::putUnderZoom() {
+ multiPut(_zoomSpace, kZoomx + 5, kZoomy + 4, 46, 40);
+}
+
+void DreamWebEngine::zoomIcon() {
+ if (_vars._zoomOn == 0)
+ return;
+ showFrame(_icons1, kZoomx, kZoomy-1, 8, 0);
+}
+
+void DreamWebEngine::zoom() {
+ if (_vars._watchingTime != 0)
return;
- if (data.byte(kZoomon) != 1)
+ if (_vars._zoomOn != 1)
return;
- if (data.byte(kCommandtype) >= 199) {
- putunderzoom();
+ if (_commandType >= 199) {
+ putUnderZoom();
return;
}
- uint16 srcOffset = (data.word(kOldpointery) - 9) * 320 + (data.word(kOldpointerx) - 11);
+ uint16 srcOffset = (_oldPointerY - 9) * 320 + (_oldPointerX - 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) {
+ 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;
@@ -423,46 +382,88 @@ void DreamGenContext::zoom() {
dst += 320*2;
}
crosshair();
- data.byte(kDidzoom) = 1;
+ _didZoom = 1;
}
-void DreamGenContext::paneltomap() {
- multiget(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
+void DreamWebEngine::panelToMap() {
+ multiGet(_mapStore, _mapXStart + _mapAdX, _mapYStart + _mapAdY, _mapXSize, _mapYSize);
}
-void DreamGenContext::maptopanel() {
- multiput(segRef(data.word(kMapstore)).ptr(0, 0), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
+void DreamWebEngine::mapToPanel() {
+ multiPut(_mapStore, _mapXStart + _mapAdX, _mapYStart + _mapAdY, _mapXSize, _mapYSize);
}
-void DreamGenContext::dumpmap() {
- multidump(data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
+void DreamWebEngine::dumpMap() {
+ multiDump(_mapXStart + _mapAdX, _mapYStart + _mapAdY, _mapXSize, _mapYSize);
}
-void DreamGenContext::transferinv() {
- const Frame *freeFrames = (const Frame *)segRef(data.word(kFreeframes)).ptr(kFrframedata, 0);
- const Frame *freeFrame = freeFrames + (3 * data.byte(kItemtotran) + 1);
- Frame *exFrames = (Frame *)segRef(data.word(kExtras)).ptr(kExframedata, 0);
- Frame *exFrame = exFrames + (3 * data.byte(kExpos) + 1);
- exFrame->width = freeFrame->width;
- exFrame->height = freeFrame->height;
- exFrame->x = freeFrame->x;
- exFrame->y = freeFrame->y;
- uint16 byteCount = freeFrame->width * freeFrame->height;
- const uint8 *src = segRef(data.word(kFreeframes)).ptr(kFrframes + freeFrame->ptr(), byteCount);
- uint8 *dst = segRef(data.word(kExtras)).ptr(kExframes + data.word(kExframepos), byteCount);
- memcpy(dst, src, byteCount);
- exFrame->setPtr(data.word(kExframepos));
- data.word(kExframepos) += byteCount;
-}
-
-bool DreamGenContext::pixelcheckset(const ObjPos *pos, uint8 x, uint8 y) {
+bool DreamWebEngine::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) {
x -= pos->xMin;
y -= pos->yMin;
- SetObject *setObject = getsetad(pos->index);
- Frame *frame = (Frame *)segRef(data.word(kSetframes)).ptr(kFramedata, 0) + setObject->index;
- const uint8 *ptr = segRef(data.word(kSetframes)).ptr(kFrames, 0) + frame->ptr() + y * frame->width + x;
+ SetObject *setObject = getSetAd(pos->index);
+ const Frame &frame = _setFrames._frames[setObject->index];
+ const uint8 *ptr = _setFrames.getFrameData(setObject->index) + y * frame.width + x;
return *ptr != 0;
}
-} /*namespace dreamgen */
+void DreamWebEngine::loadPalFromIFF() {
+ Common::File palFile;
+ uint8* buf = new uint8[2000];
+ palFile.open(getDatafilePrefix() + "PAL");
+ palFile.read(buf, 2000);
+ palFile.close();
+
+ const uint8 *src = buf + 0x30;
+ uint8 *dst = _mainPal;
+ for (size_t i = 0; i < 256*3; ++i) {
+ uint8 c = src[i] / 4;
+ if (_brightPalette) {
+ if (c) {
+ c = c + c / 2 + c / 4;
+ if (c > 63)
+ c = 63;
+ }
+ }
+ dst[i] = c;
+ }
+
+ delete[] buf;
+}
+
+void DreamWebEngine::createPanel() {
+ showFrame(_icons2, 0, 8, 0, 2);
+ showFrame(_icons2, 160, 8, 0, 2);
+ showFrame(_icons2, 0, 104, 0, 2);
+ showFrame(_icons2, 160, 104, 0, 2);
+}
+
+void DreamWebEngine::createPanel2() {
+ createPanel();
+ showFrame(_icons2, 0, 0, 5, 2);
+ showFrame(_icons2, 160, 0, 5, 2);
+}
+
+void DreamWebEngine::showPanel() {
+ showFrame(_icons1, 72, 0, 19, 0);
+ showFrame(_icons1, 192, 0, 19, 0);
+}
+
+void DreamWebEngine::transferFrame(uint8 from, uint8 to, uint8 offset) {
+ const Frame &freeFrame = _freeFrames._frames[3*from + offset];
+ Frame &exFrame = _exFrames._frames[3*to + offset];
+
+ exFrame.width = freeFrame.width;
+ exFrame.height = freeFrame.height;
+ exFrame.x = freeFrame.x;
+ exFrame.y = freeFrame.y;
+ uint16 byteCount = freeFrame.width * freeFrame.height;
+
+ const uint8 *src = _freeFrames.getFrameData(3*from + offset);
+ uint8 *dst = _exFrames._data + _vars._exFramePos;
+ memcpy(dst, src, byteCount);
+
+ exFrame.setPtr(_vars._exFramePos);
+ _vars._exFramePos += byteCount;
+}
+} // End of namespace DreamWeb