aboutsummaryrefslogtreecommitdiff
path: root/scumm/gfx.cpp
diff options
context:
space:
mode:
authorMax Horn2003-05-10 14:30:58 +0000
committerMax Horn2003-05-10 14:30:58 +0000
commitc4741d89a3a5e17f5312100e9f9280e055eb5e31 (patch)
treebf046638c3410a645644e7608d1054aafa1eade1 /scumm/gfx.cpp
parent114af3159e7c4fc552972a460f845e982fbc6ef5 (diff)
downloadscummvm-rg350-c4741d89a3a5e17f5312100e9f9280e055eb5e31.tar.gz
scummvm-rg350-c4741d89a3a5e17f5312100e9f9280e055eb5e31.tar.bz2
scummvm-rg350-c4741d89a3a5e17f5312100e9f9280e055eb5e31.zip
new V2 drawBitmap implementation which handles object drawing, too; no masking implemented yet. Once it fully works, will remove all the _egaStrip* stuff
svn-id: r7413
Diffstat (limited to 'scumm/gfx.cpp')
-rw-r--r--scumm/gfx.cpp169
1 files changed, 167 insertions, 2 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index c2468cb53c..286457e954 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -937,11 +937,176 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int width, c
if (vs->scrollable)
sx -= vs->xstart >> 3;
+ //////
+ //////
+ ////// START OF BIG HACK!
+ //////
+ //////
if (_vm->_features & GF_AFTER_V2) {
- // TODO: implement new V2 strip / zplane drawing in here
- //return;
+ backbuff_ptr = vs->screenPtr + (y * _numStrips + x) * 8;
+ if (vs->alloctwobuffers)
+ bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * _numStrips + x) * 8;
+ else
+ bgbak_ptr = backbuff_ptr;
+
+ _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x);
+
+//if (numstrip > 5) return;
+//if (width != 320 || height != 128) return;
+//if (width != 40 || height != 48) return;
+//if (height == 128) return;
+
+
+//printf("x %d, y %d, width %d, height %d, stripnr %d, numstrip %d, vs->alloctwobuffers %d\n",
+// x, y, width, height, stripnr, numstrip, vs->alloctwobuffers);
+
+ const int left = stripnr << 3;
+ const int right = left + numstrip << 3;
+ byte *dst = bgbak_ptr;
+ byte *src = smap_ptr;
+ byte color = 0, data = 0;
+ int run = 1;
+ bool dither = false;
+ byte dither_table[128];
+ byte *ptr_dither_table;
+ memset(dither_table, 0, sizeof(dither_table));
+ int theX, theY;
+
+ // Draw image data. To do this, we decode the full RLE graphics data,
+ // but only draw those parts we actually want to display.
+ assert(height <= 128);
+ for (theX = 0; theX < width; theX++) {
+ ptr_dither_table = dither_table;
+ for (theY = 0; theY < height; theY++) {
+ if (--run == 0) {
+ data = *src++;
+ if (data & 0x80) {
+ run = data & 0x7f;
+ dither = true;
+ } else {
+ run = data >> 4;
+ dither = false;
+ }
+ if (run == 0) {
+ run = *src++;
+ }
+ color = data & 0x0f;
+ }
+ if (!dither) {
+ *ptr_dither_table = color;
+ }
+ if (left <= theX && theX < right) {
+ *dst = *ptr_dither_table++;
+ dst += _vm->_realWidth;
+ }
+ }
+ if (left <= theX && theX < right) {
+ dst -= _vm->_realWidth * height;
+ dst++;
+ }
+ }
+
+/*
+ // Draw mask (zplane) data
+ // TODO - this code is right now completely bogus, will implement it correctly later
+ theY = 0;
+ theX = 0;
+
+ for (;;) {
+ run = *src++;
+ if (run & 0x80) {
+ run &= 0x7f;
+ data = *src++;
+ do {
+ if (left <= theX && theX < right) {
+ *_mask_ptr = data;
+ _mask_ptr += _numStrips;
+ }
+ theY++;
+ if (theY >= height) {
+ theX++;
+ if (theX >= (width >> 3))
+ goto finish_v2;
+ theY = 0;
+ if (left <= theX && theX < right)
+ _mask_ptr -= _numStrips * height - 1;
+ }
+ } while (--run);
+ } else {
+ do {
+ data = *src++;
+
+ if (left <= theX && theX < right) {
+ *_mask_ptr = data;
+ _mask_ptr += _numStrips;
+ }
+ theY++;
+ if (theY >= height) {
+ theX++;
+ if (theX >= width)
+ goto finish_v2;
+ theY = 0;
+ if (left <= theX && theX < right)
+ _mask_ptr -= _numStrips * height - 1;
+ }
+ } while (--run);
+ }
+ }
+
+finish_v2:
+*/
+ // Update tdirty / bdirty
+ while (numstrip--) {
+ if (sx < 0)
+ goto next_iter_v2;
+
+ if (sx >= _numStrips) {
+ return;
+ }
+
+ if (y < vs->tdirty[sx])
+ vs->tdirty[sx] = y;
+
+ if (bottom > vs->bdirty[sx])
+ vs->bdirty[sx] = bottom;
+
+ CHECK_HEAP;
+ if (vs->alloctwobuffers) {
+ backbuff_ptr = vs->screenPtr + (y * _numStrips + x) * 8;
+ bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * _numStrips + x) * 8;
+ _mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + (y * _numStrips + x);
+
+ if (_vm->hasCharsetMask(sx << 3, y, (sx + 1) << 3, bottom)) {
+ if (flag & dbClear || !lightsOn)
+ clear8ColWithMasking(backbuff_ptr, height, _mask_ptr);
+ else
+ draw8ColWithMasking(backbuff_ptr, bgbak_ptr, height, _mask_ptr);
+ } else {
+ if (flag & dbClear || !lightsOn)
+ clear8Col(backbuff_ptr, height);
+ else
+ draw8Col(backbuff_ptr, bgbak_ptr, height);
+ }
+ }
+next_iter_v2:
+ CHECK_HEAP;
+ x++;
+ sx++;
+ stripnr++;
+ }
+
+
+ // Get outa here
+ return;
}
+
+ //////
+ //////
+ ////// END OF BIG HACK!
+ //////
+ //////
+
while (numstrip--) {
CHECK_HEAP;