Bochs VBE how to return to Text mode?

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.
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Bochs VBE how to return to Text mode?

Post by fano1 »

After having set the Bochs VBE driver in graphic mode and painted all I wanted on my screen how can I return to text mode?

I cannot find anything into OSDEV wiki and no "official" documentation from Bochs in how to write a driver for this simplified version of VBE...

Thank you for your help!
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Bochs VBE how to return to Text mode?

Post by Roman »

You can use INT 0x10.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Bochs VBE how to return to Text mode?

Post by BrightLight »

The same way you enabled Bochs VBE you disable it. Instead of writing 0x01 or 0x41 to BGA register 4, write 0x00 to disable the BGA. And then set VGA text mode 3 by uploading the register sequences it requires, which can be found in FreeVGA (I think...) and somewhere in the Wiki.
Way simpler: disable Bochs VBE and then use INT 0x10 as Roman already said.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Re: Bochs VBE how to return to Text mode?

Post by fano1 »

Does not makes sense / is impossible to use VBE to set a text mode?
In the end they are part of the VESA mode numbers: https://en.wikipedia.org/wiki/VESA_BIOS ... de_numbers

I cannot do INT10 as my OS is in protected mode 32 bit so I fear if not possible with a VBE command I need to do this setting VGA registers!
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
User avatar
sleephacker
Member
Member
Posts: 97
Joined: Thu Aug 06, 2015 6:41 am
Location: Netherlands

Re: Bochs VBE how to return to Text mode?

Post by sleephacker »

fano1 wrote:Does not makes sense / is impossible to use VBE to set a text mode?
In the end they are part of the VESA mode numbers: https://en.wikipedia.org/wiki/VESA_BIOS ... de_numbers
Yes, it is possible to set text modes using VBE, but forget mode numbers, they're outdated.
To find text modes you should instead check bit 4 of the ModeAttributes field in the ModeInfoBlock.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Bochs VBE how to return to Text mode?

Post by Brendan »

Hi,

Just a note (partly because I think fano1 might be wanting to switch from "high resolution graphics mode" to "standard VGA text mode")...

If you use VBE to set a "better than VGA" video mode (which includes a "better than VGA text mode"); and then want to switch to a "standard VGA mode"; then you should use VBE for this and not "int 0x10, ah=0x00". The reason is that when setting non-VGA modes VBE can unlock incompatible "non-VGA" extensions in the video card that "int 0x10, ah=0x00" doesn't expect.

However, (depending on which version?) VBE doesn't report standard VGA modes in its list and doesn't give you "mode information structure" for standard VGA modes. For this case (and only for this case) you need to use fixed (7-bit) mode numbers with VBE.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs VBE how to return to Text mode?

Post by Octocontrabass »

VBE is INT 0x10 AH=0x4F. Unfortunately, Bochs doesn't really make the distinction between "VBE" and "virtual hardware that supports VBE".

If you're trying to set the video mode using VBE, then you need INT 0x10. (VBE also has a protected mode interface, but you still need to use INT 0x10 to find the entry point.)

If you're trying to set the video mode using virtual hardware that supports VBE, write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE, and then program it like you would any other VGA-compatible video card.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Bochs VBE how to return to Text mode?

Post by SpyderTL »

It seems like one of the virtual machines would let you do this, but I can't remember which one.

Try setting the XRES, YRES and BPP registers to zero. And if that doesn't work, check and see what these registers are set to at boot time, and try setting them back to the same values after you are in graphics mode.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Re: Bochs VBE how to return to Text mode?

Post by fano1 »

Octocontrabass wrote: If you're trying to set the video mode using virtual hardware that supports VBE, write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE, and then program it like you would any other VGA-compatible video card.
Yes I'm using "Bochs VBE Extensions" so it is no real VBE for example I've not found a way to get the ModeInfo structrure that I needed to populate the list of mode the driver will support.

The idea to set XRES, YRES and BPP to 0 could have some validity indeed, setting these values instead at 80,25 and 4 was what I was thinking but this probably would give me some weird very low resolution graphic mode...
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs VBE how to return to Text mode?

Post by Octocontrabass »

fano1 wrote:Yes I'm using "Bochs VBE Extensions" so it is no real VBE for example I've not found a way to get the ModeInfo structrure that I needed to populate the list of mode the driver will support.
VBE is just a standard for accessing a driver in the video card's ROM. You access the driver through INT 0x10. The ModeInfo structure is how the ROM driver tells you about the modes it supports.

Since you're writing your own driver, it's up to you to figure out which modes you want to support (and which of those are possible on the hardware). Several modes are standardized by VESA (PDF), but there's nothing stopping you from coming up with your own modes.
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Re: Bochs VBE how to return to Text mode?

Post by fano1 »

I've tried to change the mode to text simple setting 80x25@4 bpp but I've obtained a strange big "pixel" on the screen and nothing else!
Setting 0,0,0 gave to me a worst result: only the Bochs title bar remained :shock:

I'll hate to have to resort to set the VGA hardware registers only to return to text mode as my driver is for VBE (the simplified version implemented for the Bochs Graphic Adapter) and - in my opinion - should be a way to return to text mode using that API...
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs VBE how to return to Text mode?

Post by Octocontrabass »

The Bochs VBE extensions don't support text mode at all. You have to disable the extensions (write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE) and then set up text mode using the standard VGA registers.
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Re: Bochs VBE how to return to Text mode?

Post by fano1 »

Really annoying as I should do an hybrid driver now only to return to VGA mode!

Another question BGA will support the real VBE or not? I can query the hardware and obtain the video modes supported, return to text mode and so on?

Makes sense to do a "native" driver for BGA? It simulates a Cirrus 3 VGA card if I'm not mistaken...
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bochs VBE how to return to Text mode?

Post by Octocontrabass »

fano1 wrote:Really annoying as I should do an hybrid driver now only to return to VGA mode!
You don't have to return to text mode, you know. You could just display text in a graphics mode instead.
fano1 wrote:Another question BGA will support the real VBE or not? I can query the hardware and obtain the video modes supported, return to text mode and so on?
When you configure Bochs with BGA (extension=vbe) and VGABIOS-lgpl-latest, you can call VBE through INT 0x10 AH=0x4F.
fano1 wrote:Makes sense to do a "native" driver for BGA? It simulates a Cirrus 3 VGA card if I'm not mistaken...
BGA (extension=vbe) and Cirrus CL-GD54xx (extension=cirrus) are two completely different video cards.

If you write a native driver for BGA, you can use it in Bochs, QEMU, and VirtualBox. I think it's a good idea.

If you write a native driver for Cirrus CL-GD54xx, you can use it in... some really old computers. Don't bother unless you own an actual Cirrus SVGA card.
fano1
Member
Member
Posts: 29
Joined: Sun May 01, 2016 7:24 am

Re: Bochs VBE how to return to Text mode?

Post by fano1 »

The only way to drive BGA is using VBE right? There is no way to have a native video driver...

I don't think it is more slower emulating VBE but I have little hopes that using it natively it will have hardware accelerations to draw lines, rectangles and so on...
Member of the Cosmos OS CoreTeam
Cosmos Official Site
Do you to help us to develop it? Join our chat!
Post Reply