aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Montoir2005-09-02 11:12:09 +0000
committerGregory Montoir2005-09-02 11:12:09 +0000
commit443cf756be85cce937c92b5051fe13b6a2ef189d (patch)
treefa00ab07f74c6ef2da4984ddb1508a2997d0b485
parentb1167c6275aff8a25c59a68e90441dcec6891260 (diff)
downloadscummvm-rg350-443cf756be85cce937c92b5051fe13b6a2ef189d.tar.gz
scummvm-rg350-443cf756be85cce937c92b5051fe13b6a2ef189d.tar.bz2
scummvm-rg350-443cf756be85cce937c92b5051fe13b6a2ef189d.zip
added special sequence opcode 8
svn-id: r18733
-rw-r--r--kyra/kyra.cpp9
-rw-r--r--kyra/kyra.h2
-rw-r--r--kyra/screen.cpp95
-rw-r--r--kyra/screen.h4
4 files changed, 102 insertions, 8 deletions
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp
index 250ad0986d..79b9901c08 100644
--- a/kyra/kyra.cpp
+++ b/kyra/kyra.cpp
@@ -184,6 +184,7 @@ void KyraEngine::errorString(const char *buf1, char *buf2) {
int KyraEngine::go() {
_quitFlag = false;
+ _screen->setScreenDim(0);
seq_intro();
return 0;
}
@@ -237,7 +238,7 @@ int KyraEngine::getCharLength(const char *str, int len) {
int KyraEngine::dropCRIntoString(char *str, int offs) {
debug(9, "KyraEngine::dropCRIntoString('%s', %d)", str, offs);
int pos = 0;
- while (*str != '\0') {
+ while (*str) {
if (*str == 0x20) {
*str = 0xD;
return pos;
@@ -609,7 +610,11 @@ bool KyraEngine::seq_playSpecialSequence(const uint8 *seqData, bool skipSeq) {
}
break;
case 8:
- warning("Sequence opcode 8 skipped");
+ _screen->shuffleScreen(0, 16, 320, 128, 2, 0, 0, false);
+ _screen->_curPage = 2;
+ if (_seq_specialSequenceTempBuffer) {
+ _screen->copyCurPageBlock(0, 16, 40, 128, _seq_specialSequenceTempBuffer);
+ }
break;
case 9:
seq_copyView();
diff --git a/kyra/kyra.h b/kyra/kyra.h
index 7634242a82..ab0a759b17 100644
--- a/kyra/kyra.h
+++ b/kyra/kyra.h
@@ -71,6 +71,8 @@ public:
Screen *screen() { return _screen; }
uint8 game() const { return _game; }
+
+ Common::RandomSource _rnd;
protected:
diff --git a/kyra/screen.cpp b/kyra/screen.cpp
index 4171bb65c1..c23fbf5885 100644
--- a/kyra/screen.cpp
+++ b/kyra/screen.cpp
@@ -72,6 +72,7 @@ void Screen::clearPage(int pageNum) {
int Screen::setCurPage(int pageNum) {
debug(9, "Screen::setCurPage(%d)", pageNum);
+ assert(pageNum < SCREEN_PAGE_NUM);
int previousPage = _curPage;
_curPage = pageNum;
return previousPage;
@@ -82,6 +83,20 @@ void Screen::clearCurPage() {
memset(getPagePtr(_curPage), 0, SCREEN_PAGE_SIZE);
}
+uint8 Screen::getPagePixel(int pageNum, int x, int y) {
+ debug(9, "Screen::getPagePixel(%d, %d, %d)", pageNum, x, y);
+ assert(pageNum < SCREEN_PAGE_NUM);
+ assert(x >= 0 && x < SCREEN_W && y >= 0 && y < SCREEN_H);
+ return _pagePtrs[pageNum][y * SCREEN_W + x];
+}
+
+void Screen::setPagePixel(int pageNum, int x, int y, uint8 color) {
+ debug(9, "Screen::setPagePixel(%d, %d, %d, %d)", pageNum, x, y, color);
+ assert(pageNum < SCREEN_PAGE_NUM);
+ assert(x >= 0 && x < SCREEN_W && y >= 0 && y < SCREEN_H);
+ _pagePtrs[pageNum][y * SCREEN_W + x] = color;
+}
+
void Screen::fadeFromBlack() {
debug(9, "Screen::fadeFromBlack()");
memset(_palette3, 0, 768);
@@ -145,6 +160,74 @@ void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint
}
}
+void Screen::copyCurPageBlock(int x, int y, int h, int w, uint8 *dst) {
+ debug(9, "Screen::copyCurPageBlock(%d, %d, %d, %d, 0x%X)", x, y, w, h, dst);
+ if (x < 0) {
+ x = 0;
+ } else if (x >= 40) {
+ return;
+ }
+ if (x + w > 40) {
+ w = 40 - x;
+ }
+ if (y < 0) {
+ y = 0;
+ } else if (y >= 200) {
+ return;
+ }
+ if (y + h > 200) {
+ h = 200 - y;
+ }
+ const uint8 *src = getPagePtr(_curPage) + y * SCREEN_W + x * 8;
+ while (h--) {
+ memcpy(dst, src, w * 8);
+ dst += SCREEN_W;
+ src += SCREEN_H;
+ }
+}
+
+void Screen::shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent) {
+ debug(9, "Screen::shuffleScreen(%d, %d, %d, %d, %d, %d, %d, %d)", sx, sy, w, h, srcPage, dstPage, ticks, transparent);
+ assert(sx >= 0 && w <= SCREEN_W);
+ int x;
+ uint16 x_offs[SCREEN_W];
+ for (x = 0; x < SCREEN_W; ++x) {
+ x_offs[x] = x;
+ }
+ for (x = 0; x < w; ++x) {
+ int i = _vm->_rnd.getRandomNumber(w - 1);
+ SWAP(x_offs[x], x_offs[i]);
+ }
+
+ assert(sy >= 0 && h <= SCREEN_H);
+ int y;
+ uint8 y_offs[SCREEN_H];
+ for (y = 0; y < SCREEN_H; ++y) {
+ y_offs[y] = y;
+ }
+ for (y = 0; y < h; ++y) {
+ int i = _vm->_rnd.getRandomNumber(h - 1);
+ SWAP(y_offs[y], y_offs[i]);
+ }
+
+ for (y = 0; y < h; ++y) {
+ int y_cur = y;
+ for (x = 0; x < w; ++x) {
+ int i = sx + x_offs[x];
+ int j = sy + y_offs[y_cur];
+ ++y_cur;
+ if (y_cur >= h) {
+ y_cur = 0;
+ }
+ uint8 color = getPagePixel(srcPage, i, j);
+ if (!transparent || color != 0) {
+ setPagePixel(dstPage, i, j, color);
+ }
+ }
+ _system->delayMillis(ticks * 1000 / 60);
+ }
+}
+
void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum) {
debug(9, "Screen::fillRect(%d, %d, %d, %d, %d, %d)", x1, y1, x2, y2, color, pageNum);
assert(x2 < SCREEN_W && y2 < SCREEN_H);
@@ -209,22 +292,22 @@ void Screen::drawShape(uint8 pageNum, const uint8 *shapeData, int x, int y, int
debug(9, "Screen::drawShape(%d, %d, %d, %d, %d)", pageNum, x, y, sd, flags);
assert(shapeData);
if (flags & 0x8000) {
- warning("unhandled (flags & 0x8000) in Video::drawShape()");
+ warning("unhandled (flags & 0x8000) in Screen::drawShape()");
}
if (flags & 0x100) {
- warning("unhandled (flags & 0x100) in Video::drawShape()");
+ warning("unhandled (flags & 0x100) in Screen::drawShape()");
}
if (flags & 0x1000) {
- warning("unhandled (flags & 0x1000) in Video::drawShape()");
+ warning("unhandled (flags & 0x1000) in Screen::drawShape()");
}
if (flags & 0x200) {
- warning("unhandled (flags & 0x200) in Video::drawShape()");
+ warning("unhandled (flags & 0x200) in Screen::drawShape()");
}
if (flags & 0x4000) {
- warning("unhandled (flags & 0x4000) in Video::drawShape()");
+ warning("unhandled (flags & 0x4000) in Screen::drawShape()");
}
if (flags & 0x800) {
- warning("unhandled (flags & 0x800) in Video::drawShape()");
+ warning("unhandled (flags & 0x800) in Screen::drawShape()");
}
int scale_w, scale_h;
if (flags & DSF_SCALE) {
diff --git a/kyra/screen.h b/kyra/screen.h
index 43fdae094c..97f18cc57f 100644
--- a/kyra/screen.h
+++ b/kyra/screen.h
@@ -53,12 +53,16 @@ public:
void clearPage(int pageNum);
int setCurPage(int pageNum);
void clearCurPage();
+ uint8 getPagePixel(int pageNum, int x, int y);
+ void setPagePixel(int pageNum, int x, int y, uint8 color);
void fadeFromBlack();
void fadeToBlack();
void setScreenPalette(const uint8 *palData);
void copyToPage0(int y, int h, uint8 page, uint8 *seqBuf);
void copyRegion(int x1, int y1, int x2, int y2, int w, int h, int srcPage, int dstPage);
void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
+ void copyCurPageBlock(int x, int y, int h, int w, uint8 *dst);
+ void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1);
void setAnimBlockPtr(uint8 *p, int size);
void setTextColorMap(const uint8 *cmap);