flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > What are the ways to create GUI Goto page 1, 2, 3 Next |
Author |
|
smiddy 11 May 2012, 13:43
Great Question: I will be watching this thread to be sure.
In theory you should be able to do #2, so long as the driver from Windows isn't using the OS calls, by stripping the Windows Driver information. I was wondering if you can get from the vendor of the graphics card, a programming interface (or some such) document in order to do things directly with your card. This won't be compatible with the rest of the world, but at least you will be setup for yourself. Is VESA continued to be supported? There is a lot of free information out on the net for that if I recall correctly. I'll be lurking to see how this thread unfolds. |
|||
11 May 2012, 13:43 |
|
AsmGuru62 11 May 2012, 15:03
I think the private API from a vendor would expose the internals of card's
functionality, which may be a confident information, like a trade secret. So, I think, the vendor would not give out that info. Good question, however. |
|||
11 May 2012, 15:03 |
|
Dex4u 11 May 2012, 16:08
To start with your best to stick to vesa, if you see my post here:
http://board.flatassembler.net/topic.php?p=143625#143625 you will see a vesa demo, that implements both A20 and going back to realmode for mode switching Theres also FBrowser as a example (if you can not find it i will post), but vesa is very simple to use. Here is a min example of enabling vesa and going to PM. Code: ;************************************ ; By Dex ; Assemble with fasm ; c:\fasm Vesa.asm Vesa.bin ; ;************************************ org 0x7C00 use16 ;**************************** ; Realmode startup code. ;**************************** start: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov sp,0x7C00 ;**************************** ; Vesa start code. ;**************************** mov bx,4112h mov ax,4f01h mov di,Mode_Info mov cx,bx int 10h mov ax,4f02h int 10h ;***************************** ; Setting up, to enter pmode. ;***************************** cli lgdt [gdtr] mov eax, cr0 or al,0x1 mov cr0,eax jmp 0x10: protected ;***************************** ; Pmode. ;***************************** use32 protected: mov ax,0x8 mov ds,ax mov es,ax mov ss,ax mov esp,0x7C00 ;***************************** ; Turn floppy off. ;***************************** mov dx,3F2h mov al,0 out dx,al ;***************************** ; Do we have 32 BitsPerPixel. ;***************************** cmp byte[ModeInfo_BitsPerPixel],32 jne Letsloop ;***************************** ; fade background screen. ;***************************** fade_screen: mov edx,[ModeInfo_PhysBasePtr] mov edi,edx xor eax,eax mov al,0xc5 xor ebx,ebx mov bl,195 DoLoop: mov cx,640*2 dec eax rep stosd dec ebx jnz DoLoop Letsloop: hlt jmp Letsloop ;************************************* ; GDT. ;************************************* gdt: dw 0x0000, 0x0000, 0x0000, 0x0000 sys_data: dw 0xFFFF, 0x0000, 0x9200, 0x00CF sys_code: dw 0xFFFF, 0x0000, 0x9800, 0x00CF gdt_end: gdtr: dw gdt_end - gdt - 1 dd gdt ;************************************* ; Make program 510 byte's + 0xaa55 ;************************************* times 510- ($-start) db 0 dw 0xaa55 ;************************************* ; Put uninitialized data here. ;************************************* ;=========================================================; ; Vesa Information Block 11/12/03 ; ;---------------------------------------------------------; ; DOS EXTREME OS V0.01 ; ; by Craig Bamford(Dex). ; ; ; ;=========================================================; ;============================== VESA MODE INFORMATION =========================================== Mode_Info: ModeInfo_ModeAttributes rw 1 ModeInfo_WinAAttributes rb 1 ModeInfo_WinBAttributes rb 1 ModeInfo_WinGranularity rw 1 ModeInfo_WinSize rw 1 ModeInfo_WinASegment rw 1 ModeInfo_WinBSegment rw 1 ModeInfo_WinFuncPtr rd 1 ModeInfo_BytesPerScanLine rw 1 ModeInfo_XResolution rw 1 ModeInfo_YResolution rw 1 ModeInfo_XCharSize rb 1 ModeInfo_YCharSize rb 1 ModeInfo_NumberOfPlanes rb 1 ModeInfo_BitsPerPixel rb 1 ModeInfo_NumberOfBanks rb 1 ModeInfo_MemoryModel rb 1 ModeInfo_BankSize rb 1 ModeInfo_NumberOfImagePages rb 1 ModeInfo_Reserved_page rb 1 ModeInfo_RedMaskSize rb 1 ModeInfo_RedMaskPos rb 1 ModeInfo_GreenMaskSize rb 1 ModeInfo_GreenMaskPos rb 1 ModeInfo_BlueMaskSize rb 1 ModeInfo_BlueMaskPos rb 1 ModeInfo_ReservedMaskSize rb 1 ModeInfo_ReservedMaskPos rb 1 ModeInfo_DirectColorModeInfo rb 1 ; VBE 2.0 extensions ModeInfo_PhysBasePtr rd 1 ModeInfo_OffScreenMemOffset rd 1 ModeInfo_OffScreenMemSize rw 1 ;======================================= START OF PROGRAM ====================================== |
|||
11 May 2012, 16:08 |
|
bubach 11 May 2012, 16:15
VESA via the VBE standards is the safest bet.
The newest VBE standard is 3.0 but not that many people seem to use it, supposedly because of bad support on graphic cards. But i'm not so sure that it's that bad: http://www.jnode.org/node/912 And remember that listing is from 2006, i bet there's tons of cards out there that supports it by now, so i would include it in any driver. You could start by checking for version 3.0 then 2.0, 1.2 and 1.1 in that order to use the most up to date version supported by your card. Here's a BIOS interrupt list that has the VBE calls: http://www.delorie.com/djgpp/doc/rbinter/ix/10/4F.html Here's a small tutorial about it using VESA 1.2 with a demo program for DOS, it's C(++) but you should be able to follow the code or at least benefit from the text itself. http://gameprogrammer.com/1-vbe.html VBE 3 documentation in PDF: http://bos.asmhackers.net/docs/vesa/docs/vbe3.pdf VBE 2.0 http://www.phatcode.net/res/221/files/vbe20.pdf And here's a very specific and in depth document about VBE 1.2 programming: http://www.monstersoft.com/tutorial1/VESA_intro.html Hope that helps, the difficult part would be to set it all up and pass on the information to your protected mode kernel, or to go back and forth between 16bit and 32-bit. |
|||
11 May 2012, 16:15 |
|
Rusik 11 May 2012, 18:57
Thanks for the replies guys. I just tested the code Dex4u, but unfortunately it does not work on my computer. But do not worry, it`s not problem now.
I have another question. In one forum I download boot loader with nice fractal animation. It uses 1024x768 VESA mode, switching to protected mode and activated A20. This is cool, all pixels in the vertical are used but it`s the top and bottom black bars because the pixels are not involved in animation. So, my question is how do I activate each pixel if I have resolution of my screen 1600x900 and also it`s possible to use one 1600x900 *.bmp instead of animations so that it filled the entire screen? I've seen VESA64 archive by Madis731 http://board.flatassembler.net/topic.php?t=11609 but there is used a small background image that is multiplied on full screen and I do not know how remake that code. This archive with fractal animation
|
|||||||||||
11 May 2012, 18:57 |
|
Dex4u 14 May 2012, 12:05
There your problem, the image is going to be too big unless you code a jpeg decoder or use a lower res.
When you boot Madis731 demo, what mode number is posted when firsted booted. Eg something like mode-0x115 Can you post the number. |
|||
14 May 2012, 12:05 |
|
Rusik 14 May 2012, 12:28
Dex4u I do not know how to check, but I think that it 112h or 115h.
|
|||
14 May 2012, 12:28 |
|
Dex4u 14 May 2012, 12:32
Rusik wrote: Dex4u I do not know how to check, but I think that it 112h or 115h. When i boot Madis731 demo up, it stop for about 10 second with info about vesa. the last thing before going to demo is mode number. You need to be quick. By the way which demo did you use as he posted many. |
|||
14 May 2012, 12:32 |
|
Rusik 14 May 2012, 12:45
I used VESA64_15.11_resize.7z http://board.flatassembler.net/download.php?id=5365
I think I find: Update3: This time there have been quite a few changes: - it will always start in 800x600 24bpp mode or fail otherwise |
|||
14 May 2012, 12:45 |
|
freecrac 14 May 2012, 13:45
Rusik wrote: Dex4u I do not know how to check, but I think that it 112h or 115h. 1a) try to get the vesa info with function 4F00h into a buffer of 512 bytes 1b) check if the ax-register return with 4Fh = if not ERROR 2) compare the byte at Buffer+05h if lesser than 2 (major version number of Vesa) Only with VBE 2 or 3: 3) get the pointer(Offset,Segment) of the modelist from Buffer+0Eh 4) get the first/next vesa modenumber and check if FFFF the end of List 4b) increase the offset 5) use function 4f01 Mode-Info into an other Buffer of 256 Bytes 5a) check if the ax-register return with 4Fh = if not ERROR 6) check the parameter of the vesamode(resolution...) 7) repeat with 4 Dirk |
|||
14 May 2012, 13:45 |
|
Rusik 14 May 2012, 21:07
freecrac I have some examples of VESA functions, but the problem is that I can not use them because I do not have sufficient knowledge of assembly, I just start
|
|||
14 May 2012, 21:07 |
|
bubach 14 May 2012, 23:11
Not to sound rude or anything, but what are you going to do once you are in graphics mode if you don't know assembly?
|
|||
14 May 2012, 23:11 |
|
freecrac 15 May 2012, 05:33
Some VESA bios of modern cards does support widescreen modes. For example, my Colorfull GTX295 don´t support the resolution of 1600x900, but some other widescreen modes.
(The last modes in the modelist below with 1920x1200 fit the native resolution of my 28"-16:10 LCD-monitor.) Vesamodes Colorfull GTX295(Nvidia) 0100 X=0280 Y=0190 8Bit 640x480 0101 X=0280 Y=01E0 8Bit 640x480 0102 X=0320 Y=0258 4Bit 800x600 0103 X=0320 Y=0258 8Bit 800x600 0104 X=0400 Y=0300 4Bit 1024x768 0105 X=0400 Y=0300 8Bit 1024x768 0106 X=0500 Y=0400 4Bit 1280x1024 0107 X=0500 Y=0400 8Bit 1280x1024 010E X=0140 Y=00C8 10Bit 320x200 010F X=0140 Y=00C8 20Bit 320x200 0111 X=0280 Y=01E0 10Bit 640x480 0112 X=0280 Y=01E0 20Bit 640x480 0114 X=0320 Y=0258 10Bit 800x600 0115 X=0320 Y=0258 20Bit 800x600 0117 X=0400 Y=0300 10Bit 1024x768 0118 X=0400 Y=0300 20Bit 1024x768 011A X=0500 Y=0400 10Bit 1280x1024 011B X=0500 Y=0400 20Bit 1280x1024 0130 X=0140 Y=00C8 8Bit 320x200 0131 X=0140 Y=0190 8Bit 320x400 0132 X=0140 Y=0190 10Bit 320x400 0133 X=0140 Y=0190 20Bit 320x400 0134 X=0140 Y=00F0 8Bit 320x240 0135 X=0140 Y=00F0 10Bit 320x240 0136 X=0140 Y=00F0 20Bit 320x240 013D X=0280 Y=0190 10Bit 640x400 013E X=0280 Y=0190 20Bit 640x400 0145 X=0640 Y=04B0 8Bit 1600x1200 0146 X=0640 Y=04B0 10Bit 1600x1200 014A X=0640 Y=04B0 20Bit 1600x1200 0160 X=0500 Y=0320 8Bit 1280x800 0161 X=0500 Y=0320 20Bit 1280x800 0162 X=0300 Y=01E0 8Bit 768x480 017B X=0500 Y=02D0 20Bit 1280x720 017C X=0780 Y=04B0 8Bit 1920x1200 017D X=0780 Y=04B0 20Bit 1920x1200 The modes can be used with the linear frame buffer when A20 is on, or with a banked acess of the videoram in A000:0 using bank switching for to acess all other 64KB banks of the screen. I think without, or only with a rare knowledge of assembly it is better to test some commands in simpler routines before to start to write a GUI with assembly. Dirk |
|||
15 May 2012, 05:33 |
|
Rusik 15 May 2012, 10:21
bubach wrote: Not to sound rude or anything, but what are you going to do once you are in graphics mode if you don't know assembly? I learned assembler for Win32 before (a little), even wrote some simple programs. But now I have a great desire to write their OS wit GUI, so started with a simple: write a graphics boot loader and understand how it works. I have a lot of excellent literature, which describes the function of BIOS and many others... The problem is that I have many questions to which I can not find answers, so I write in this forum For example, this time I thought that if VESA mode supports 640x480, 800x600, 1024x768 and I have 1600x900 on my monitor, I can not use all the pixels (only 640x480, 800x600 etc). But yesterday accidentally found an example VBETest.zip http://forum.osdev.org/viewtopic.php?f=1&t=20859&start=0 that turns the whole screen on my computer and I realized that was wrong. If you want to ask what I do on this board if I do not know anything, then say so. I said, every programmer was a time when he knew nothing. Each started with nothing and eventually reached the result. If you want to ask me why I undertake such complex tasks, I will answer that first it's interesting to me and secondly I want to gain practical knowledge and not just read books and believe that the way it is! .. . Last edited by Rusik on 19 Apr 2015, 19:47; edited 1 time in total |
|||
15 May 2012, 10:21 |
|
freecrac 15 May 2012, 17:37
I think it is OK to ask those questions.
Inside of the "VBETest.zip" i found the part of code for to check out the resolution of 800x600. I think if we want an other resolution, than we have to edit those values and also all values if they are in an alliance with calculations of the screen adresses. (Not tested, i just take a look inside.) But if your VBE2/3-Bios don´t provide the resolution of your monitor, then we have a big problem to find a solution for to switch into those mode without VESA and without a driver from the manufacturer of the videocard. There are no informations about to switch to high resolutions with a port access like older modeX in a lower resolution. (Also nobody can tell me the way how to switch the mode of a secondary video adapter (of one card with 2 monitors pluged in), so that the secondary display shows the content of the secondary linear frame buffer, without of using a closed source driver. I always hope that i totaly fail with this claim.) Then we we need some more informations about your problems for using of assembler instructions. Maybe you can post a little part of code for a demonstration. Dirk Last edited by freecrac on 15 May 2012, 17:42; edited 2 times in total |
|||
15 May 2012, 17:37 |
|
bubach 15 May 2012, 17:38
Yes I understand that you can't know everything from the start, but you made it sound as if you knew nothing about Assembly. So I thought that you might need to start with something a bit more simple -not that you should leave the board. But if you know basic Assembly and can read tutorials and follow examples then thats fine
|
|||
15 May 2012, 17:38 |
|
Rusik 15 May 2012, 21:36
Thanks for you care about the topic freecrac, but unfortunately I have no any code yet. Only examples that I find and learn. But I still have many questions. One of them is: What is the optimal VESA mode should I use(24/32-bits of course) if I have 1600x900 resolution on my monitor? What are the advantages of one mode over another? And if someone uses my code, what is the optimal mode for it, if it can be any resolution of it monitor?
And second question, more great: Suppose I decided all the previous problems with the graphics and created a good VESA interface. Now I want to use it in my operating system. It will be a real-time OS that will work in Protected mode. The problem is that in protected mode BIOS interrupts are not available and this makes it impossible to use VESA. In all the examples I've seen, first switches to protected mode and then switches to (un)real mode. But it is clear that is not suitable for serious OS. At the moment I know (I read) three ways to solve this problem: 1. The application or OS does not call the BIOS code directly from protected mode, but first makes a copy of the BIOS image in a writeable section of memory and then calls the code within this relocated memory block (VBE 3.0 Official Manual, page 21). 2. Using 32-bit Entry Point for PM. 3. Using PMID. But again the problem is that I can not find the sample code for this, and without them I myself can not understand. Does anyone know anything about it? |
|||
15 May 2012, 21:36 |
|
freecrac 16 May 2012, 11:28
Rusik wrote: Thanks for you care about the topic freecrac, but unfortunately I have no any code yet. Only examples that I find and learn. Quote: But I still have many questions. One of them is: What is the optimal VESA mode should I use(24/32-bits of course) if I have 1600x900 resolution on my monitor?What are the advantages of one mode over another? And if someone uses my code, what is the optimal mode for it, if it can be any resolution of it monitor? The difference between 24 and 32 bits per pixel is only a programming issue and this have no visible effect for the screen. I always prefer 32 bits per pixel, because we have no 24 Bit-registers and in those 24 bit modes we have to split the ram acess in two or three hits for to set a single pixel color. With 32 Bit bits per pixel we can use a single 32 bit acess instead. Quote: And second question, more great: I properly tested the 16 bit unrealmode with an Intel 80386 DX, 80486, Pentium 1,2,3,4, Core2quad Q9550 and with AMD K5, K6,.. No one have a problem with the unrealmode. They all must have a bug inside, because in the Intel manuals we can found the guaranteed properties of the Intel x86-CPUs that describe, that the hidden internal segment descriptor cache will be claered after switching back to the realmode. But that is not true, because all Intel x86-CPUs that i had tested do not clear the descriptor cache. And if it is really a material defect, then we all can reclaim our money back that we have paid for the Intel x86-CPUs, when most of they are concerned. So i think Intel is not serious in this point, but the Unrealmode is a serious feature of most x86. Only some very rare hardware-components (from Intel too) with a bios that also switch into the PM and back to RM are not compatible with the unrealmode. In the 90" where DOS more in use we had a lot of aplications that use the unrealmode and also some older driver of the himem.sys from Microsoft use the unrealmode some years too. Only for to sell Windows 95 came a claim about the unrealmode that there is not serious. I think it is only a dirty lie/trick to push Windows 95 on the market. So i think it is nothing clear about the unrealmode if it suitable for a serious OS, or not. It is only clear that Intel propagate lies about the properties of their x86-CPUs. Quote: At the moment I know (I read) three ways to solve this problem: But the RM part of the VESA-bios can also be used with the v86-mode. I Think for the beginning it is easier to use any VESA functions within the realmode before switching into the protectmode. What is PMID = PubMed Unique Identifier? Dirk |
|||
16 May 2012, 11:28 |
|
Rusik 16 May 2012, 12:48
freecrac I do not dispute that the native resolution of LCD-monitors provides the best quality, but VESA does not support modes what are not defined by this standard.
It would be nice if it was possible to use any modes with any resolution using LFB or something else for example... So, if I have a monitor with 1600x900 resolution, what mode from the list available to be most optimal for me? That's what I would like to know. And more, maybe it's not this topic, but what about the Menuet64. From the above I assume that this OS has a 64-bit kernel but uses 16 or 32-bits VESA interface, constantly switching in (un)real mode(if it works in Protected Mode of course). |
|||
16 May 2012, 12:48 |
|
Goto page 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.