Hello maybe i can help too.
At last i have also a question, but later.
This little piece of code shows how to get a vesamode-number(unknow) for a desired resolution and/or other criteria, for that we can get mode informations.
Code: Select all
; The code is for the 16 Bit Realmode
MaxX = 640 ; Horizontal resolution
MaxY = 480 ; Vertical resolution
BpP = 32 ; Bits per pixel
mov ax, DATEN ; Store relative Segmentadress of the Datasegment
mov ds, ax ; into DS-Segmentregister
mov es, ax ; into ES-Segmentregister
mov di, OFFSET VINF ; Buffer(512 Bytes) for VESA-Info
mov ax, 4F00h ; Function 0
int 10h ; Get up to 512 Bytes es:di (Datasegment:VINF)
cmp ax, 4Fh ; succsesfull ?
jnz NOVESA ; else error: no Vesabios aviable
cmp Byte PTR[di+5], 2 ; Compare major version number of Vesa
jb NOVESA2 ; lesser than Version 2?
lfs si, [di+0Eh] ; Get pointer of Modelist in FS:SI
MODE: mov cx, fs:[si] ; Get Modenumber
lea si, [si+2] ; Increase Offset of modelist (instead of add si,2)
cmp cx, 0FFFFh ; End of list ?
jz NOMODE
add cx, 4000h
mov ax, 4F01h ; Get Mode Info
mov di, OFFSET MINF ; Buffer(256 Bytes) for Mode Info
int 10h
cmp ax, 4Fh
jnz NOVESA
cmp Word PTR[di+12h], MaxX
jnz MODE
cmp Word PTR[di+14h], MaxY
jnz MODE
cmp BYTE PTR[di+19h], BpP ; Bits per pixel?
jnz MODE
;- other compare instructions -
; ------Our DS-SEG-----
VINF DB 512 dup (0AAh) ; Buffer for Vesa-Info(4F00h)
MINF DB 256 dup (044h) ; Buffer for Mode Info(4F01h)
Additional we can check other importend bits in the ModeAttributes field.
we can check the FieldPosition and the MaskSizes of each color fleld and if we become a BGR or RGB orientation for the bits of the green, red and blue field
we can check how many BytesPerScanLine exist
we can check if the address of the linear framebuffer exist, or if there only 4 zero bytes
VBE 3:
we can check if we can use hardware triple buffering for flicker free large movements on the screen without to become a tearing of the content
(more usefull in combination with a higher refreshrate)
we can check the MaxPixelClock if we want to use our own CRTC-parameter for a higher refreshrate >60hz
If we want to use a vesamode with our own CRT parameter table (VBE 3 only with modenumber+800h ),
then we can try to get some informations of our CRT-monitor before to make sure that we do not exeed the capacity of it.
(Note: Older 5 pol BNC(bayonet connector) cable have no DDC(Display data channel) for to transmit the EDID(extended dispay information data))
Code: Select all
mov ax, 4F15h ; DDC - INSTALLATION CHECK
xor bl, bl
int 10h
cmp ax, 4Fh
jnz NODDC
mov ax, 4F15h ; DDC - READ EDID
mov bl, 1
xor cx, cx
xor dx, dx
mov di, OFFSET EDID ; es:di 128 byte
int 10h
cmp ax, 4Fh
jnz short NODDC
mov eax, 0FD000000h ; Text-identifier V/H range
mov bx, 36h
cmp eax, [di+bx] ; di+36h detailed timing #1
jz short RANGE
lea bx, [bx+12h]
cmp eax, [di+bx] ; di+48h detailed timing #2
jz short RANGE
lea bx, [bx+12h]
cmp eax, [di+bx] ; di+5Ah detailed timing #3
jz short RANGE
lea bx, [bx+12h]
cmp eax, [di+bx] ; di+6Ch detailed timing #4
jnz short NODDC
RANGE: mov cl, [USERHZ]
mov al, [di+bx+6] ; MAXHZ
mov dl, [di+bx+8] ; MAXKHZ
MAXHZ = 160 ; CRT-Monitor: HZ
MAXKHZ = 96 ; KHZ
;-------
EDID DB 80h dup (55h)
But before we can set a mode with a higher refreshrate, we have to get a pixelclock from our card and we have to recalculate our refreshrate before.
Code: Select all
Input: bp = vesa modenumber
DDCOK: mov ecx, DWORD PTR[di+0Dh]
mov ax, 4F0Bh ; get/set Pixel-Clock
xor bl, bl ; 0=get
mov dx, bp ; Video-Mode
int 10h
cmp ax, 4Fh
jnz NOVESA ; ERROR function not aviable
mov DWORD PTR[di+0Dh], ecx ; pixelclock
xor eax, eax ; calculate RefreshRate
mov ax, [di] ; horizontal Total
xor ebx, ebx
mov bx, [di+6] ; vertical Total
mul ebx
mov ebx, eax
mov eax, ecx ; Pixelclock
mov esi, 10
xor edx, edx
div esi
xor edx, edx
div ebx
mov [di+11h], ax ; RefreshRate=Pixelclock/(HTotal*Vtotal)
;--------------------------------------
; example of a CRTC parameter table for the resolution of 1024 x 768 @100 hz refreshrate
;--------------------------------------
CRTC DW 1456 ; Horizontal Total in Pixel
HORIANF DW 1122 ; Horizontal Sync-Start in Pixel
HORIEND DW 216 ; Horizontal Sync-End in Pixel
VERTOTA DW 814 ; Vertical Total in Lines
VERTANF DW 768 ; Vertical Sync-Start in Lines
VERTEND DW 42 ; Vertical Sync-End in Lines
DOIFLAG DB 04h ; Flag (interlaced,doubleScan,polarity)
PIXCLOC DD 118309000 ; Pixel clock in hz
REFRATE DW 10000 ; Refresh-Rate in 0.01 hz
;---------------------
DB 40 dup (0)
;--------------------------------------
Tested with a geforce 4 ti 4200 from msi(vbe3 AGP 4MB) and two 19" CRTs from SAMSUNG and SAMTRON with a capacity of 96 khz/160 hz.
A little DOS-Demo (source is written for MASM 5) can be download from my homepage:
http://www.alice-dsl.net/freecracmaps/Tool/Neutrip.zip
public documents from vesa.org
EEDIDguideV1.pdf
EEDIDverifGuideRa.pdf
vbe3.pdf
..
Little helpfull tool for calculating the CRTC parameter:
http://home.arcor.de/g.s/vbehz.htm
;-------------------
Now it is time for my personal question, maybe somebody knows an answer.
Most of modern videocards comes with a primary and additional with a secondary display device.
If they are two monitors pluged in and we start our PC, then we can see that they are in a "cloned mode" and they both are showing the same content.
If we switch to a vesa graphic mode, then the secondary device switch to the same resolution too and shows also the same content that we can see on the primary device.
But how we can stop those "clone mode", for to let show the content of the secondary linear framebuffer on our secondary monitor maybe in a different resolution/mode?
Dirk