aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorBertrand Augereau2006-10-02 18:41:39 +0000
committerBertrand Augereau2006-10-02 18:41:39 +0000
commit22756edd6f148ea98e6e71eb375641c07fe91c25 (patch)
tree90c0592448c5e73b6063ff40341ecc34bdbecab5 /backends/platform
parent9118a731dce8d0118f28e9a5d96f1feae519cdbd (diff)
downloadscummvm-rg350-22756edd6f148ea98e6e71eb375641c07fe91c25.tar.gz
scummvm-rg350-22756edd6f148ea98e6e71eb375641c07fe91c25.tar.bz2
scummvm-rg350-22756edd6f148ea98e6e71eb375641c07fe91c25.zip
NDS : Naive C++ scanline 320*16 -> 256*16 rescaler code
svn-id: r24074
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/ds/arm9/source/blitters.cpp66
-rw-r--r--backends/platform/ds/arm9/source/blitters.h1
2 files changed, 67 insertions, 0 deletions
diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp
index 1e954f5c9c..821fdd0b5a 100644
--- a/backends/platform/ds/arm9/source/blitters.cpp
+++ b/backends/platform/ds/arm9/source/blitters.cpp
@@ -134,4 +134,70 @@ void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height) {
: "r0", "%0", "%2", "%3");
}
+// Can work in place, because it's a contraction
+void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const u16* src)
+{
+ for(size_t i=0; i<64; ++i)
+ {
+ u16 s0 = src[5*i+0];
+ u16 s1 = src[5*i+1];
+ u16 s2 = src[5*i+2];
+ u16 s3 = src[5*i+3];
+ u16 s4 = src[5*i+4];
+
+ u16 rs0 = s0 & 0x1F;
+ u16 rs1 = s1 & 0x1F;
+ u16 rs2 = s2 & 0x1F;
+ u16 rs3 = s3 & 0x1F;
+ u16 rs4 = s4 & 0x1F;
+
+ u16 gs0 = (s0 >> 5) & 0x1F;
+ u16 gs1 = (s1 >> 5) & 0x1F;
+ u16 gs2 = (s2 >> 5) & 0x1F;
+ u16 gs3 = (s3 >> 5) & 0x1F;
+ u16 gs4 = (s4 >> 5) & 0x1F;
+
+ u16 bs0 = (s0 >> 10) & 0x1F;
+ u16 bs1 = (s1 >> 10) & 0x1F;
+ u16 bs2 = (s2 >> 10) & 0x1F;
+ u16 bs3 = (s3 >> 10) & 0x1F;
+ u16 bs4 = (s4 >> 10) & 0x1F;
+
+ u16 rd0 = 4*rs0 + rs1;
+ u16 rd1 = 3*rs1 + 2*rs2;
+ u16 rd2 = 2*rs2 + 3*rs3;
+ u16 rd3 = rs3 + 4*rs4;
+
+ u16 gd0 = 4*gs0 + gs1;
+ u16 gd1 = 3*gs1 + 2*gs2;
+ u16 gd2 = 2*gs2 + 3*gs3;
+ u16 gd3 = gs3 + 4*gs4;
+
+ u16 bd0 = 4*bs0 + bs1;
+ u16 bd1 = 3*bs1 + 2*bs2;
+ u16 bd2 = 2*bs2 + 3*bs3;
+ u16 bd3 = bs3 + 4*bs4;
+
+ // Offsetting for correct rounding
+ rd0 = rd0*2+5; rd1 = rd1*2+5; rd2 = rd2*2+5; rd3 = rd3*2+5;
+ gd0 = gd0*2+5; gd1 = gd1*2+5; gd2 = gd2*2+5; gd3 = gd3*2+5;
+ bd0 = bd0*2+5; bd1 = bd1*2+5; bd2 = bd2*2+5; bd3 = bd3*2+5;
+
+ rd0 /= 10; rd1 /= 10; rd2 /= 10; rd3 /= 10;
+ gd0 /= 10; gd1 /= 10; gd2 /= 10; gd3 /= 10;
+ bd0 /= 10; bd1 /= 10; bd2 /= 10; bd3 /= 10;
+
+ u16 d0 = 0x8000 | (bd0 << 10) | (gd0 << 5) | rd0;
+ u16 d1 = 0x8000 | (bd1 << 10) | (gd1 << 5) | rd1;
+ u16 d2 = 0x8000 | (bd2 << 10) | (gd2 << 5) | rd2;
+ u16 d3 = 0x8000 | (bd3 << 10) | (gd3 << 5) | rd3;
+
+ dest[4*i+0] = d0;
+ dest[4*i+1] = d1;
+ dest[4*i+2] = d2;
+ dest[4*i+3] = d3;
+ }
}
+
+}
+
diff --git a/backends/platform/ds/arm9/source/blitters.h b/backends/platform/ds/arm9/source/blitters.h
index c1252d2ed7..21c6279224 100644
--- a/backends/platform/ds/arm9/source/blitters.h
+++ b/backends/platform/ds/arm9/source/blitters.h
@@ -26,6 +26,7 @@ namespace DS {
void asmDrawStripToScreen(int height, int width, byte const* text, byte const* src, byte* dst,
int vsPitch, int vmScreenWidth, int textSurfacePitch);
void asmCopy8Col(byte* dst, int dstPitch, const byte* src, int height);
+void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const u16* src);
}