Page 1 of 1

why can't i use vesa mode ?

Posted: Wed Dec 27, 2006 3:01 am
by mohammed
i used mode 13h to draw

Code: Select all

.model tiny
.data
x dw 0
y dw 0
color db 1
.code
start:
mov ax,0013h
int 10h
mov  di, 0a000h    
mov  es,di             
lop:mov  ax, 320        
mul  [Y]            
mov  di, ax         
add  di, [X]       
mov  al, [Color]   
stosb               
inc y
inc x
inc color
jmp lop
end start

i tried to use the vesa by change the value of ax to 4f02h but it didn't work why ?

Posted: Wed Dec 27, 2006 4:30 am
by Combuster
From the VBE spec:

Code: Select all

Function 02h - Set VBE Mode
Input: AX = 4F02h Set VBE Mode
       BX = Desired Mode to set
         D0-D8 = Mode number
         D9-D10= Reserved (must be 0)
         D11   = 0 Use current default refresh rate
               = 1 Use user specified CRTC values for refresh rate
         D12-13 Reserved for VBE/AF (must be 0)
         D14   = 0 Use windowed frame buffer model
               = 1 Use linear/flat frame buffer model
         D15   = 0 Clear display memory
               = 1 Don't clear display memory
       ES:DI = Pointer to CRTCInfoBlock structure
Output: AX = VBE Return Status
Note: All other registers are preserved.
i.e. by just changing ax to 4f02, you haven't chosen a mode yet. you'll need to supply the mode number in BX for it to work.

Posted: Wed Dec 27, 2006 5:27 am
by Ready4Dis
Deleted info, was incorrect.

Posted: Wed Dec 27, 2006 8:35 am
by mohammed
Yes, and the location you need to draw to is changed as well, it will no longer be 0xa000, you have to ask the video card what location the video memory is located in.
no it realy worked when i changed the value of bx as Combuster said to the mode wich i wanted but it didn't draw the same !!
http://www.monstersoft.com/tutorial1/VESA_intro.html
all the tutorials availabe put the code with gcc and i have problems with it no one have a complete code in assembly ?

it is so slow in assembling and linking and working!!!
why ?!!!

Posted: Wed Dec 27, 2006 12:15 pm
by Dex
Try this simple demo (for fasm)

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                           ;;
;; fasm example.By Craig Bamford (Dex) 2002. ;;
;; 640*480 8bpp (256 colors) vesa1           ;;
;; C:\fasm vesa1.asm vesa1.com               ;;
;;                                           ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG    100h

Start:
        mov ax,4f02h
        mov bx,101h
        int 10h

        mov dx,0xa000
        mov es,dx
        call window

StartAgain:
        xor dx,dx
        mov [color],0	   
MainLoop:
        push dx
        call window
        xor bx,bx
        inc [color]
        mov al,[color]
        call static

        pop dx
        cmp dx,4
        je StartAgain
        inc dx  ;<** here is box number
        mov ah,01h
        int 16h
        jz MainLoop
        mov ah,00h
        int 16h
        mov ax,0003h
        int 10h

        ret

window:
        mov ax,4f05h
        mov bx,0
        int 10h
        xor bx,bx
        ret

static:         
        stosb
        inc bx
        cmp bx,0x00000
        jne static
        ret




color    db         0
Row      db         0

Posted: Wed Dec 27, 2006 2:44 pm
by mohammed
thanks dex
i want you to see my program and told me if this is a high color or my eye cheating me ?

Code: Select all

.model tiny 
.data 
x dw 0 
y dw 0 
color db 156 
.code 
start: 
mov ax,4f02h 
mov bx,100h
int 10h 
mov  di, 0a000h    
mov  es,di              
lop:mov  ax, 320        
mul  [Y]            
mov  di, ax          
add  di, [X]        
mov  al, [Color]    
stosb                
inc y 
inc x 
jmp lop 
end start

Posted: Wed Dec 27, 2006 8:13 pm
by Dex
First you are trying to draw to screen like its one big buff like mode 13h, you can not do this as vesa1 uses banks, which means the screen is div into 64k chucks.
If you take my example screen size and times it = 307200 thata a bit more than 64k
So you write 64k to 0a000h than you switch to the next bank, that what this does:

Code: Select all

window:
        mov ax,4f05h
        mov bx,0
        int 10h
        xor bx,bx
        ret
Note whats in DX on call this function, is the bank we want, starting with bank 0 ( in the above case we need 5 banks to fill screen ).
Once we swich bank we write another 64k to 0a000h and so on.
Something like this:
As your in realmode you limted to 64k, so this mode uses 1 boxs 64k in size, you need to swich boxs eg:
********box0****
64k
********box1****
64k
********box2****
64k
********box3****
64k
********box4****
64k
****************

Posted: Thu Dec 28, 2006 1:39 am
by mohammed
now i understand why the color just fill the above 1/5 of the screen
thank you :)