Is there a way to change the aspect ratio used by DOS?

Discussions about using non Windows and Linux guests such as FreeBSD, DOS, OS/2, OpenBSD, etc.
Post Reply
All Screws Loose
Posts: 7
Joined: 16. Dec 2018, 12:04
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Currently FreeDOS, MS-DOS/Win3.1, Win95, OS/2 Warp, Arch Linux, Kali Linux, TempleOS, and Visopsys
Location: A place of darkness and chaos

Is there a way to change the aspect ratio used by DOS?

Post by All Screws Loose »

I have a Windows 3.1 VM and a Windows 95 VM that I'm running for fun. I'm using a monitor with a 4:3 aspect ratio, which works perfectly when I'm in Windows, but when I'm in text mode, the dimensions are all wrong - as in, it's too wide from left to right and too narrow from top to bottom. Is there any way to change the text mode resolution in VirtualBox?
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

All Screws Loose wrote: Is there any way to change the text mode resolution in VirtualBox?
The resolution? No, it's always going to be 640x480 for a DOS guest.
The way it looks? Yes, you could use Scaled-Mode from the View menu...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
All Screws Loose
Posts: 7
Joined: 16. Dec 2018, 12:04
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Currently FreeDOS, MS-DOS/Win3.1, Win95, OS/2 Warp, Arch Linux, Kali Linux, TempleOS, and Visopsys
Location: A place of darkness and chaos

Re: Is there a way to change the aspect ratio used by DOS?

Post by All Screws Loose »

Ah, I see. Any way to do that in full screen?
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

It's easier to try it than actually ask, is it not? ;)
You just stretch the window from top to bottom and left to right, instead of going full-screen...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Is there a way to change the aspect ratio used by DOS?

Post by mpack »

In DOS text mode the display is usually 80 columns wide by 25 lines high, the aspect ratio is therefore dictated by the font (which sets the dimensions of one character cell). Without source code changes I don't know of a way to force VirtualBox to use a different font.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

mpack wrote:I don't know of a way to force VirtualBox to use a different font
But does VirtualBox uses its own fonts it there? I thought that was DOS doing its own thing, I don't think that VirtualBox gets particularly involved in there...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Is there a way to change the aspect ratio used by DOS?

Post by mpack »

Michal seems to have a better memory for these things, but AFAIR DOS did not have its own fonts. In fact it didn't care about the display at all, individual apps did their own thing on that. In nearly all early PCs the font used in text modes was built into the display controller.

I just had a hunt around the source. The file "vgafonts.h" looks like it defines 8x8, 8x14 and 8x16 "ROM fonts".
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

mpack wrote:The file "vgafonts.h" looks like it defines 8x8, 8x14 and 8x16 "ROM fonts".
It seems that all of these are used in the BIOS/EFI part, not after the OS takes over. I'll try to ping Michal on IRC, see if we can better understand the whole thing...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Is there a way to change the aspect ratio used by DOS?

Post by mpack »

We were discussing DOS text mode, so there is no "take over" of graphics by the OS. DOS has no graphics.
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Is there a way to change the aspect ratio used by DOS?

Post by Martin »

Who has a DOS VM available and can test a
'mode con cols=120 lines=50'
;)
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

I have FreeDOS (I can't read my old 5 1/4" floppies anymore), and if I try what you said, I get:
C:\> mode con cols=120 lines=50
Columns must be 40 or 80 or 132
C:\> mode con cols=132 lines=50
Using VGA 400 line resolution.
C:\> mode con cols=80 lines=25
C:\>
Yeah, it works! Use the Scaled-Mode for the VM, and we're in business! ;)
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Is there a way to change the aspect ratio used by DOS?

Post by michaln »

The normal resolution of a 80x25 text mode is not 640x480, it is 720x400 because the character cells are 16x9 pixels wide. The does indeed result in the "wrong" aspect ratio because the pixels on a classic VGA monitor wouldn't be square, but in a VM they are.

VirtualBox (VGA BIOS) does supply its own "hardware" fonts, and the fonts VirtualBox uses match standard IBM fonts. DOS is perfectly capable of overriding those, and it is a requirement for supporting any "international" codepages, as the BIOS fonts only support the standard IBM codepage 437. The GRAFTABL command is used to load fonts supporting alternative codepages.

But that's not very relevant, because although GRAFTABL can load different character glyphs, it cannot change the size of the character cells, that's defined by hardware.

The closest you can get to the "right" aspect ratio is probably running the VM in scale mode (Host+C). That will rescale the screen contents to a fixed window size rather than the other way around.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Is there a way to change the aspect ratio used by DOS?

Post by socratis »

Thanks Michal for shedding some light on this...
You see, I always remembered VGA to be 640x480, but I can't (for the life of me) remember whether it was "shorter and wider", haven't used an actual computer like that since (oh boy) 1995, '96(?) or something like that...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
michaln
Oracle Corporation
Posts: 2973
Joined: 19. Dec 2007, 15:45
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Any and all
Contact:

Re: Is there a way to change the aspect ratio used by DOS?

Post by michaln »

The so-called "VGA" resolution is 640x480. That was the highest-resolution graphics mode which all VGA chips (and monitors) could handle. But VGA text modes were never 640x480 (except, one way or another, on laptops with a 640x480 LCD) and by default used 720x400 resolution, same as the old MDA (monochrome text-only cards). The reasons were probably ergonomic more than anything, the extended 9 pixel wide character cells are more legible than 8 pixel wide, but the cards had limited pixel clocks and monitors had fixed horizontal frequency, so the added horizontal resolution came at the expense of reduced vertical resolution. At 400 pixels high, you still get 25 lines of 16 pixel high character cells, which was entirely sufficient. Note that VGA text modes also had higher refresh rate (70 Hz) than 640x480 graphics modes (60 Hz).

If you look at the second table here and just consider the VGA graphics modes 0 to 13h, you'll see that the original VGA monitors were dumb fixed-frequency monitors with 31.778 KHz horizontal refresh, no fancy multisync. The VGA chip itself had whopping two pixel clock rates (25.175 MHz and 28.322 MHz), nothing programmable like mid-1990s cards (when you look at old graphics cards like this one, they usually have two to four discrete oscillators on them, very low-tech). The 25.175 MHz clock was used for 640-wide modes, the 28.322 MHz clock for 720-wide modes.

There are 17 modes listed in that table, but that is an illusion. A VGA monitor cannot display a 320x200 mode, the display controller uses double-scanning and pixel doubling to send two lines and/or pixels to the monitor so that a 320x200 resolution, 640x200 resolution, and (if one goes beyond BIOS) 320x400 resolution are all actually displayed as 640x400. The resolutions that a VGA card can really display are 640x400, 640x350, 720x350, 720x400, and 640x480. The last one at 60 Hz vertical refresh, the others at 70 Hz.

The 350-line modes are a bit of a special on VGA systems, they are actually delivered with the exact same timings as the 400-line modes, but with a total of extra 50 lines of padding added at the top and bottom. The monitor senses the 350-line mode based on sync polarity and stretches the 350 lines to cover the same area as 400 lines would. The monitor similarly senses a 480-line mode and spaces the lines such that 480, 400, or 350 lines all take about the same vertical space on the monitor.

All that covers just standard VGA modes; there is a bit of wiggle room because the displays were analog, and some room for creativity when programming the VGA hardware directly rather than strictly using the BIOS. The relative complexity didn't come out of nowhere, it was dictated by requirements to a) provide backwards compatibility with CGA and EGA, and b) allow the use of cheap fixed-frequency monitors.
Post Reply