VOGONS


I might have accidentally implemented Normal4x.

Topic actions

  • This topic is locked. You cannot reply or edit posts.

First post, by Elamaton

User metadata
Rank Newbie
Rank
Newbie

This is going to sound a bit outlandish, but bear with me.

Earlier today at work I posted this thread: Scaling, aspect ratios and Normal4x revisited.

While driving home, I thought about my statement of "it can't be that hard", concerning implementing Normal4x. I have no C/C++ experience whatsoever (just PHP, Python, and some Java years ago), certainly nothing graphics-related, but just for the hell of it, I checked out the source from CVS and started looking at it.

Well, a hour and a half of grepping and copypasting later, I thought I'd download SDL to my Mac and try compiling DOSBox with my changes.

To my surprise, it compiled just fine.

To my even greater surprise, it ran just fine.

To my complete jaw-dropping amazement, the 4x scaling actually. Fucking. Worked.

This wasn't supposed to happen. The compilation was supposed to die at some point, or at least the software should have crashed violently. But no.

I verified the functionality with Tyrian with its 320x200 resolution, having this in the config file:

windowresolution=original
output=opengl
aspect=true
scaler=normal4x

And what do you know, I got a 1280x960 resolution. For fun, I set windowresolution=1280x960 and tried the various normal scalers, and yes, the 4x image was easily the sharpest. This is exactly what I was saying in the original thread. And I have screenshots of this experiment:

http://elamaton.no-ip.com:8080/dosbox/Normal3x.png
http://elamaton.no-ip.com:8080/dosbox/Normal4x.png

The difference should be quite obvious at least on a proper LCD screen. Flip back and forth those two, the difference is particularly visible in the text, especially the brighter-colored "Data".

Now, while I'm completely giddy at actually pulling this off and feeling good about myself, I must admit that the changes were not that hard. I'm not that smart. But if even I could manage them in an hour and a half, never having done any C++ and certainly never having looked at DOSBox's codebase before, I must express my amazement: why hasn't someone done this a long time ago? I mean, the feature request isn't actually new. And the changes were positively trivial. This is something a dev could have done during a coffee break.

I'm mostly being rhetorical. I'm sure there are valid reasons.

Anyway. Here's the output of cvs diff. The changes are naive and unassuming, and minimally tested, but tested anyway. You'll want to review them and clean them up. But after they've gone through whatever process you have for these sort of things, I would REALLY like to see Normal4x in the next release. Don't let their humble copy-pasted origins or their simian author put you off. I know people want this feature, and that's why I started the whole thing.

Cheers, and all the best to you.

Index: src/dosbox.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/dosbox.cpp,v
retrieving revision 1.137
diff -r1.137 dosbox.cpp
372c372
< "none", "normal2x", "normal3x",
---
> "none", "normal2x", "normal3x", "normal4x",
Index: src/gui/render.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render.cpp,v
retrieving revision 1.56
diff -r1.56 render.cpp
290a291,292
> else if (render.scale.size == 4)
> simpleBlock = &ScaleNormal4x;
553c555
< if(++render.scale.size > 3)
---
> if(++render.scale.size > 4)
591a594
> else if (scaler == "normal4x") { render.scale.op = scalerOpNormal;render.scale.size = 4; }
Index: src/gui/render_loops.h
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render_loops.h,v
retrieving revision 1.5
diff -r1.5 render_loops.h
53a54,56
> #if (SCALERHEIGHT > 3)
> PTYPE * line3;
> #endif
68a72,74
> #if (SCALERHEIGHT > 3)
> line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
> #endif
79a86,88
> #if (SCALERHEIGHT > 3)
> line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
> #endif
87a97,99
> #if (SCALERHEIGHT > 3)
> line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
> #endif
94a107,109
> #if (SCALERHEIGHT > 3)
> line3 += SCALERWIDTH * (SCALER_BLOCKSIZE -1);
> #endif
107a123,125
> #if (SCALERHEIGHT > 3)
> line3 = WC[2];
> #endif
114a133,135
> #if (SCALERHEIGHT > 3)
> line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
> #endif
124a146,148
> #if (SCALERHEIGHT > 3)
> line3 += SCALERWIDTH;
> #endif
Show last 88 lines
133a158,160
> #if (SCALERHEIGHT > 3)
> BituMove((Bit8u*)(&line0[-SCALER_BLOCKSIZE*SCALERWIDTH])+render.scale.outPitch*3,WC[2], SCALER_BLOCKSIZE *SCALERWIDTH*PSIZE);
> #endif
Index: src/gui/render_scalers.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render_scalers.cpp,v
retrieving revision 1.14
diff -r1.14 render_scalers.cpp
258a259,275
> 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 }
> }};
>
Index: src/gui/render_scalers.h
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render_scalers.h,v
retrieving revision 1.13
diff -r1.13 render_scalers.h
115a116
> extern ScalerSimpleBlock_t ScaleNormal4x;
Index: src/gui/render_simple.h
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render_simple.h,v
retrieving revision 1.5
diff -r1.5 render_simple.h
68a69,71
> #if (SCALERHEIGHT > 3)
> PTYPE *line3 = WC[2];
> #endif
75a79,81
> #if (SCALERHEIGHT > 3)
> PTYPE *line3 = (PTYPE *)(((Bit8u*)line0)+ render.scale.outPitch * 3);
> #endif
90a97,99
> #if (SCALERHEIGHT > 3)
> line3 += SCALERWIDTH;
> #endif
99a109,111
> #if (SCALERHEIGHT > 3)
> BituMove(((Bit8u*)line0)-copyLen+render.scale.outPitch*3,WC[2], copyLen );
> #endif
Index: src/gui/render_templates.h
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/gui/render_templates.h,v
retrieving revision 1.14
diff -r1.14 render_templates.h
259a260,285
> #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
>

Reply 1 of 26, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

I haven't looked at the code but the way features get into DOSBox is if there is an actual need for the feature. If there is no need then it does not get implemented.

It's hard to say exactly what the average monitor size that DOSBox users have but going by Valve's hardware survey most people have 1024x768 size monitors. This may be one among many of the reasons why 4x hasn't been implemented yet.

I'm sure the devs have a huge list of what needs to be in DOSBox and does not. The things most on top of the list are compatibility....extra features are towards the bottom. Extra features are usually implemented around the time when the official versions come out but only usually because a LOT of time has been spent on testing and finetuning those features.

How To Ask Questions The Smart Way
Make your games work offline

Reply 2 of 26, by leileilol

User metadata
Rank l33t++
Rank
l33t++
DosFreak wrote:

It's hard to say exactly what the average monitor size that DOSBox users have but going by Valve's hardware survey most people have 1024x768 size monitors. This may be one among many of the reasons why 4x hasn't been implemented yet.

well that's just valve's denizens
it didn't stop zsnes from having hq4x

apsosig.png
long live PCem

Reply 5 of 26, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

and how long has zsnes been out? Compatibility for NES/SNES games ceased to be an issue a long time ago. It could be argued that we're pretty close to the point where that's the same for DOSBox.

Anyways we all know that when 4x is implemented people will be bitching about why 8x hasn't been implemented because anyone that is a gamer and uses DOSBox runs their desktop at 2560x1600. 🙄 (By the way I run mine at 1920x1200) (I'm all for 4x scaler but as I mentioned above other issues probably have taken priority).

Last edited by DosFreak on 2008-05-22, 20:39. Edited 2 times in total.

How To Ask Questions The Smart Way
Make your games work offline

Reply 6 of 26, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I am reminded of the old saying "In for a penny, in for a pound."

Your view is a bit narrow when you say that it takes little time and effort to implement. While you may think it's acceptable to have a 4x version of the simple scaler without a 4x version of the other 2x/3x scalers, not everyone will think the same. Perhaps you noticed during your copypasting that those other types of scalers are not so simple.

Reply 7 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie
ripsaw8080 wrote:

Your view is a bit narrow when you say that it takes little time and effort to implement. While you may think it's acceptable to have a 4x version of the simple scaler without a 4x version of the other 2x/3x scalers, not everyone will think the same. Perhaps you noticed during your copypasting that those other types of scalers are not so simple.

Indeed I did. I could not begin to implement them. Also, it's very likely that my simple patch is missing something, and possible that it breaks something somewhere in some situations. Fortunately, I have no illusions of it getting into the codebase as-is.

But your view strikes me as odd, too. Having Normal4x does not take anything away from anybody. The old 3x advanced scalers will continue to function as before, and they'll surely eventually reach 4x. Only a spoiled child or a similarly immature adult whinebag would complain about a situation where someone else's needs are met before his/hers. They can (and should) be ignored. It's an imperfect world, and some features are inevitably completed before some other features are.

(Just to be clear, I'm not implying that you are a spoiled child. No insult intended.)

If someone doesn't have the patience to wait for a feature, then it's in the open source spirit that the impatient person produce a patch himself. That's what I did, so I can afford to shoot my mouth off for a bit. Now that I have done as convention dictates, my part has been played, and the issue is in more capable hands. If anyone whines about the other missing scalers, then they're free to try and implement them themselves, too.

Of course, if it's developer policy to only release new scaler multipliers when ALL scaling methods have them, then so be it. I might put that policy to question, but it's not my project. The devs shall do as they please.

(Okay, I lied about not beginning to implement them. I'm actually looking at AdvMame4x right now. Scan4x looks trivial. We'll see if anything comes out of this idle dabbling. Diffs will be posted, if I don't lose interest.)

Reply 8 of 26, by MiniMax

User metadata
Rank Moderator
Rank
Moderator
Elamaton wrote:

I must be getting old - I don't see a f....cking difference except the mouse-pointer jumping back and forth when I flip between the images using Firefox 2.x on a 1920 x 1200 LCD screen.

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 9 of 26, by ADDiCT

User metadata
Rank Oldbie
Rank
Oldbie

Ehm... Elamaton, are you aware of Gulizoka's DOSBox build? It has a special output method "direct3d", which supports shaders. In the "Shaders" directory, there are files named (for example) "GS4x.fx", "GS4xHqFilter.fx", "GS4xScale.fx" and "GS4xSoft.fx". These files are relatively simple text files, so i'd say it would me much easier to implement a shader, than change DOSBox code. I have no idea how they work, though. The only thing i can tell is that it's easily possible to change parameters by editing these files (Gulizoka gave me an example when i needed a special effect).

MiniMax: buy a new monitor, or get a set of glasses (; . The 4x shot is "clearer" and not as blurred as the 3x one. The pixels are "sharper". I've used IrfanView, and the difference was subtle, but easily visible. Firefox might scale the pictures, if they're larger than the size of the FF window.

Last edited by ADDiCT on 2008-05-23, 09:19. Edited 1 time in total.

Reply 10 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie
DosFreak wrote:

It's hard to say exactly what the average monitor size that DOSBox users have but going by Valve's hardware survey most people have 1024x768 size monitors. This may be one among many of the reasons why 4x hasn't been implemented yet.

Nothing against the rest of your post, but I call bullshit on that Valve survey.

http://www.steampowered.com/status/survey.html

Now, the most common Primary Display Resolution listed is 1280x960, not 1024x768 (although it does come second). Some 20% are running resolutions higher than that. That's plenty enough reason for 4x scaling to exist. That's not the point, however. The point is, the survey contains so many discrepancies and oddities that it's nearly worthless.

The most common 4:3 LCD resolution (1280x1024) isn't mentioned at all, while x960 is. Many CRT owners naturally use that resolution, but no sensible LCD user will (unless their display can letterbox the image). There are tons of 17" LCDs out there, and they should show. The only imaginable scenario is that the x1024 LCD users are rolled into the same result as x960 CRT users. That's just stupid.

Then, looking at the 4:3 aspect ratios, we see the dominance of the venerable 16" display. *cough* What the hell were these people smoking? I dare you to go out and find a 16" display. Jesus. Viewable screen area of 16" on 17" CRTs is no excuse; no one uses that metric in the real world. Similarly, the equally ubiquitous 18" displays are well represented. All in all, another blow to the credibility of the survey.

I mean, for the sake of all things holy, they combine 1280x1024 and 1280x960 into the same group - although their difference in the implied display type is significant - but not 16"-17" and 18"-19"? Idiots.

Almost 65 percent of people have 60Hz as their refresh rate. That's the default rate of just about all LCD displays. 75 comes second, and is probably divided among LCD and CRT users, being a reasonable CRT rate and the common secondary LCD rate. 60Hz must be nearly all LCD, since CRT on 60Hz just means headaches. (Some very specific Vsync demands are the only reason 60Hz CRT is even imaginable nowadays.)

It can be extrapolated that the majority of people are running LCDs. (Obviously. This is 2008, ferchrissakes.) And the last desktop LCD that could only reach 1024x768 was a 15" one, and they've gone the way of the dodo a long ago. Laptops with that resolution are more common, but laptops that can realistically run Valve games will almost certainly have a larger, probably widescreen resolution.

There's more, but enough ranting, since it's pretty off-topic anyway.

Reply 11 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie
MiniMax wrote:

I must be getting old - I don't see a f....cking difference except the mouse-pointer jumping back and forth when I flip between the images using Firefox 2.x on a 1920 x 1200 LCD screen.

Yes, you probably are. I ran those by some DOSBoxing friends of mine and they all confirmed the improved picture quality which I also perceived. (Yes, I did want to rule out the possibility that the difference I saw was just psychological.)

Reply 12 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie
ADDiCT wrote:

Ehm... Elamaton, are you aware of Gulizoka's DOSBox build?

Yes. Windows-only (I'm primarily a Mac user, secondarily Linux, tertiarily Windows), and an unofficial experimental build, however good, is still an unofficial experimental build. I like to keep it stable, steady and official in the long run.

(To that end, official MT-32 support would be veeery nice, so people not running the worst of the major operating systems could enjoy it as well. So what that it needs the ROMs which are of "questionable" legality, that's no problem of the DOSBox project since it wouldn't be distributing them. ScummVM has support, and its faaaaabulous 😉 )

Reply 13 of 26, by MiniMax

User metadata
Rank Moderator
Rank
Moderator
Elamaton wrote:
MiniMax wrote:

I must be getting old - I don't see a f....cking difference except the mouse-pointer jumping back and forth when I flip between the images using Firefox 2.x on a 1920 x 1200 LCD screen.

Yes, you probably are. I ran those by some DOSBoxing friends of mine and they all confirmed the improved picture quality which I also perceived. (Yes, I did want to rule out the possibility that the difference I saw was just psychological.)

Hmm. I saved the images to my hard disk, put them in a temp folder, and used the View-as-slide-show in Window flip-flop between the images. No difference what-so-ever (except the mouse pointer) to my old, weary eyes. Anyone else see a difference?

DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Fedora 32

Reply 15 of 26, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author
Elamaton wrote:

(To that end, official MT-32 support would be veeery nice, so people not running the worst of the major operating systems could enjoy it as well. So what that it needs the ROMs which are of "questionable" legality, that's no problem of the DOSBox project since it wouldn't be distributing them. ScummVM has support, and its faaaaabulous 😉 )

Quite of topic. And the answer is that I don't like distributing a halfworking program. (e.g. something that needs something else to operate properly, especially if that is possibly illegal.)

And just get a real MT32. it works perfectly with dosbox (cvs version of dosbox also with a mac) and the emulation isn't on par with it yet.

plain scaling for 4x ? why not use windowresolution with a hardware scaler like openglnb or ddraw/overlay
for fullscreen i see currently no use for 4x scaling at at all.

Who knows what happens If one of us ever gets a monitor that big that needs 4x scaling. I don't expect it to happen soon 😀

Water flows down the stream
How to ask questions the smart way!

Reply 16 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie
wd wrote:

The difference is in the interpolation at the edges.
Either way if somebody wants to play at big resolutions then he shall
use fullscreen which is why it's there in the first place.

I used windowed mode here because it was easier to take screenshots of the final scaled image, and because windowed mode on an LCD doesn't do the ugly strecth to the LCD's native resolution. But still, fullscreen looks better with a higher scaling multiplier just as windowed mode does.

I just tested it. Here's how:

Native resolution of LCD screen: 1680x1050 (16:10), although for DOSBox pillarboxed 1400x1050
fullscreen=true, fullresolution=original, aspect=true, scaler=[none, normal2x, normal3x]
Game used: Tyrian (sticking with it 😉 ) at 320x200

Subjective results for scalers:

none with 320x200 stretched to native res looked awful.
normal2x with 640x480 stretched to native res looked better.
normal3x with 960x720 in the top left of a 1024x768 full screen with thin black bars stretched to native res looked even better.
normal4x, if it existed, would almost certainly look better still.

So: the higher the multiplier of the scaler, the better the image looks even in full screen.

Your statement of "playing at big resolutions" makes no sense. If I had a screen of 4000x3000 pixels, I'd certainly want normal12x to exist, regardless of my choice of windowing vs. fullscreen.

Reply 17 of 26, by Elamaton

User metadata
Rank Newbie
Rank
Newbie

And the answer is that I don't like distributing a halfworking program. (e.g. something that needs something else to operate properly, especially if that is possibly illegal.)

I'll accept that you feel that way. I disagree completely, since nothing illegal would be required for DOSBox to function, given that MT-32 emulation would be completely optional. And there are legal owners of those ROMs too. But it's your call, and I'll rest my case.

And just get a real MT32.

Umm, no. Buying decades-old hardware and the necessary adapters to make it work with modern machines just to complement an EMULATOR instead of voicing support for that hardware to get, you know, EMULATED (or rather, the existing emulation, even if imperfect, to be implemented) would be silly. I thought the whole point of emulation was to dispense with old hardware, so I could play old games without owning old computers or their old peripherals?

Well, hopefully something like Gulikoza's build eventually finds its way outside Windows.

plain scaling for 4x ? why not use windowresolution with a hardware scaler like openglnb or ddraw/overlay

Because it looks like shit in comparison. I tested it, naturally. It's possible that there is yet some combination of config options I haven't tested that would rival what my normal4x patched version looked like at 1280x960, but so far nothing has come close.

for fullscreen i see currently no use for 4x scaling at at all.

See my previous post.

Reply 19 of 26, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

And there are legal owners of those ROMs too.

obviously you aren't and I guess there are 99,99999999% illegal owners of the ROMs...

Umm, no. Buying decades-old hardware and the necessary adapters to make it work with modern machines just to complement an EMULATOR instead of voicing support for that hardware to get, you know, EMULATED (or rather, the existing emulation, even if imperfect, to be implemented) would be silly. I thought the whole point of emulation was to dispense with old hardware, so I could play old games without owning old computers or their old peripherals?

Quite frankly, I had hoped for good Mt32 emulation myself but after ages of no further development I gave up and bought a real one. Look at the Mt32 forum, the emulation is far from perfect, some may even say far from good and the code hasn't changed in almost 2 years. If you need a built of Dosbox with this emulation then look at how to integrate the Mt32 emu with Dosbox. There is a description of this somewhere and there might even be a patch on Dosbox' SF site (or ask the guys who offer the windows cvs versions with it compiled in)

As for getting the devs to add anything you want to main Dosbox sources you definitely are going the wrong way, you are only hardening their views on such things...