aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2006-02-16 22:35:43 +0000
committerTravis Howell2006-02-16 22:35:43 +0000
commit5c98378e84f9a3cdffde2f19e8105e24ed0f9d1a (patch)
treed42828321e60307881e497004a678f42f6a95a4d
parent8b76033dc3cd09ab8b717fe8e4e41fa2de1bcc19 (diff)
downloadscummvm-rg350-5c98378e84f9a3cdffde2f19e8105e24ed0f9d1a.tar.gz
scummvm-rg350-5c98378e84f9a3cdffde2f19e8105e24ed0f9d1a.tar.bz2
scummvm-rg350-5c98378e84f9a3cdffde2f19e8105e24ed0f9d1a.zip
Cleanup drawing code for Feeble Files
svn-id: r20734
-rw-r--r--engines/simon/simon.h1
-rw-r--r--engines/simon/vga.cpp281
2 files changed, 128 insertions, 154 deletions
diff --git a/engines/simon/simon.h b/engines/simon/simon.h
index bbacd95b31..c2b58f03b6 100644
--- a/engines/simon/simon.h
+++ b/engines/simon/simon.h
@@ -774,6 +774,7 @@ public:
protected:
void drawImages(VC10_state *state);
void drawImages_Feeble(VC10_state *state);
+ bool drawImages_clip(VC10_state *state);
void delete_vga_timer(VgaTimerEntry * vte);
void vcResumeSprite(const byte *code_ptr, uint16 cur_file, uint16 cur_sprite);
diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp
index da6db13b3a..599a04cdb8 100644
--- a/engines/simon/vga.cpp
+++ b/engines/simon/vga.cpp
@@ -656,13 +656,9 @@ void SimonEngine::decodeStripA(byte *dst, const byte *src, int height) {
void SimonEngine::vc10_draw() {
byte *p2;
uint width, height;
- uint maxWidth, maxHeight;
byte flags;
- const uint16 *vlut;
VC10_state state;
- int cur;
-
state.image = (int16)vcReadNextWord();
if (state.image == 0)
return;
@@ -674,15 +670,10 @@ void SimonEngine::vc10_draw() {
}
_vcPtr += 2;
state.x = (int16)vcReadNextWord();
+ state.x -= _scrollX;
- if (getGameType() == GType_SIMON2 || getGameType() == GType_FF) {
- state.x -= _scrollX;
- }
state.y = (int16)vcReadNextWord();
-
- if (getGameType() == GType_FF) {
- state.y -= _scrollY;
- }
+ state.y -= _scrollY;
if (getGameType() == GType_SIMON1) {
state.flags = vcReadNextWord();
@@ -774,212 +765,194 @@ void SimonEngine::vc10_draw() {
}
}
- vlut = &_video_windows[_windowNum * 4];
-
state.width = state.draw_width = width; /* cl */
state.height = state.draw_height = height; /* ch */
-
+
+ state.surf2_addr = dx_lock_2();
+ state.surf2_pitch = _dxSurfacePitch;
+
+ state.surf_addr = dx_lock_attached();
+ state.surf_pitch = _dxSurfacePitch;
+
+ if (getGameType() == GType_FF) {
+ drawImages_Feeble(&state);
+ } else {
+ drawImages(&state);
+ }
+
+ dx_unlock_2();
+ dx_unlock_attached();
+}
+
+bool SimonEngine::drawImages_clip(VC10_state *state) {
+ const uint16 *vlut;
+ uint maxWidth, maxHeight;
+ int cur;
+
+ vlut = &_video_windows[_windowNum * 4];
+
if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
- state.draw_width = width * 2;
+ state->draw_width = state->width * 2;
}
- state.x_skip = 0; /* colums to skip = bh */
- state.y_skip = 0; /* rows to skip = bl */
+ state->x_skip = 0; /* colums to skip = bh */
+ state->y_skip = 0; /* rows to skip = bl */
- cur = state.x;
+ cur = state->x;
if (cur < 0) {
do {
- if (!--state.draw_width)
- return;
- state.x_skip++;
+ if (!--state->draw_width)
+ return 0;
+ state->x_skip++;
} while (++cur);
}
- state.x = cur;
+ state->x = cur;
maxWidth = (getGameType() == GType_FF) ? 640 : (vlut[2] * 2);
- cur += state.draw_width - maxWidth;
+ cur += state->draw_width - maxWidth;
if (cur > 0) {
do {
- if (!--state.draw_width)
- return;
+ if (!--state->draw_width)
+ return 0;
} while (--cur);
}
- cur = state.y;
+ cur = state->y;
if (cur < 0) {
do {
- if (!--state.draw_height)
- return;
- state.y_skip++;
+ if (!--state->draw_height)
+ return 0;
+ state->y_skip++;
} while (++cur);
}
- state.y = cur;
+ state->y = cur;
maxHeight = (getGameType() == GType_FF) ? 480 : vlut[3];
- cur += state.draw_height - maxHeight;
+ cur += state->draw_height - maxHeight;
if (cur > 0) {
do {
- if (!--state.draw_height)
- return;
+ if (!--state->draw_height)
+ return 0;
} while (--cur);
}
- assert(state.draw_width != 0 && state.draw_height != 0);
+ assert(state->draw_width != 0 && state->draw_height != 0);
if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
- state.draw_width *= 4;
- }
-
- state.surf2_addr = dx_lock_2();
- state.surf2_pitch = _dxSurfacePitch;
-
- state.surf_addr = dx_lock_attached();
- state.surf_pitch = _dxSurfacePitch;
-
- if (getGameType() == GType_FF) {
- drawImages_Feeble(&state);
- } else {
- drawImages(&state);
+ state->draw_width *= 4;
}
- dx_unlock_2();
- dx_unlock_attached();
+ return 1;
}
void SimonEngine::drawImages_Feeble(VC10_state *state) {
- if (state->flags & 0x10) {
- // This is an "overlay" sprite, meaning that it's not affected
- // by scrolling. The Oracle icon uses it, for instance.
-
- state->x += _scrollX;
- state->y += _scrollY;
- }
-
- state->surf2_addr += state->x + state->y * state->surf2_pitch;
- state->surf_addr += state->x + state->y * state->surf_pitch;
-
- if (state->flags & 0x10) {
- // TODO: See the original ScaleClip() for further details.
- //
- // As far as I understand, overlay sprites are basically
- // uncompressed picture data (with 0 marking transparency).
- // However, scaling is currently not implemented.
- debug(0, "TODO: Overlay sprites not completely supported");
- } else if (state->flags & 0x20) {
- if (vcGetBit(81) == false) {
- // TODO: Compare Feeble rect
- }
+ if (state->flags & 0x8) {
+ if (state->flags & 0x40) {
+ // TODO::Add support for image scaling in Feeble Files
- uint w, h;
- byte *src, *dst, *dst_org;
+ } else if (state->flags & 0x10) {
+ // TODO::Add support for image overlay in Feeble Files
- state->dl = state->width;
- state->dh = state->height;
+ } else {
+ if (drawImages_clip(state) == 0)
+ return;
- vc10_skip_cols(state);
+ state->surf2_addr += state->x + state->y * state->surf2_pitch;
+ state->surf_addr += state->x + state->y * state->surf_pitch;
- dst_org = state->surf_addr;
- w = 0;
- do {
- byte color;
+ uint w, h;
+ byte *src, *dst, *dst_org;
- src = vc10_depack_column(state);
- dst = dst_org;
+ if (state->flags & 0x20) {
+ if (vcGetBit(81) == false) {
+ // TODO: Compare Feeble rect
+ }
- h = 0;
- do {
- color = *src;
- if (color)
- *dst = color;
- dst += _screenWidth;
- src++;
- } while (++h != state->draw_height);
- dst_org++;
- } while (++w != state->draw_width);
- } else if (state->flags & 0x8) {
- uint w, h;
- byte *src, *dst, *dst_org;
+ state->dl = state->width;
+ state->dh = state->height;
- state->dl = state->width;
- state->dh = state->height;
+ vc10_skip_cols(state);
- vc10_skip_cols(state);
+ dst_org = state->surf_addr;
+ w = 0;
+ do {
+ byte color;
- if (state->flags & 2) {
- dst_org = state->surf_addr;
- w = 0;
- do {
- src = vc10_depack_column(state);
- dst = dst_org;
+ src = vc10_depack_column(state);
+ dst = dst_org;
- h = 0;
- do {
- *dst = *src;
- dst += _screenWidth;
- src++;
- } while (++h != state->draw_height);
- dst_org++;
- } while (++w != state->draw_width);
- } else {
- dst_org = state->surf_addr;
- w = 0;
- do {
- byte color;
+ h = 0;
+ do {
+ color = *src;
+ if (color)
+ *dst = color;
+ dst += _screenWidth;
+ src++;
+ } while (++h != state->draw_height);
+ dst_org++;
+ } while (++w != state->draw_width);
+ } else {
+ state->dl = state->width;
+ state->dh = state->height;
- src = vc10_depack_column(state);
- dst = dst_org;
+ vc10_skip_cols(state);
- h = 0;
+ dst_org = state->surf_addr;
+ w = 0;
do {
- color = *src;
- if (color)
- *dst = color;
- dst += _screenWidth;
- src++;
- } while (++h != state->draw_height);
- dst_org++;
- } while (++w != state->draw_width);
+ byte color;
+
+ src = vc10_depack_column(state);
+ dst = dst_org;
+
+ h = 0;
+ do {
+ color = *src;
+ if ((state->flags & 2) || color != 0)
+ *dst = color;
+ dst += _screenWidth;
+ src++;
+ } while (++h != state->draw_height);
+ dst_org++;
+ } while (++w != state->draw_width);
+ }
}
} else {
+ if (drawImages_clip(state) == 0)
+ return;
+
+ state->surf2_addr += state->x + state->y * state->surf2_pitch;
+ state->surf_addr += state->x + state->y * state->surf_pitch;
+
const byte *src;
byte *dst;
uint count;
src = state->depack_src + state->width * state->y_skip;
dst = state->surf_addr;
- if (state->flags & 0x80) {
- do {
- for (count = 0; count != state->draw_width; count++) {
- byte color;
- color = src[count + state->x_skip];
- if (color) {
- if (color == 220)
- color = 244;
+ do {
+ for (count = 0; count != state->draw_width; count++) {
+ byte color;
+ color = src[count + state->x_skip];
+ if (color) {
+ if ((state->flags & 0x80) && color == 220)
+ color = 244;
- dst[count] = color;
- }
+ dst[count] = color;
}
- dst += _screenWidth;
- src += state->width;
- } while (--state->draw_height);
- } else {
- do {
- for (count = 0; count != state->draw_width; count++) {
- byte color;
- color = src[count + state->x_skip];
- if (color)
- dst[count] = color;
- }
- dst += _screenWidth;
- src += state->width;
- } while (--state->draw_height);
- }
- }
+ }
+ dst += _screenWidth;
+ src += state->width;
+ } while (--state->draw_height);
+ }
}
void SimonEngine::drawImages(VC10_state *state) {
const uint16 *vlut = &_video_windows[_windowNum * 4];
+ if (drawImages_clip(state) == 0)
+ return;
+
uint offs, offs2;
// Allow one section of Simon the Sorcerer 1 introduction to be displayed
// in lower half of screen