Hmmm ... linear frame buffer from real mode possible?

Started by keinplan, April 26, 2010, 05:44:54 PM

Previous topic - Next topic

keinplan

Any hack to this? Bank switching sucks.

Or is there no other choice then protected mode?

Greetz,
keinplan

dedndave

yes - probably easier from real mode than 32-bit protected mode
i think what you are looking for is commonly called "X-mode" (plug that into google)
there are a few different resolutions possible - my fave is 320x240 256 color, but it isn't linear buffer

keep in mind, you only get 64 Kb, if i remember
so, resolution and colors is limited
but, you can set up the VGA registers easier in real mode than protected mode

dedndave


keinplan

#3
I need VESA mode 0115h (or higher). At the moment i have to bank switch with INT 10h, 4F05h, to access all pixels of the screen (sure, a bank is only 64k). As i know, the other method (where i have NOT to switch banks) is to use linear frame buffer (vesa 2.0+). But LFB works only with protected mode, or?

Now the question is, can i use vesa/linear frame buffer, without protected mode, in the easier real mode (with a hack or something else). Does you understand what i try to say?  :dazzled:


EDIT:
hehe - i know this unchained xmode from dr dobbs, but that´s not enough for me, i need more ... pixel and colors :(

dedndave

i have never tried that
Steve (FORTRANS) or Michael (MichaelW) would probably know if there is a trick

FORTRANS

Hi,

   Well I have used the VESA bank switching in my graphics
code.  To use the linear frame buffer requires a 32-bit selector
to be set up.  So a DOS protected mode driver, protected
mode, or unreal mode would be required.  This was discussed
recently for memory access above the 1 megabyte limit..

http://www.masm32.com/board/index.php?topic=13564.0

   Bank switching works well enough for me, so I haven't
tried any of those

Regards,

Steve N.

BogdanOntanu

Quote from: keinplan on April 26, 2010, 06:12:45 PM
...

No the question is, can i use vesa/linear frame buffer, without protected mode, in the easier real mode (with a hack or something else). Does you understand what i try to say?  :dazzled:


Yes, you can use the so called "unreal mode" in order to access the linear frame buffer. This old technique still requires that you go to 32 bits protected mode briefly in order to touch the segment selectors limits and the return to real mode and have access to 4Giga bytes of RAM with some minimal extra work while BIOS will continue to work (most of the time).

However besides kernel loading there is no real advantage into doing this. You limit yourself to the 16 bits frame of mind and get into the bad habbit of using 16 bits when the rest of the world  is using 32 bits and moving slowly towards 64 bits.

Practically 16 bits is obsolete and "a bad thing to learn" and use unless you really really have to.  IMHO unless you write a BIOS or you load your kernel you do not really need to use the the 16 bits.

If you want to make your own OS then by all means do use the 16 bits BIOS for initial setup, for kernel loading and for getting some minimal hardware info and THEN get the hell out of there as fast as possible and go into the 32 bits protected mode and keep an eye open for the next best thing: the 64bits long mode.

Forget the 16 bits real mode as fast as possible but not faster. You do need it a little for the startup but that is all. Do not make you home in there. In your own OS in 32 bits protected mode accessing the VGA registers and hardware is even easyer that in 16 bits.

The only thing that attracts people into the BIOS and 16 bist "trap" is that the BIOS is already there and it is  already functional (but is is very basic by design) and you think that **YOU** did someting or learn something important by using it when in fact you did not.

You learn very little by using 16 bits and you learn something of very little use in the future.

Even if you do not make your own OS or 32 bits protected mode program and even IF you "simply" use the Windows Win32 API and 32 bits ASM programming you will learn much more that in 16 bits real mode and you will have a solid platform for finishing learning 16 bits (if the need ever arises) and more importantly you will have a solid base for general professional programming in C/C++ and/or 64 bits if you  need to.

So yes from my experience there is no better choiche than 32 bits protected mode or 64 bits long mode for graphics.



Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

keinplan

Thanks for all answers, great forum  :U

There are some right things.

1) i was thinking about unreal mode before i post this thread. But wiki says, this mode does not work with DosBox. But i need DosBox compatible code. Why? Cause no one i know have a working DOS, but all can use DosBox to get funny stuff working.

2) i´m not a real programmer, i have never learnd this. I think i´m first of all a game designer, but without programmers -  :lol - i have to learn to programm. Why ASM? Cause it´s so funny like no other language i know.

3) i know, DOS isn´t dead, but DOS is a zombie. But ... most of the best game´s i ever played are DOS game´s. I play this game´s still today. I don´t need FullHD & 3D or something like that (cause to do this, there is the need for a army of designer, 3D peoples, ...). All i want is to code, stressless, what´s in my mind. But at minimum, i need 800x600x24.

4) At the moment, i grope me up to a situation where i can say, this is it! I can work with this. I hope, i do not stress to much with my questions while going my way (and i hope you all understand at minimum 75% of what i try to say)  :8)


So, i´m hungry. And i understand the need for the protected mode (for the near future).
Does you know good books (printed or ebook) to learn how to programm with protected mode (something like Peter Norton´s assembly book)?

Greetz and thanks,
keinplan

clive

Coding 32-bit assembler is DOS is reasonably easy with one of the existing DOS extenders. It's been a long while since I was active in DOS, but back in the day there was PMODE/W, DOS4G(W), Causeway and DOS32A. Several of these are available with source these days. I'd certainly recommend looking at some of these to understand the methods and pitfalls.

I used some Intel manuals to get into protected mode, but the practical problem with doing it yourself is that many PC's had design and function issues that had to be worked around. Doing it now might be easier, but if you want things to run on a slew of legacy hardware some of the more "commercial" offerings might save you a lot of wasted time. Doom used to run with DOS4G(W). Current versions of the extenders should run reasonably happily in a Dos Box provided they don't touch things the OS is using/protecting.
.
http://www.sid6581.net/pmodew/
http://www.tenberry.com/dos4g/index.html
http://www.devoresoftware.com/freesource/cwsrc.htm
http://dos32a.narechk.net/index_en.html

This book was reasonable good, as I recall. Protected Mode Software Architecture, by Tom Shanley
http://books.google.com/books?id=1Zizivf6NekC&lpg=PP1&ots=9hpWx_Hj8o&dq=protected%20mode&pg=PR12#v=onepage&q&f=false
It could be a random act of randomness. Those happen a lot as well.

redskull

As long as you remain true to the DPMI specification, you should be able to do most of this under DosBOX (or even under NTVDM) using the VESA extensions; IIRC, SVGA offers the needed resolutions, and the newer versions can be called from either real or protected; of course, it's always hit and miss with emulation.  But as both the VESA and the DPMI are wildly supported, it's probably you best bet for "stressless" programming.  (Though in the world of DOS emulation, nothing is stressless).  I just tried it on my (widescreen) monitor, and I got the usual nasty message that i can't use fullscreen anymore   :'(  YMMV

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

SayisalAdam

Well.. Actually, you can not start assembly without 16 bits I think. But you must upgrade yourself to win32 as quick as possible.
Vesa modes bigger than 640x480x32 won't work if you don't calculate the correct CRT Refresh Rates!.
Also. Vesa does not work with most of the ATI based video cards. Newer versions of this card is also another problem cuz the VESA SVGA modes are different(!) Trust me.
Also! Your application will not work in full screen mode in some cases. 'something like terminal verison of windows ???'. It will say; NTVDM error, Can't start application in full screen mode'

I made a library for Qbasic 4.5. For as a game engine. Couldn't access FlatMode or set DPMI, cuz the compiler was Qb4.5
I wrote a code to set SVGA screen on both ATI and nVidia based gfx cards. Also cheked if gfx card supports VBE.
In 640x480x32, while showing a 640x480 pixels image, FPS was 33 on P4 3.06 Ghz HyperThreading x86 microproccessor. It uses files as Image memory :P (Reduces FPS!)
And also I must warn you about the EMS! Modern tablet pc's don't have a 64k avaible under 1 Mb memeory cuz for the installed drivers. So, if you are going to use EMS, just forget about it. The EMS needs a 64K in lower memory as an operating window. It writes or reads data from there actually. But you can always get a 15.6 MB of XMS in NTVDM.

As you see... 16 bit mode really sucks this way...
But gives much more deeper information about the x86 machines. And the informaton is totally useless today...

sinsi

There are some tricks you can use with v86 mode and paging, similar to what emm386 does for umb's and ems.
One problem I can think of is that might be slower than a bank switch.
You can get a pointer to protected-mode code to bank switch with vbe2.
Light travels faster than sound, that's why some people seem bright until you hear them.