change text mode VGA width/height?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
YDeeps1
Member
Member
Posts: 69
Joined: Tue Aug 31, 2021 7:25 am
Discord: speedy.dev
Contact:

change text mode VGA width/height?

Post by YDeeps1 »

I keep searching for the answer but I cant find any so I'm curious if it is possible to change the VGA text mode width & height from 80x25 to something else (whether thats by resizing the text of whatever) without switching to pixel mode and drawing the characters myself.

Is this possible? Thanks.
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: change text mode VGA width/height?

Post by nexos »

There are some obscure higher resolution VGA text modes AFAIK, but I am not sure how widely implemented they are implemented.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: change text mode VGA width/height?

Post by kzinti »

It is possible, here is some high-level info:

https://en.wikipedia.org/wiki/VGA_text_mode
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: change text mode VGA width/height?

Post by Octocontrabass »

Standard VGA doesn't have a whole lot of options for higher resolutions, but you can make the character cells smaller. Using the default 720x400 text mode resolution, the character cells are 9x16 which results in 80x25 cells. Using only standard BIOS calls, you can reduce the cell height - for example, use 9x8 characters for an 80x50 text mode. I'm not sure if it's possible with BIOS calls, but by poking the registers directly, you can change the cell width to 8 pixels. With 8x8 character cells, you can have a 90x50 text mode. (You might also be able to increase the vertical resolution to 480 lines, giving you 60 rows, but I haven't tried to work out the timings to see if displays would accept it.)
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: change text mode VGA width/height?

Post by eekee »

Octocontrabass wrote:Standard VGA doesn't have a whole lot of options for higher resolutions, but you can make the character cells smaller. Using the default 720x400 text mode resolution, the character cells are 9x16 which results in 80x25 cells.
Note: There is an old alternative standard, "LCD", for 80s laptops. This has 640x400 (or 640x200) pixels and 8x16 (or 8x8) characters. I mention it because some much more recent laptops implement it, even when it's quite unnecessary to do so. I have a Thinkpad X61 which implements LCD text although its screen is greater than 720 pixels wide and the characters have to be stretched in software.

Some other VGA BIOSes implemented 132-column modes, presumably 1056 pixels wide, but I haven't seen one for many years. Lilo was good at probing for these things.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
feryno
Member
Member
Posts: 73
Joined: Thu Feb 09, 2012 6:53 am
Location: Czechoslovakia
Contact:

Re: change text mode VGA width/height?

Post by feryno »

I used this code in my very old project to change from 80x25 to 80x50, I hope it will help you and is still present:

Code: Select all

; set 80x50 text mode
	mov	ax,1112h	; AH=11h TEXT-MODE CHARACTER GENERATOR FUNCTIONS
				; AL=12h load ROM 8x8 double-dot pattern (PS,EGA,VGA)
	xor	bl,bl		; block to load
	int	10h
hypervisor-based solutions developer (Intel, AMD)
FrankRay78
Posts: 22
Joined: Fri Jan 05, 2024 10:10 am

Re: change text mode VGA width/height?

Post by FrankRay78 »

feryno wrote:I used this code in my very old project to change from 80x25 to 80x50, I hope it will help you and is still present:

Code: Select all

; set 80x50 text mode
	mov	ax,1112h	; AH=11h TEXT-MODE CHARACTER GENERATOR FUNCTIONS
				; AL=12h load ROM 8x8 double-dot pattern (PS,EGA,VGA)
	xor	bl,bl		; block to load
	int	10h
Is the above code snippet actually correct? Wouldn't we expect to see AH=00h included somewhere, along with AL specifying which text mode to switch to?
Better software requirements can change the world. Better Software UK.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: change text mode VGA width/height?

Post by Octocontrabass »

It's not switching to a different mode, it's just changing the font. If you want to also set the mode, you'd write something like this:

Code: Select all

mov ax, 0x0003 ; VGA text mode, 720x400 pixels, 9x16 font, 80x25 characters
int 0x10
mov ax, 0x1112 ; replace 9x16 font with 9x8 font, so now it's 80x50 characters
mov bl, 0x00
int 0x10
Post Reply