From 0fbefc72aa7fd29b74dd2fac41ebfae0dfcac781 Mon Sep 17 00:00:00 2001 From: Michael Pearce Date: Mon, 9 Sep 2002 05:56:11 +0000 Subject: Applied roever's screen effects patch (#602595) and fixed LethalWP's Makefile ;) svn-id: r4909 --- backends/dc/dc.h | 1 + backends/dc/display.cpp | 40 ++++++++++++++++++++ backends/mac/mac.cpp | 6 +++ backends/morphos/morphos.cpp | 40 ++++++++++++++++++++ backends/morphos/morphos.h | 1 + backends/null/null.cpp | 1 + backends/sdl/sdl-common.cpp | 37 ++++++++++++++++++ backends/sdl/sdl-common.h | 2 + backends/wince/pocketpc.cpp | 42 +++++++++++++++++++++ backends/x11/x11.cpp | 40 ++++++++++++++++++++ common/system.h | 4 ++ scumm/gfx.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++-- 12 files changed, 300 insertions(+), 4 deletions(-) diff --git a/backends/dc/dc.h b/backends/dc/dc.h index 4a2b78cfb7..7bd15c9bbf 100644 --- a/backends/dc/dc.h +++ b/backends/dc/dc.h @@ -15,6 +15,7 @@ class OSystem_Dreamcast : public OSystem { // Draw a bitmap to screen. // The screen will not be updated to reflect the new bitmap void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h); + void move_screen(int dx, int dy, int height); // Update the dirty areas of the screen void update_screen(); diff --git a/backends/dc/display.cpp b/backends/dc/display.cpp index 97c7f2aed5..317f33a0fa 100644 --- a/backends/dc/display.cpp +++ b/backends/dc/display.cpp @@ -132,6 +132,46 @@ void OSystem_Dreamcast::copy_rect(const byte *buf, int pitch, int x, int y, } while (--h); } +void OSystem_Dreamcast::move_screen(int dx, int dy, int height) { + + if ((dx == 0) && (dy == 0)) + return; + + if (dx == 0) { + // vertical movement + if (dy > 0) { + // move down + // copy from bottom to top + for (int y = height - 1; y >= dy; y--) + copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, SCREEN_W, 1); + } else { + // move up + // copy from top to bottom + for (int y = 0; y < height + dx; y++) + copy_rect(screen + SCREEN_W * (y - dy), SCREEN_W, 0, y, SCREEN_W, 1); + } + } else if (dy == 0) { + // horizontal movement + if (dx > 0) { + // move right + // copy from right to left + for (int x = SCREEN_W - 1; x >= dx; x--) + copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height); + } else { + // move left + // copy from left to right + for (int x = 0; x < SCREEN_W; x++) + copy_rect(screen + x - dx, SCREEN_W, x, 0, 1, height); + } + } else { + // free movement + // not neccessary for now + } + + +} + + bool OSystem_Dreamcast::show_mouse(bool visible) { bool last = _ms_visible; diff --git a/backends/mac/mac.cpp b/backends/mac/mac.cpp index f22d72666b..2dc6dea1f5 100644 --- a/backends/mac/mac.cpp +++ b/backends/mac/mac.cpp @@ -772,6 +772,12 @@ void OSystem_MAC::copy_rect(const byte *buf, int pitch, int x, int y, int w, int } while(--h); } +void OSystem_MAC::move_screen(int dx, int dy) { + + +} + + void OSystem_MAC::add_dirty_rect(int x, int y, int w, int h) { if (force_full) return; diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp index 629b8079b8..164c046b54 100644 --- a/backends/morphos/morphos.cpp +++ b/backends/morphos/morphos.cpp @@ -927,6 +927,46 @@ void OSystem_MorphOS::copy_rect(const byte *src, int pitch, int x, int y, int w, } } +void OSystem_MorphOS::move_screen(int dx, int dy, int height) { + + if ((dx == 0) && (dy == 0)) + return; + + if (dx == 0) { + // vertical movement + if (dy > 0) { + // move down + // copy from bottom to top + for (int y = height - 1; y >= dy; y--) + copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1); + } else { + // move up + // copy from top to bottom + for (int y = 0; y < height + dx; y++) + copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1); + } + } else if (dy == 0) { + // horizontal movement + if (dx > 0) { + // move right + // copy from right to left + for (int x = ScummBufferWidth - 1; x >= dx; x--) + copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height); + } else { + // move left + // copy from left to right + for (int x = 0; x < ScummBufferWidth; x++) + copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height); + } + } else { + // free movement + // not neccessary for now + } + + +} + + bool OSystem_MorphOS::AddUpdateRect(WORD x, WORD y, WORD w, WORD h) { if (UpdateRects > 25) diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h index aead0c3aec..6bda51d597 100644 --- a/backends/morphos/morphos.h +++ b/backends/morphos/morphos.h @@ -47,6 +47,7 @@ class OSystem_MorphOS : public OSystem // Draw a bitmap to screen. // The screen will not be updated to reflect the new bitmap virtual void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h); + void move_screen(int dx, int dy, int height); // Update the dirty areas of the screen virtual void update_screen(); diff --git a/backends/null/null.cpp b/backends/null/null.cpp index d48f1be764..df42dbfc38 100644 --- a/backends/null/null.cpp +++ b/backends/null/null.cpp @@ -30,6 +30,7 @@ public: void set_palette(const byte *colors, uint start, uint num) {} void init_size(uint w, uint h); void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {} + void move_screen(int dx, int dy) {} void update_screen() {} bool show_mouse(bool visible) { return false; } void set_mouse_pos(int x, int y) {} diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index 422ce8b353..bdedb8ed1a 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -135,6 +135,43 @@ void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int } +void OSystem_SDL_Common::move_screen(int dx, int dy, int height) { + + if ((dx == 0) && (dy == 0)) + return; + + if (dx == 0) { + // vertical movement + if (dy > 0) { + // move down + // copy from bottom to top + for (int y = height - 1; y >= dy; y--) + copy_rect((byte *)sdl_screen->pixels + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + } else { + // move up + // copy from top to bottom + for (int y = 0; y < height + dx; y++) + copy_rect((byte *)sdl_screen->pixels + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + } + } else if (dy == 0) { + // horizontal movement + if (dx > 0) { + // move right + // copy from right to left + for (int x = SCREEN_WIDTH - 1; x >= dx; x--) + copy_rect((byte *)sdl_screen->pixels + x - dx, SCREEN_WIDTH, x, 0, 1, height); + } else { + // move left + // copy from left to right + for (int x = 0; x < SCREEN_WIDTH; x++) + copy_rect((byte *)sdl_screen->pixels + x - dx, SCREEN_WIDTH, x, 0, 1, height); + } + } else { + // free movement + // not neccessary for now + } +} + void OSystem_SDL_Common::add_dirty_rect(int x, int y, int w, int h) { if (force_full) return; diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index ae7b64306e..bd2410ab2a 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -42,6 +42,8 @@ public: // The screen will not be updated to reflect the new bitmap void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h); + void move_screen(int dx, int dy, int height); + // Update the dirty areas of the screen void update_screen() = 0; diff --git a/backends/wince/pocketpc.cpp b/backends/wince/pocketpc.cpp index 0162d14e28..6adb61b0b3 100644 --- a/backends/wince/pocketpc.cpp +++ b/backends/wince/pocketpc.cpp @@ -95,6 +95,8 @@ public: // The screen will not be updated to reflect the new bitmap void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h); + void move_screen(int dx, int dy, int height); + // Update the dirty areas of the screen void update_screen(); @@ -1215,6 +1217,46 @@ void OSystem_WINCE3::copy_rect(const byte *buf, int pitch, int x, int y, int w, } while (--h); } +void OSystem_WINCE3::move_screen(int dx, int dy, int height) { + + if ((dx == 0) && (dy == 0)) + return; + + if (dx == 0) { + // vertical movement + if (dy > 0) { + // move down + // copy from bottom to top + for (int y = height - 1; y >= dy; y--) + copy_rect(_gfx_buf + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + } else { + // move up + // copy from top to bottom + for (int y = 0; y < height + dx; y++) + copy_rect(_gfx_buf + SCREEN_WIDTH * (y - dy), SCREEN_WIDTH, 0, y, SCREEN_WIDTH, 1); + } + } else if (dy == 0) { + // horizontal movement + if (dx > 0) { + // move right + // copy from right to left + for (int x = SCREEN_WIDTH - 1; x >= dx; x--) + copy_rect(_gfx_buf + x - dx, SCREEN_WIDTH, x, 0, 1, height); + } else { + // move left + // copy from left to right + for (int x = 0; x < SCREEN_WIDTH; x++) + copy_rect(_gfx_buf + x - dx, SCREEN_WIDTH, x, 0, 1, height); + } + } else { + // free movement + // not neccessary for now + } + + +} + + void OSystem_WINCE3::update_screen() { if (!hide_cursor) diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp index 1492c0d8ae..3a2e362a1d 100644 --- a/backends/x11/x11.cpp +++ b/backends/x11/x11.cpp @@ -62,6 +62,8 @@ public: // The screen will not be updated to reflect the new bitmap void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h); + void move_screen(int dx, int dy, int height); + // Update the dirty areas of the screen void update_screen(); @@ -509,6 +511,44 @@ void OSystem_X11::copy_rect(const byte *buf, int pitch, int x, int y, int w, int } } +void OSystem_X11::move_screen(int dx, int dy, int height) { + + if ((dx == 0) && (dy == 0)) + return; + + if (dx == 0) { + // vertical movement + if (dy > 0) { + // move down + // copy from bottom to top + for (int y = height - 1; y >= dy; y--) + copy_rect(local_fb + fb_width * (y - dy), fb_width, 0, y, fb_width, 1); + } else { + // move up + // copy from top to bottom + for (int y = 0; y < height + dx; y++) + copy_rect(local_fb + fb_width * (y - dy), fb_width, 0, y, fb_width, 1); + } + } else if (dy == 0) { + // horizontal movement + if (dx > 0) { + // move right + // copy from right to left + for (int x = fb_width - 1; x >= dx; x--) + copy_rect(local_fb + x - dx, fb_width, x, 0, 1, height); + } else { + // move left + // copy from left to right + for (int x = 0; x < fb_width; x++) + copy_rect(local_fb + x - dx, fb_width, x, 0, 1, height); + } + } else { + // free movement + // not neccessary for now + } +} + + void OSystem_X11::update_screen_helper(const dirty_square * d, dirty_square * dout) { int x, y; diff --git a/common/system.h b/common/system.h index 4bac597eb1..c0fabec1b4 100644 --- a/common/system.h +++ b/common/system.h @@ -92,6 +92,10 @@ public: // The screen will not be updated to reflect the new bitmap virtual void copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) = 0; + // Moves the screen content around by the given amount of pixels + // but only the top height pixel rows, the rest stays untouched + virtual void move_screen(int dx, int dy, int height) = 0; + // Update the dirty areas of the screen virtual void update_screen() = 0; diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 07f92f9e33..2bbaf04dc6 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -681,16 +681,16 @@ void Scumm::fadeIn(int effect) unkScreenEffect6(); break; case 130: - unkScreenEffect1(); + scrollEffect(3); // right unkScreenEffect1(); break; case 131: - unkScreenEffect2(); + scrollEffect(2); // left unkScreenEffect2(); break; case 132: - unkScreenEffect3(); + scrollEffect(1); // down unkScreenEffect3(); break; case 133: - unkScreenEffect4(); + scrollEffect(0); // up unkScreenEffect4(); break; case 134: dissolveEffect(1, 1); @@ -2092,6 +2092,88 @@ void Scumm::dissolveEffect(int width, int height) { } } +void Scumm::scrollEffect(int dir) { + + VirtScreen *vs = &virtscr[0]; + + int x, y; + int step; + + if ((dir == 0) || (dir == 1)) + step = vs->height; + else + step = vs->width; + +#define scrolltime 500 // ms the scroll is supposed to take +#define picturedelay 20 + + step /= (scrolltime/picturedelay); + + switch (dir) { + case 0: + //up + y = 1 + step; + while (y < vs->height) { + _system->move_screen(0, -step, vs->height); + _system->copy_rect(vs->screenPtr + vs->xstart + (y - step) * vs->width, + vs->width, + 0, vs->height - step, + vs->width, step); + _system->update_screen(); + waitForTimer(picturedelay); + + y += step; + } + break; + case 1: + // down + y = 1 + step; + while (y < vs->height) { + _system->move_screen(0, step, vs->height); + _system->copy_rect(vs->screenPtr + vs->xstart + vs->width * (vs->height-y), + vs->width, + 0, 0, + vs->width, step); + _system->update_screen(); + waitForTimer(picturedelay); + + y += step; + } + break; + case 2: + // left + x = 1 + step; + while (x < vs->width) { + _system->move_screen(-step, 0, vs->height); + _system->copy_rect(vs->screenPtr + vs->xstart + x - step, + vs->width, + vs->width - step, 0, + step, vs->height); + _system->update_screen(); + waitForTimer(picturedelay); + + x += step; + } + break; + case 3: + // right + x = 1 + step; + while (x < vs->width) { + _system->move_screen(step, 0, vs->height); + _system->copy_rect(vs->screenPtr + vs->xstart + vs->width - x, + vs->width, + 0, 0, + step, vs->height); + _system->update_screen(); + waitForTimer(picturedelay); + + x += step; + } + break; + } +} + + void Scumm::unkScreenEffect6() { if (_gameId == GID_LOOM256) dissolveEffect(1, 1); -- cgit v1.2.3