From cf12e0499752f9607b50a05d465e1921eaabc242 Mon Sep 17 00:00:00 2001 From: Bertrand Augereau Date: Wed, 22 Jun 2011 23:11:44 +0200 Subject: DREAMWEB: frameoutv becomes a native function --- devtools/tasmrecover/tasm-recover | 3 ++- engines/dreamweb/dreamgen.cpp | 47 --------------------------------------- engines/dreamweb/stubs.cpp | 22 ++++++++++++++++++ 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index 96fd6c45fa..d6c6a2523f 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -22,6 +22,7 @@ generator = cpp(context, "DreamGen", blacklist = [ 'width160', 'convertkey', 'readabyte', - 'readoneblock' + 'readoneblock', + 'frameoutv' ]) generator.generate('dreamweb') #start routine diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index da0d71f7fe..462ae596f8 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -4329,52 +4329,6 @@ noeffects: cx = pop(); } -void DreamGenContext::frameoutv() { - STACK_CHECK; - push(dx); - ax = bx; - bx = dx; - _mul(bx); - _add(di, ax); - dx = pop(); - push(cx); - ch = 0; - _sub(dx, cx); - cx = pop(); -frameloop1: - push(cx); - ch = 0; -frameloop2: - _lodsb(); - _cmp(al, 0); - if (!flags.z()) - goto backtosolid; -backtoother: - _inc(di); - if (--cx) - goto frameloop2; - cx = pop(); - _add(di, dx); - _dec(ch); - if (!flags.z()) - goto frameloop1; - return; -frameloop3: - _lodsb(); - _cmp(al, 0); - if (flags.z()) - goto backtoother; -backtosolid: - _stosb(); - if (--cx) - goto frameloop3; - cx = pop(); - _add(di, dx); - _dec(ch); - if (!flags.z()) - goto frameloop1; -} - void DreamGenContext::frameoutbh() { STACK_CHECK; push(dx); @@ -22126,7 +22080,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) { case 0xc214: delthisone(); break; case 0xc228: doblocks(); break; case 0xc22c: showframe(); break; - case 0xc230: frameoutv(); break; case 0xc238: frameoutbh(); break; case 0xc23c: frameoutfx(); break; case 0xc240: transferinv(); break; diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index eebfbeb0d4..1869f1b109 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -503,4 +503,26 @@ void DreamGenContext::showpcx() { pcxFile.close(); } +void DreamGenContext::frameoutv() { + uint16 pitch = dx; + uint16 width = cx & 0xff; + uint16 height = cx >> 8; + uint16 stride = pitch - width; + + const uint8* src = ds.ptr(si, width * height); + uint8* base = es.ptr(di, stride * height); + uint8* dst = base + pitch * bx; + + // NB: Original code assumes non-zero width and height, "for" are unneeded, do-while would suffice but would be less readable + for (uint16 y = 0; y < height; ++y) { + for (uint16 x = 0; x < width; ++x) { + uint8 pixel = *src++; + if (pixel) + *dst = pixel; + ++dst; + } + dst += stride; + } +} + } /*namespace dreamgen */ -- cgit v1.2.3