Questions:
- Shouldn't the programmer check that the color mode is available?
- If yes, does the GRUB structure help, or must the VGA card be asked instead?
Thank you for reading.
These are tutorials, and any example code is only intended to illustrate concepts in a concise/simple manner that can be easily understood by people that need a tutorial. If the tutorial tried to do things like a real OS would, then it'd be too complicated for people trying to learn. Basically; the example code in any decent tutorial is not intended for an actual OS and is not useful for an actual OS.CocaCola wrote:I have seen that two OS tutorials (Friesen's and Molloy's), as well as OSDev Wiki pages, assume that color mode is available and the correct address to write to is 0xB8000.
I'd frankly be surprised if MDA has been supported in any new operating system since 1990 or so. Support may have been maintained past 1990 in a few old OSes like DOS simply because it was already there and no need was seen to remove it, but I could be talking out of my rear.egos wrote:linguofreak, I removed EGA support from my kernel few years ago, so only VGA compatible card is held good in requirements. MDA was never used.
Code: Select all
mov dx, 03ceh
mov al, 6
out dx, al
inc dx
in al, dx
shr al, 2
and al, 3
mov edi, 0A0000h
cmp al, 2
jl @f
mov edi, 0B0000h
cmp al, 2
je @f
mov edi, 0B8000h
@@:
So the conclusion is that I should check if the video mode is what I want?Gigasoft wrote:Your VGA card will always implement the same set of features no matter what type of monitor is connected, so you don't really have to care. The BIOS won't map VRAM at B0000h just because you have a monochrome monitor, either. The only difference it makes is that the palette might be initialized with grays. However, if the current video mode is anything other than what you want, it's probably best to initialize the card to a known state.
Good point, although I'd rather support MDA text mode just to be able to print a silly "Upgrade hardware" error message...linguofreak wrote:Also, I'm willing to bet that any computers that only have MDA text mode are old enough that most modern OS's won't work on them anyways. 20 or 30 years ago you would have had to check, now I'd say you can safely decide not to support MDA text mode.
I'm saying that the type of monitor that is connected won't change anything. But some BIOSes might set up the card in a graphics mode when they boot, so you should perform a check anyway.Otherwise by saying that I "don't really have to care", you are implying that there must be some safe defaults, correct?
Check if the byte at 449h equals 2 or 3. To be sure about the number of rows, you can also check that the byte at 484h equals 24.And then I should somehow check if the mode is 80x25 characters, but I don't know how.
Why the hell would anyone even bother discussing MDA graphics mode.linguofreak wrote:Also, I'm willing to bet that any computers that only have MDA text mode are old enough that most modern OS's won't work on them anyways. 20 or 30 years ago you would have had to check, now I'd say you can safely decide not to support MDA text mode.
I have no plans whatsoever to stop supporting MDA (text mode). If I encounter some PC in the future that doesn't support it, I'll put an emulator in place to emulate the behavior using a supported graphics mode. Since I also have no problems with dynamic VBE changes even with long mode (since the mode switch can run in protected mode), that is not something that will make me stop supporting MDA and text mode either.linguofreak wrote:I'd frankly be surprised if MDA has been supported in any new operating system since 1990 or so. Support may have been maintained past 1990 in a few old OSes like DOS simply because it was already there and no need was seen to remove it, but I could be talking out of my rear.egos wrote:linguofreak, I removed EGA support from my kernel few years ago, so only VGA compatible card is held good in requirements. MDA was never used.
You probably know what you are talking about. However, can I ask a question? If I understood correctly, MDA was the "original" video card of IBM PC. Then there were CGA/EGA/VGA. I guess the term MDA is not relevant anymore (in any context) for modern OS developers. Is it even possible to have an 80386-based computer with MDA? Your OS surely needs an 80368 CPU or newer? Did you mean that VGA compatible cards support the MDA mode (e.g. "BIOS video mode 7h") and you support that in addition to a VGA text mode? In short: what you meant by supporting MDA?rdos wrote:I have no plans whatsoever to stop supporting MDA (text mode).