aboutsummaryrefslogtreecommitdiff
path: root/shell/scalers
diff options
context:
space:
mode:
authorgameblabla2020-12-26 08:53:03 +0100
committergameblabla2020-12-26 08:53:03 +0100
commit2c41876dd9913c2a49cd044a805df54915b95f0f (patch)
treee04b3f224a90c217289c49b84129faac19bf1248 /shell/scalers
parent4c1a193d483b10ef63c27553f6e6e95af23552b8 (diff)
downloadsnesemu-2c41876dd9913c2a49cd044a805df54915b95f0f.tar.gz
snesemu-2c41876dd9913c2a49cd044a805df54915b95f0f.tar.bz2
snesemu-2c41876dd9913c2a49cd044a805df54915b95f0f.zip
Fix issue wit pitch being doubled by 2.
Change all of the code accordingly and simplify it. This was made as to allocate less memory than needed, improve the speed of the scaler code and make it more suitable for IPU mode.
Diffstat (limited to 'shell/scalers')
-rw-r--r--shell/scalers/scaler.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/shell/scalers/scaler.c b/shell/scalers/scaler.c
index 3aeea05..81644aa 100644
--- a/shell/scalers/scaler.c
+++ b/shell/scalers/scaler.c
@@ -39,7 +39,7 @@ void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* re
uint16_t* BlockDst;
for (BlockY = 0; BlockY < height; BlockY++)
{
- BlockSrc = Src16 + BlockY * 512 * 1;
+ BlockSrc = Src16 + BlockY * width * 1;
BlockDst = Dst16 + BlockY * 320 * 1;
for (BlockX = 0; BlockX < 64; BlockX++)
{
@@ -69,15 +69,15 @@ void upscale_256x240_to_320x240_bilinearish(uint32_t* restrict dst, uint32_t* re
void upscale_256xXXX_to_320x240(uint32_t* restrict dst, uint32_t* restrict src, uint_fast16_t width, uint_fast16_t height)
{
- uint_fast16_t midh = 240;
- uint_fast16_t Eh = 0;
- uint_fast16_t source = 0;
- uint_fast16_t dh = 0;
- uint_fast8_t y, x;
+ uint32_t midh = 240 / 2;
+ uint32_t Eh = 0;
+ uint32_t source;
+ uint32_t dh = 0;
+ uint32_t y, x;
for (y = 0; y < 240; y++)
{
- source = dh * width;
+ source = dh * 256 / 2;
for (x = 0; x < 320/10; x++)
{
@@ -91,12 +91,11 @@ void upscale_256xXXX_to_320x240(uint32_t* restrict dst, uint32_t* restrict src,
ef = src[source + 2] & 0xF7DEF7DE;
gh = src[source + 3] & 0xF7DEF7DE;
- if(Eh >= midh)
- {
- ab = AVERAGE(ab, src[source + width/2]) & 0xF7DEF7DE; // to prevent overflow
- cd = AVERAGE(cd, src[source + width/2 + 1]) & 0xF7DEF7DE; // to prevent overflow
- ef = AVERAGE(ef, src[source + width/2 + 2]) & 0xF7DEF7DE; // to prevent overflow
- gh = AVERAGE(gh, src[source + width/2 + 3]) & 0xF7DEF7DE; // to prevent overflow
+ if(Eh >= midh) {
+ ab = AVERAGE(ab, src[source + 256/2]) & 0xF7DEF7DE; // to prevent overflow
+ cd = AVERAGE(cd, src[source + 256/2 + 1]) & 0xF7DEF7DE; // to prevent overflow
+ ef = AVERAGE(ef, src[source + 256/2 + 2]) & 0xF7DEF7DE; // to prevent overflow
+ gh = AVERAGE(gh, src[source + 256/2 + 3]) & 0xF7DEF7DE; // to prevent overflow
}
*dst++ = ab;