VGA mode changing for 720x400 and 640x400

tsowell
Posts: 4
Joined: Sun Apr 04, 2021 10:25 pm
Been thanked: 3 times

VGA mode changing for 720x400 and 640x400

Unread post by tsowell »

Hi everyone,

I've been playing around with getting the MiSTer to use native VGA resolutions with the ao486 core, and I've hacked up a little proof of concept. I've attached binaries and included links to the changes, but please be careful and check my work! Some very old CRTs can be damaged by bad video timing.


When the ao486 core changes its video mode, MiSTer will check if the new resolution is 720x400 or 320x200/640x400 and use hard-coded mode lines to change the output VGA mode to match the resolution. Any other mode will default to the mode configured in MiSTer.ini (I use 640x480).

The mode lines I hard-coded are for the modes supported by my IBM 8513, but I think they should be fine for a multisync monitor.

The MiSTer code for changing modes is here: https://github.com/tsowell/Main_MiSTer/ ... dfa41dbe3c


In addition, MiSTer will also request that the core change sync polarity in order to support ancient monitors that used the polarity of the sync signals to encode the display height of the video signal. This requires special support in the core, and I've only added hacky support to ao486. I've attached the rbf file, but unless you have a very old monitor, you probably won't need this - the MiSTer mode-changing code works fine without it. I need it for my IBM 8513 which will not scale 400-line video vertically to fill the display unless VSYNC polarity is positive.

The ao486 code to support changing sync polarity is here: https://github.com/tsowell/ao486_MiSTer ... 105fb3442c


Here are the options I used for testing:

Code: Select all

forced_scandoubler=1
vga_scaler=1
direct_video=0
video_mode=6
vsync_adjust=0

Set the ao486 core's Scale option to Wider HV-Integer
Let me know if you have any advice on how to do this better. I'd like to improve support for this if only for my own use.

I think the proper way to do this would be to allow the user to configure the modes supported by their display, and MiSTer would search through those to find a suitable match each time the core changes the video mode.

Changing sync polarity requires support in each core. The ao486 code I linked to above changes sync polarity mid-frame - it would be probably be better to wait for a better time or blank the display before making the change.
Attachments
vga-res-poc.zip
MiSTer and ao486.rbf binaries
(2.46 MiB) Downloaded 12 times
jlancaster86
Posts: 44
Joined: Sat Jun 27, 2020 1:33 pm
Has thanked: 35 times
Been thanked: 8 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by jlancaster86 »

Does it not use native resolutions already with direct video enabled?
callanabrown
Posts: 12
Joined: Thu Jul 30, 2020 1:05 pm
Has thanked: 7 times
Been thanked: 1 time

Re: VGA mode changing for 720x400 and 640x400

Unread post by callanabrown »

This is fantastic, precisely the two resolutions I've been switching between. I'll test it out ASAP.

edit: This appeared to work great for me. DOS text mode was perfectly clear and it changed resolutions to display Skyroads correctly, then back again when I quit. I saw the badly-scaled DOS text mode for just a moment before it switched.

I am using an HDMI->VGA converter on a Samsung Syncmaster 900 (not using an IO board).

vga_scaler = 0
forced_scandoubler = 0
direct_video = 0
video_mode = 6

I suppose it works with both vga_scaler and forced_scandoubler set to 0 since you hardcoded 320x200 to upscale to 640x400?

Also wondering about video_info.. I have never seen the video information come up as an OSD banner, and trying to add a video_info line into the ini doesn't seem to do anything. Was this feature moved/removed?
tsowell
Posts: 4
Joined: Sun Apr 04, 2021 10:25 pm
Been thanked: 3 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by tsowell »

jlancaster86 wrote: Mon Apr 05, 2021 12:57 am Does it not use native resolutions already with direct video enabled?
Thanks for the suggestion! That does sound promising. I will see how it works once I get an HDMI-to-VGA converter. I'm curious to see if the core handles HDMI sync polarity better than it does with VGA. Even if it doesn't, there's probably a cleaner way to fix that than what I've done here.
tsowell
Posts: 4
Joined: Sun Apr 04, 2021 10:25 pm
Been thanked: 3 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by tsowell »

calannabrown, thanks for trying it out. I'm glad it seems to be working!
callanabrown wrote: Mon Apr 05, 2021 2:01 am I suppose it works with both vga_scaler and forced_scandoubler set to 0 since you hardcoded 320x200 to upscale to 640x400?
My code just sets the video mode, and I think something else still needs to scale it up to 640x400. Do you have the core's scaler enabled?
callanabrown wrote: Mon Apr 05, 2021 2:01 am Also wondering about video_info.. I have never seen the video information come up as an OSD banner, and trying to add a video_info line into the ini doesn't seem to do anything. Was this feature moved/removed?
The video info banners show for me on each mode change - I just tested it with video_info=5. I'm not sure what would prevent them from working, but we are using different settings and setups. Does video_info work for you with a stock MiSTer release?
callanabrown
Posts: 12
Joined: Thu Jul 30, 2020 1:05 pm
Has thanked: 7 times
Been thanked: 1 time

Re: VGA mode changing for 720x400 and 640x400

Unread post by callanabrown »

OK got video_info working.. didn't see it further down in my INI so it was being set then unset again later.

I did verify I had vga_scaler, forced_scandoubler and direct_video all set to 0.

In this github thread: https://github.com/MiSTer-devel/ao486_MiSTer/issues/6
Sorg mentions "ao486 outputs HDMI resolution through VGA on this core. So you need to set a compatible to your monitor video mode in MiSTer.ini" so that to me implies the core might be hardwired to the scaler? Or perhaps your modifications trigger the scaler?
Attachments
20210405_074350.jpg
20210405_074350.jpg (3 MiB) Viewed 382 times
20210405_074338.jpg
20210405_074338.jpg (2.48 MiB) Viewed 382 times
HMPoweredMan
Posts: 35
Joined: Fri Sep 11, 2020 7:37 pm
Been thanked: 1 time

Re: VGA mode changing for 720x400 and 640x400

Unread post by HMPoweredMan »

callanabrown wrote: Mon Apr 05, 2021 12:07 pm OK got video_info working.. didn't see it further down in my INI so it was being set then unset again later.

I did verify I had vga_scaler, forced_scandoubler and direct_video all set to 0.

In this github thread: https://github.com/MiSTer-devel/ao486_MiSTer/issues/6
Sorg mentions "ao486 outputs HDMI resolution through VGA on this core. So you need to set a compatible to your monitor video mode in MiSTer.ini" so that to me implies the core might be hardwired to the scaler? Or perhaps your modifications trigger the scaler?
The core has to go through the scaler unfortunately. This wasn't always the case.

This works great! Certainly an acceptable solution for me. I can't stand that we don't have native resolutions but this is certainly the next best thing to using the janky scaling!

This should be committed to the main IMO.

Will you be keeping this updated parallel with mister main? I intend to keep using this as long as possible.


Another problem comes to mind for those who want multiple monitor outputs. Ideally the HDMI output would maintain the resolution so modern devices could display it while the VGA output would be the 'native' res.
akeley
Posts: 197
Joined: Mon May 25, 2020 7:54 pm
Has thanked: 17 times
Been thanked: 6 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by akeley »

Tried it on Direct Video and Syncmaster 795df. The switching works fine. In 320x200 scaling seems to be perfectly 1:1. DOS text is readable but has artifacts. Is this to be expected?

Thanks for your efforts...if this core could output native VGA properly it would make my day (or year).

EDIT: After tweaking some settings and a cold reboot somehow even DOS is 1:1 now. The fact it's all working now is amazing (I've not checked on this core for a few monhts).

Couple of games I tried did stop working after some options screens though, with the monitor light blinking. Something to do with different resolutions? It was Battlehawks 1942 & Sim City.
thorr
Posts: 175
Joined: Mon Jul 06, 2020 9:37 pm
Has thanked: 8 times
Been thanked: 8 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by thorr »

This is great! Unfortunately my SVGA CRT doesn't work anymore, but I am using my CRT TV and could still potentially benefit from this. Instead of hardcoding the modelines for the various resolutions, can you add lines to the INI file that can be customized? That way, I can set up various resolutions for my CRT TV that actually work and scale well for each mode.
tsowell
Posts: 4
Joined: Sun Apr 04, 2021 10:25 pm
Been thanked: 3 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by tsowell »

Thanks everyone for trying this out!
HMPoweredMan wrote: Wed Apr 07, 2021 10:27 pm This should be committed to the main IMO.

Will you be keeping this updated parallel with mister main? I intend to keep using this as long as possible.
thorr wrote: Thu Apr 08, 2021 10:06 pm This is great! Unfortunately my SVGA CRT doesn't work anymore, but I am using my CRT TV and could still potentially benefit from this. Instead of hardcoding the modelines for the various resolutions, can you add lines to the INI file that can be customized? That way, I can set up various resolutions for my CRT TV that actually work and scale well for each mode.
I'm using this myself, and I do plan to keep it up-to-date with main. In the next couple of weeks I'll try to give it a more proper treatment:

1. Add a configuration option to completely enable/disable the feature.
2. Use user-defined modes - either "vga_mode_0=...", "vga_mode_1=...", "vga_mode_n=..." in MiSTer.ini, or just a separate config file if I can't find a clean way to do variable-length lists in MiSTer.ini.
3. Keep the sync polarity code and the native mode code in separate branches, with a third branch combining the two.

That should get it a little closer to being suitable for a pull request, but I'm fine with maintaining it as a patch if it never gets to that point.
HMPoweredMan wrote: Wed Apr 07, 2021 10:27 pm Another problem comes to mind for those who want multiple monitor outputs. Ideally the HDMI output would maintain the resolution so modern devices could display it while the VGA output would be the 'native' res.
That's a good idea. I don't have a great understanding of how the VGA/HDMI output works, but I will keep this in mind as I learn more.
akeley wrote: Thu Apr 08, 2021 6:20 pm Couple of games I tried did stop working after some options screens though, with the monitor light blinking. Something to do with different resolutions? It was Battlehawks 1942 & Sim City.
I'll try those out and see if I can figure out what's going on. Thanks for the bug report!
akeley
Posts: 197
Joined: Mon May 25, 2020 7:54 pm
Has thanked: 17 times
Been thanked: 6 times

Re: VGA mode changing for 720x400 and 640x400

Unread post by akeley »

tsowell wrote: Fri Apr 09, 2021 7:49 pm
akeley wrote: Thu Apr 08, 2021 6:20 pm Couple of games I tried did stop working after some options screens though, with the monitor light blinking. Something to do with different resolutions? It was Battlehawks 1942 & Sim City.
I'll try those out and see if I can figure out what's going on. Thanks for the bug report!
I tried Battlehawks on my Win 98 PC yesterday and it also crashed when switching to the actual flying part, (it did work when I tried it in the DOS mode though). So maybe it's not related to resolutions after all.

I've only started using this core few days ago, before the scaling was just not all there. I will try to see how some other games behave and report. I'm very happy to hear you will continue developing this, for me 1:1 CRT ao486 is probably the Holy Grail of MiSTer, so once again big thanks for looking into it.

Here's also an interesting article on different resolutions in DOS games: http://nerdlypleasures.blogspot.com/201 ... -when.html
Post Reply