aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/ds/arm9/source
diff options
context:
space:
mode:
authorBertrand Augereau2006-12-09 13:20:11 +0000
committerBertrand Augereau2006-12-09 13:20:11 +0000
commit12f6bd37eaf6812fede3843b2110ea066fc90e49 (patch)
tree50142eeadaa34b1e69edb170750340aa417ee4b2 /backends/platform/ds/arm9/source
parent8fb811bb0a8982c177b7bcac990c80c3d396f92d (diff)
downloadscummvm-rg350-12f6bd37eaf6812fede3843b2110ea066fc90e49.tar.gz
scummvm-rg350-12f6bd37eaf6812fede3843b2110ea066fc90e49.tar.bz2
scummvm-rg350-12f6bd37eaf6812fede3843b2110ea066fc90e49.zip
NDS : More blitters stuff
svn-id: r24818
Diffstat (limited to 'backends/platform/ds/arm9/source')
-rw-r--r--backends/platform/ds/arm9/source/blitters.cpp90
1 files changed, 77 insertions, 13 deletions
diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp
index 4ae7a3c599..04f0742b35 100644
--- a/backends/platform/ds/arm9/source/blitters.cpp
+++ b/backends/platform/ds/arm9/source/blitters.cpp
@@ -225,20 +225,86 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3
((u32*)dest)[1] = d32;
}
+static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3, u32 s4,
+ u16* dest)
+{
+ u32 bs0 = s0 & 0xFF;
+ u32 bs1 = s1 & 0xFF;
+ u32 bs2 = s2 & 0xFF;
+ u32 bs3 = s3 & 0xFF;
+ u32 bs4 = s4 & 0xFF;
+
+ u32 gs0 = (s0 >> 8) & 0xFF;
+ u32 gs1 = (s1 >> 8) & 0xFF;
+ u32 gs2 = (s2 >> 8) & 0xFF;
+ u32 gs3 = (s3 >> 8) & 0xFF;
+ u32 gs4 = (s4 >> 8) & 0xFF;
+
+ u32 rs0 = (s0 >> 16) & 0xFF;
+ u32 rs1 = (s1 >> 16) & 0xFF;
+ u32 rs2 = (s2 >> 16) & 0xFF;
+ u32 rs3 = (s3 >> 16) & 0xFF;
+ u32 rs4 = (s4 >> 16) & 0xFF;
+
+ u32 rd0 = 4*rs0 + rs1;
+ u32 rd1 = 2*rs1 + rs1 + 2*rs2;
+ u32 rd2 = 2*rs2 + 2*rs3 + rs3;
+ u32 rd3 = rs3 + 4*rs4;
+
+ u32 gd0 = 4*gs0 + gs1;
+ u32 gd1 = 2*gs1 + gs1 + 2*gs2;
+ u32 gd2 = 2*gs2 + 2*gs3 + gs3;
+ u32 gd3 = gs3 + 4*gs4;
+
+ u32 bd0 = 4*bs0 + bs1;
+ u32 bd1 = 2*bs1 + bs1 + 2*bs2;
+ u32 bd2 = 2*bs2 + 2*bs3 + bs3;
+ u32 bd3 = bs3 + 4*bs4;
+
+#if 0
+ // 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 = (rd0 * 51) >> 9; rd1 = (rd1 * 51) >> 9; rd2 = (rd2 * 51) >> 9; rd3 = (rd3 * 51) >> 9;
+ gd0 = (gd0 * 51) >> 9; gd1 = (gd1 * 51) >> 9; gd2 = (gd2 * 51) >> 9; gd3 = (gd3 * 51) >> 9;
+ bd0 = (bd0 * 51) >> 9; bd1 = (bd1 * 51) >> 9; bd2 = (bd2 * 51) >> 9; bd3 = (bd3 * 51) >> 9;
+#else
+ rd0 = DIV_BY_5[rd0]; rd1 = DIV_BY_5[rd1]; rd2 = DIV_BY_5[rd2]; rd3 = DIV_BY_5[rd3];
+ gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1]; gd2 = DIV_BY_5[gd2]; gd3 = DIV_BY_5[gd3];
+ bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1]; bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3];
+#endif
+
+ u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0;
+ u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2;
+
+ ((u32*)dest)[0] = d10;
+ ((u32*)dest)[1] = d32;
+}
+
+inline u32 Convert555To8888(u16 pixel)
+{
+ u32 result = pixel & 0x1F;
+ result |= ((pixel >> 5) & 0x1F) << 8;
+ result |= ((pixel >> 10) & 0x1F) << 16;
+ return result;
+}
+
// Can't work in place
-void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u16* palette)
+void Rescale_320xPAL8Scanline_To_256x1555Scanline(u16* dest, const u8* src, const u32* palette)
{
ComputeDivBy5TableIFN();
for(size_t i=0; i<64; ++i)
{
- u16 s0 = palette[src[5*i+0]];
- u16 s1 = palette[src[5*i+1]];
- u16 s2 = palette[src[5*i+2]];
- u16 s3 = palette[src[5*i+3]];
- u16 s4 = palette[src[5*i+4]];
+ u32 s0 = palette[src[5*i+0]];
+ u32 s1 = palette[src[5*i+1]];
+ u32 s2 = palette[src[5*i+2]];
+ u32 s3 = palette[src[5*i+3]];
+ u32 s4 = palette[src[5*i+4]];
- RescaleBlock_5x1555_To_4x1555(s0, s1, s2, s3, s4, dest+4*i);
+ RescaleBlock_5x8888_To_4x1555(s0, s1, s2, s3, s4, dest+4*i);
}
}
@@ -262,15 +328,13 @@ void Rescale_320x1555Scanline_To_256x1555Scanline(u16* dest, const u16* src)
void Rescale_320x256xPAL8_To_256x256x1555(u16* dest, const u8* src, const u16* palette, int destStride, int srcStride)
{
- /*
- u16* fastRam = (u16 *) (0x37F8000 + 16384);
-
- memcpy(fastRam, palette, 256 * 2);
- */
+ u32* fastRam = (u32 *) (0x37F8000 + 16384);
+ for(size_t i=0; i<256; ++i)
+ fastRam[i] = Convert555To8888(palette[i]);
for(size_t i=0; i<200; ++i)
{
- Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, palette);
+ Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam);
}
}