VOGONS


First post, by Tobis87

User metadata
Rank Newbie
Rank
Newbie

Hi,

I tried to get some 4x scalers working, but as Wikipedia says: "The AdvMAME4×/Scale4× algorithm is just EPX applied twice to get 4× resolution."

My problem is, that I don't know how to let dosbox run a scaler twice. So I tried to get as near as possible to the advmame4x scaler in one pass.

I know it is not official, but X-wing already looks great with it! 😁

Update: Screenshots attached

Update2: Patch simplified

diff -urN dosbox-0.73/src/dosbox.cpp dosbox-0.73/src/dosbox.cpp
--- dosbox-0.73/src/dosbox.cpp 2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/dosbox.cpp 2010-01-19 11:56:25.387344693 +0100
@@ -378,9 +378,9 @@
Pstring = Pmulti->GetSection()->Add_string("type",Property::Changeable::Always,"normal2x");

const char *scalers[] = {
- "none", "normal2x", "normal3x",
+ "none", "normal2x", "normal3x", "normal4x",
#if RENDER_USE_ADVANCED_SCALERS>2
- "advmame2x", "advmame3x", "advinterp2x", "advinterp3x", "hq2x", "hq3x", "2xsai", "super2xsai", "supereagle",
+ "advmame2x", "advmame3x", "advmame4x", "advinterp2x", "advinterp3x", "advinterp4x", "hq2x", "hq3x", "2xsai", "super2xsai", "supereagle",
#endif
#if RENDER_USE_ADVANCED_SCALERS>0
"tv2x", "tv3x", "rgb2x", "rgb3x", "scan2x", "scan3x",
diff -urN dosbox-0.73/src/gui/render.cpp dosbox-0.73/src/gui/render.cpp
--- dosbox-0.73/src/gui/render.cpp 2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/gui/render.cpp 2010-01-19 11:58:59.469013482 +0100
@@ -288,6 +288,8 @@
simpleBlock = &ScaleNormal2x;
else if (render.scale.size == 3)
simpleBlock = &ScaleNormal3x;
+ else if (render.scale.size == 4)
+ simpleBlock = &ScaleNormal4x;
else
simpleBlock = &ScaleNormal1x;
/* Maybe override them */
@@ -299,12 +301,16 @@
complexBlock = &ScaleAdvInterp2x;
else if (render.scale.size == 3)
complexBlock = &ScaleAdvInterp3x;
+ else if (render.scale.size == 4)
+ complexBlock = &ScaleAdvInterp4x;
break;
case scalerOpAdvMame:
if (render.scale.size == 2)
complexBlock = &ScaleAdvMame2x;
else if (render.scale.size == 3)
complexBlock = &ScaleAdvMame3x;
+ else if (render.scale.size == 4)
+ complexBlock = &ScaleAdvMame4x;
break;
case scalerOpHQ:
if (render.scale.size == 2)
@@ -597,11 +603,14 @@
if (scaler == "none") { render.scale.op = scalerOpNormal;render.scale.size = 1; }
else if (scaler == "normal2x") { render.scale.op = scalerOpNormal;render.scale.size = 2; }
else if (scaler == "normal3x") { render.scale.op = scalerOpNormal;render.scale.size = 3; }
+ else if (scaler == "normal4x") { render.scale.op = scalerOpNormal;render.scale.size = 4; }
#if RENDER_USE_ADVANCED_SCALERS>2
else if (scaler == "advmame2x") { render.scale.op = scalerOpAdvMame;render.scale.size = 2; }
else if (scaler == "advmame3x") { render.scale.op = scalerOpAdvMame;render.scale.size = 3; }
+ else if (scaler == "advmame4x") { render.scale.op = scalerOpAdvMame;render.scale.size = 4; }
else if (scaler == "advinterp2x") { render.scale.op = scalerOpAdvInterp;render.scale.size = 2; }
else if (scaler == "advinterp3x") { render.scale.op = scalerOpAdvInterp;render.scale.size = 3; }
+ else if (scaler == "advinterp4x") { render.scale.op = scalerOpAdvInterp;render.scale.size = 4; }
else if (scaler == "hq2x") { render.scale.op = scalerOpHQ;render.scale.size = 2; }
else if (scaler == "hq3x") { render.scale.op = scalerOpHQ;render.scale.size = 3; }
else if (scaler == "2xsai") { render.scale.op = scalerOpSaI;render.scale.size = 2; }
diff -urN dosbox-0.73/src/gui/render_loops.h dosbox-0.73/src/gui/render_loops.h
Show last 334 lines
--- dosbox-0.73/src/gui/render_loops.h	2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/gui/render_loops.h 2010-01-19 11:55:13.982380988 +0100
@@ -51,6 +51,9 @@
#if (SCALERHEIGHT > 2)
PTYPE * line2;
#endif
+#if (SCALERHEIGHT > 3)
+ PTYPE * line3;
+#endif
/* Clear this block being dirty marker */
const Bitu changeType = changed[b];
changed[b] = 0;
@@ -66,6 +69,9 @@
#if (SCALERHEIGHT > 2)
line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
#endif
+#if (SCALERHEIGHT > 3)
+ line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
+#endif
SCALERFUNC;
line0 += SCALERWIDTH * SCALER_BLOCKSIZE;
fc += SCALER_BLOCKSIZE;
@@ -77,6 +83,9 @@
#if (SCALERHEIGHT > 2)
line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
#endif
+#if (SCALERHEIGHT > 3)
+ line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
+#endif
SCALERFUNC;
case SCALE_RIGHT:
#if (SCALERHEIGHT > 1)
@@ -85,6 +94,9 @@
#if (SCALERHEIGHT > 2)
line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
#endif
+#if (SCALERHEIGHT > 3)
+ line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
+#endif
line0 += SCALERWIDTH * (SCALER_BLOCKSIZE -1);
#if (SCALERHEIGHT > 1)
line1 += SCALERWIDTH * (SCALER_BLOCKSIZE -1);
@@ -92,6 +104,9 @@
#if (SCALERHEIGHT > 2)
line2 += SCALERWIDTH * (SCALER_BLOCKSIZE -1);
#endif
+#if (SCALERHEIGHT > 3)
+ line3 += SCALERWIDTH * (SCALER_BLOCKSIZE -1);
+#endif
fc += SCALER_BLOCKSIZE -1;
SCALERFUNC;
line0 += SCALERWIDTH;
@@ -105,6 +120,9 @@
#if (SCALERHEIGHT > 2)
line2 = WC[1];
#endif
+#if (SCALERHEIGHT > 3)
+ line3 = WC[2];
+#endif
#else
#if (SCALERHEIGHT > 1)
line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch);
@@ -112,6 +130,9 @@
#if (SCALERHEIGHT > 2)
line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
#endif
+#if (SCALERHEIGHT > 3)
+ line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
+#endif
#endif //defined(SCALERLINEAR)
for (Bitu i = 0; i<SCALER_BLOCKSIZE;i++) {
SCALERFUNC;
@@ -122,6 +143,9 @@
#if (SCALERHEIGHT > 2)
line2 += SCALERWIDTH;
#endif
+#if (SCALERHEIGHT > 3)
+ line3 += SCALERWIDTH;
+#endif
fc++;
}
#if defined(SCALERLINEAR)
@@ -131,6 +155,9 @@
#if (SCALERHEIGHT > 2)
BituMove((Bit8u*)(&line0[-SCALER_BLOCKSIZE*SCALERWIDTH])+render.scale.outPitch*2,WC[1], SCALER_BLOCKSIZE *SCALERWIDTH*PSIZE);
#endif
+#if (SCALERHEIGHT > 3)
+ BituMove((Bit8u*)(&line0[-SCALER_BLOCKSIZE*SCALERWIDTH])+render.scale.outPitch*3,WC[2], SCALER_BLOCKSIZE *SCALERWIDTH*PSIZE);
+#endif
#endif //defined(SCALERLINEAR)
break;
}
diff -urN dosbox-0.73/src/gui/render_scalers.cpp dosbox-0.73/src/gui/render_scalers.cpp
--- dosbox-0.73/src/gui/render_scalers.cpp 2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/gui/render_scalers.cpp 2010-01-19 12:02:29.860881690 +0100
@@ -256,6 +256,23 @@
{ Normal3x_8_8_R, Normal3x_9_15_R , Normal3x_9_16_R , Normal3x_9_32_R }
}};

+ ScalerSimpleBlock_t ScaleNormal4x = {
+ "Normal4x",
+ GFX_CAN_8|GFX_CAN_15|GFX_CAN_16|GFX_CAN_32,
+ 4,4,{
+{ Normal4x_8_8_L, Normal4x_8_15_L , Normal4x_8_16_L , Normal4x_8_32_L },
+{ 0, Normal4x_15_15_L, Normal4x_15_16_L, Normal4x_15_32_L},
+{ 0, Normal4x_16_15_L, Normal4x_16_16_L, Normal4x_16_32_L},
+{ 0, Normal4x_32_15_L, Normal4x_32_16_L, Normal4x_32_32_L},
+{ Normal4x_8_8_L, Normal4x_9_15_L , Normal4x_9_16_L , Normal4x_9_32_L }
+},{
+{ Normal4x_8_8_R, Normal4x_8_15_R , Normal4x_8_16_R , Normal4x_8_32_R },
+{ 0, Normal4x_15_15_R, Normal4x_15_16_R, Normal4x_15_32_R},
+{ 0, Normal4x_16_15_R, Normal4x_16_16_R, Normal4x_16_32_R},
+{ 0, Normal4x_32_15_R, Normal4x_32_16_R, Normal4x_32_32_R},
+{ Normal4x_8_8_R, Normal4x_9_15_R , Normal4x_9_16_R , Normal4x_9_32_R }
+}};
+
#if RENDER_USE_ADVANCED_SCALERS>0
ScalerSimpleBlock_t ScaleTV2x = {
"TV2x",
@@ -380,6 +397,14 @@
{ AdvMame3x_8_R,AdvMame3x_16_R,AdvMame3x_16_R,AdvMame3x_32_R}
};

+ScalerComplexBlock_t ScaleAdvMame4x = {
+ "AdvMame4x",
+ GFX_CAN_8|GFX_CAN_15|GFX_CAN_16|GFX_CAN_32,
+ 4,4,
+{ AdvMame4x_8_L,AdvMame4x_16_L,AdvMame4x_16_L,AdvMame4x_32_L},
+{ AdvMame4x_8_R,AdvMame4x_16_R,AdvMame4x_16_R,AdvMame4x_32_R}
+};
+
/* These need specific 15bpp versions */
ScalerComplexBlock_t ScaleHQ2x ={
"HQ2x",
@@ -437,4 +462,12 @@
{ 0,AdvInterp3x_15_R,AdvInterp3x_16_R,AdvInterp3x_32_R}
};

+ScalerComplexBlock_t ScaleAdvInterp4x = {
+ "AdvInterp4x",
+ GFX_CAN_15|GFX_CAN_16|GFX_CAN_32|GFX_RGBONLY,
+ 4,4,
+{ 0,AdvInterp4x_15_L,AdvInterp4x_16_L,AdvInterp4x_32_L},
+{ 0,AdvInterp4x_15_R,AdvInterp4x_16_R,AdvInterp4x_32_R}
+};
+
#endif
diff -urN dosbox-0.73/src/gui/render_scalers.h dosbox-0.73/src/gui/render_scalers.h
--- dosbox-0.73/src/gui/render_scalers.h 2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/gui/render_scalers.h 2010-01-19 12:03:28.170822333 +0100
@@ -113,6 +113,7 @@
extern ScalerSimpleBlock_t ScaleNormalDh;
extern ScalerSimpleBlock_t ScaleNormal2x;
extern ScalerSimpleBlock_t ScaleNormal3x;
+extern ScalerSimpleBlock_t ScaleNormal4x;
#if RENDER_USE_ADVANCED_SCALERS>0
extern ScalerSimpleBlock_t ScaleTV2x;
extern ScalerSimpleBlock_t ScaleTV3x;
@@ -130,8 +131,10 @@
extern ScalerComplexBlock_t ScaleSuperEagle;
extern ScalerComplexBlock_t ScaleAdvMame2x;
extern ScalerComplexBlock_t ScaleAdvMame3x;
+extern ScalerComplexBlock_t ScaleAdvMame4x;
extern ScalerComplexBlock_t ScaleAdvInterp2x;
extern ScalerComplexBlock_t ScaleAdvInterp3x;
+extern ScalerComplexBlock_t ScaleAdvInterp4x;
#endif
#if RENDER_USE_ADVANCED_SCALERS>1
extern ScalerLineBlock_t ScalerCache;
diff -urN dosbox-0.73/src/gui/render_simple.h dosbox-0.73/src/gui/render_simple.h
--- dosbox-0.73/src/gui/render_simple.h 2009-05-27 11:15:41.000000000 +0200
+++ dosbox-0.73/src/gui/render_simple.h 2010-01-19 11:55:13.982380988 +0100
@@ -68,6 +68,9 @@
#if (SCALERHEIGHT > 2)
PTYPE *line2 = WC[1];
#endif
+#if (SCALERHEIGHT > 3)
+ PTYPE *line3 = WC[2];
+#endif
#else
#if (SCALERHEIGHT > 1)
PTYPE *line1 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch);
@@ -75,6 +78,9 @@
#if (SCALERHEIGHT > 2)
PTYPE *line2 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 2);
#endif
+#if (SCALERHEIGHT > 3)
+ PTYPE *line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
+#endif
#endif //defined(SCALERLINEAR)
hadChange = 1;
for (Bitu i = x > 32 ? 32 : x;i>0;i--,x--) {
@@ -90,6 +96,9 @@
#if (SCALERHEIGHT > 2)
line2 += SCALERWIDTH;
#endif
+#if (SCALERHEIGHT > 3)
+ line3 += SCALERWIDTH;
+#endif
}
#if defined(SCALERLINEAR)
#if (SCALERHEIGHT > 1)
@@ -99,6 +108,9 @@
#if (SCALERHEIGHT > 2)
BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*2,WC[1], copyLen );
#endif
+#if (SCALERHEIGHT > 3)
+ BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*3,WC[2], copyLen );
+#endif
#endif //defined(SCALERLINEAR)
}
}
diff -urN dosbox-0.73/src/gui/render_templates.h dosbox-0.73/src/gui/render_templates.h
--- dosbox-0.73/src/gui/render_templates.h 2009-05-25 20:44:46.000000000 +0200
+++ dosbox-0.73/src/gui/render_templates.h 2010-01-19 13:52:18.048640601 +0100
@@ -257,6 +257,32 @@
#undef SCALERHEIGHT
#undef SCALERFUNC

+#define SCALERNAME Normal4x
+#define SCALERWIDTH 4
+#define SCALERHEIGHT 4
+#define SCALERFUNC \
+ line0[0] = P; \
+ line0[1] = P; \
+ line0[2] = P; \
+ line0[3] = P; \
+ line1[0] = P; \
+ line1[1] = P; \
+ line1[2] = P; \
+ line1[3] = P; \
+ line2[0] = P; \
+ line2[1] = P; \
+ line2[2] = P; \
+ line2[3] = P; \
+ line3[0] = P; \
+ line3[1] = P; \
+ line3[2] = P; \
+ line3[3] = P;
+#include "render_simple.h"
+#undef SCALERNAME
+#undef SCALERWIDTH
+#undef SCALERHEIGHT
+#undef SCALERFUNC
+
#define SCALERNAME NormalDw
#define SCALERWIDTH 2
#define SCALERHEIGHT 1
@@ -508,6 +534,44 @@
#undef SCALERHEIGHT
#undef SCALERFUNC

+#define SCALERNAME AdvInterp4x
+#define SCALERWIDTH 4
+#define SCALERHEIGHT 4
+#define SCALERFUNC \
+ if ((C1 != C7) && (C3 != C5)) { \
+ line0[0] = C3 == C1 ? interp_w2(C3,C4,5U,3U) : C4; \
+ line0[3] = C1 == C5 ? interp_w2(C5,C4,5U,3U) : C4; \
+ line1[1] = C4; \
+ line1[2] = C4; \
+ line2[1] = C4; \
+ line2[2] = C4; \
+ line3[0] = C3 == C7 ? interp_w2(C3,C4,5U,3U) : C4; \
+ line3[3] = C7 == C5 ? interp_w2(C5,C4,5U,3U) : C4; \
+ line0[1] = line0[0]; \
+ line0[2] = line0[3]; \
+ line1[0] = line0[0]; \
+ line1[3] = line0[3]; \
+ line2[0] = line3[0]; \
+ line2[3] = line3[3]; \
+ line3[1] = line3[0]; \
+ line3[2] = line3[3]; \
+ line0[0] = line0[0] != C4 ? interp_w2(C3,line0[0],5U,3U) : line0[0]; \
+ line0[3] = line0[3] != C4 ? interp_w2(C5,line0[3],5U,3U) : line0[3]; \
+ line3[0] = line3[0] != C4 ? interp_w2(C3,line3[0],5U,3U) : line3[0]; \
+ line3[3] = line3[3] != C4 ? interp_w2(C5,line3[3],5U,3U) : line3[3]; \
+ } else { \
+ line0[0] = line0[1] = line0[2] = line0[3] = C4; \
+ line1[0] = line1[1] = line1[2] = line1[3] = C4; \
+ line2[0] = line2[1] = line2[2] = line2[3] = C4; \
+ line3[0] = line3[1] = line3[2] = line3[3] = C4; \
+ }
+
+#include "render_loops.h"
+#undef SCALERNAME
+#undef SCALERWIDTH
+#undef SCALERHEIGHT
+#undef SCALERFUNC
+
#endif // #if (DBPP > 8)

#define SCALERNAME AdvMame2x
@@ -555,6 +619,39 @@
#undef SCALERHEIGHT
#undef SCALERFUNC

+#define SCALERNAME AdvMame4x
+#define SCALERWIDTH 4
+#define SCALERHEIGHT 4
+#define SCALERFUNC \
+ if ((C1 != C7) && (C3 != C5)) { \
+ line0[0] = C3 == C1 ? C3 : C4; \
+ line0[3] = C5 == C1 ? C5 : C4; \
+ line1[1] = C4; \
+ line1[2] = C4; \
+ line2[1] = C4; \
+ line2[2] = C4; \
+ line3[0] = C3 == C7 ? C3 : C4; \
+ line3[3] = C5 == C7 ? C5 : C4; \
+ line0[1] = line0[0]; \
+ line0[2] = line0[3]; \
+ line1[0] = line0[0]; \
+ line1[3] = line0[3]; \
+ line2[0] = line3[0]; \
+ line2[3] = line3[3]; \
+ line3[1] = line3[0]; \
+ line3[2] = line3[3]; \
+ } else { \
+ line0[0] = line0[1] = line0[2] = line0[3] = C4; \
+ line1[0] = line1[1] = line1[2] = line1[3] = C4; \
+ line2[0] = line2[1] = line2[2] = line2[3] = C4; \
+ line3[0] = line3[1] = line3[2] = line3[3] = C4; \
+ }
+
+#include "render_loops.h"
+#undef SCALERNAME
+#undef SCALERWIDTH
+#undef SCALERHEIGHT
+#undef SCALERFUNC

#endif // (SBPP == DBPP) && !defined (CACHEWITHPAL)

Attachments

  • Filename
    Normal4x.jpg
    File size
    130.36 KiB
    Downloads
    167 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    Advmame4x.jpg
    File size
    154.05 KiB
    Downloads
    167 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    Advinterp4x.jpg
    File size
    149.76 KiB
    Downloads
    189 downloads
    File license
    Fair use/fair dealing exception
Last edited by Tobis87 on 2011-09-25, 21:23. Edited 5 times in total.

Reply 1 of 6, by Tobis87

User metadata
Rank Newbie
Rank
Newbie

In order to see what is still missing, I also attach screenshots of Monkey Island 2 with Dosbox scaled by Advinterp4x and ScummVM scaled by Advmame4x (also unofficial).

Attachments

  • Filename
    ScummVM Advmame4x.jpg
    File size
    285.72 KiB
    Downloads
    191 downloads
    File license
    Fair use/fair dealing exception
  • Filename
    Dosbox Advintrp4x.jpg
    File size
    275.58 KiB
    Downloads
    191 downloads
    File license
    Fair use/fair dealing exception

Reply 4 of 6, by Tobis87

User metadata
Rank Newbie
Rank
Newbie

your patch made everything german, this can't be good!

If my patch could make everything german, I would call it a feature. 😉

The algorithm is quite bloated, because I did find it mostly by messing around. I'm still surprised that it works that good.
Maybe someone has an idea how to simplify it.

I think nobody wants to implement advmame4x in their projects, because shortly after this is done, someone would want advmame8x for his home theater projector to be implemented.
But I like the idea from the wish list, of having a multiplier for the scaler setting:

# scaler -- Scaler used to enlarge/enhance low resolution modes.
# Supported are none,normal2x,advmame2x,advmame3x,advinterp2x,interp2x,tv2x.

scaler=advinterp2x
multiplier=2

Where the multiplier would be the number of times the scaler is applied.
Is something like this already planed?

Last edited by Tobis87 on 2010-01-26, 18:01. Edited 1 time in total.

Reply 6 of 6, by Tobis87

User metadata
Rank Newbie
Rank
Newbie

I thought that advmame4x was simply 2 times advmame2x applied

Yes, that's true.
But I don't know how to let dosbox apply a scaler 2 times.
So I tried to get as near as possible to the advmame4x.