flat assembler
Message board for the users of flat assembler.

Index > Main > VBE study

Goto page 1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
Hi, i'm studing VBE.. and im trying to understand some codes..

I got the sample code below from some place (in this forum i think), and i'd like to do some questions about it.

OBS 1: it's not the original source, i made some few changes.
OBS 2: i made some comments into the code, read and tell me if they are right.

Code:
org    100h

Start:
        mov     ax, 4f02h        ; VESA set mode
        mov     bx, 101h         ; 640*480 8bpp (256 colors)
        int     10h

        mov     dx, 0xA000       ; Screen memory starts at segment 0A000h in real mode
        mov     es, dx
        call    setWindow

StartAgain:
        xor     dx, dx            ; DX = Window number?
        mov     [color], 0
MainLoop:
        ;push    dx
        call    setWindow
        inc     [color]             ; next color to next bank
        mov     al, [color]
        call    static_

        ;pop     dx
        cmp     dx, 4             ; 4 = total banks  (0 to 4 = 5)
        je      StartAgain        ; reset
        inc     dx                ; next Window or next Bank?
        mov     ah, 1h            ; just keyboard
        int     16h
        jz      MainLoop

        ; exit

        ret

setWindow:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AX = 4F05h = Display Window Control
;; BH = 00h select video memory window
;;      01h get video memory window
;; BL = 00h Window A
;;      01h Window B
;; DX = window address in video memory (in granularity units)
;; 
;; Return:
;; DX = window address in video memory (in gran. units).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        mov     ax, 4F05h
        xor     bx, bx
        int     10h
     ret


; paints each Window (banks?)
static_:
        stosb              ; copies AL value (color) to ES:DI, and adds DI.
        inc     bx
        test    bx, bx
        jnz     static_
     ret


color    db 0    


1º Question: whats granularity units?
2º Question: in static_ function DI is not initialized (stosb), it always starts with 0?
3º Question: in static_ function when/how BX will be 0?
4º Question: Whats the Window B function?
5º Question: We change Windows or Banks?

_________________
Sorry if bad english.
Post 16 Jun 2010, 23:16
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Teehee,

Before you get any samples, did you read VBE standard? It's crucial to know what you're doing.

  1. Granularity is a measure of how precise you can position video memory window (relative to video memory address space, not CPU's). The unit is KiB.
  2. Since di isn't initialized, it can contain anything.
  3. setWindow clears bx, it will become zero after overflow (65536 repetitions).
  4. Window B may be not present, if it does you can map two regions of video memory into CPU address space.
  5. We change windows; banks are for CGA/HGC graphic modes (they're interlaced).
Post 17 Jun 2010, 00:56
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
i'm still reading this, baldr:


Description:
Download
Filename: VESA30.PDF
Filesize: 266.03 KB
Downloaded: 364 Time(s)


_________________
Sorry if bad english.
Post 17 Jun 2010, 01:09
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
A very good VBE link: http://davmac.org/davpage/vesa.html
It answers many of your questions, lists some "standard" mode numbers, and has bitfield maps of common VBE structures.
Post 17 Jun 2010, 02:47
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
i like it, Tyler, Thanks.

A few questions:

1. What is OEM?
2. a mode "linear framebuffer" supported uses no banks (windows)?
Post 17 Jun 2010, 16:17
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
1. http://en.wikipedia.org/wiki/Original_equipment_manufacturer Very Happy

2. Correct, the LFB is a 32bit memory region and so does away with banking.
Post 18 Jun 2010, 07:47
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Hello Smile
Here there is a utility for Vbe test that i wrote some time ago
for Dos/Win98/Xp,
Vista and Windows 7 report wrong data but you can try.

_________________
Nil Volentibus Arduum Razz
Post 18 Jun 2010, 08:05
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
DJ Mauretto wrote:
Hello Smile
Here there is a utility for Vbe test that i wrote some time ago
for Dos/Win98/Xp,
Vista and Windows 7 report wrong data but you can try.

thanks, it looks very cool, i just wonder... where is the source, just because i like to read sources...to learn more and more again. Smile
Post 18 Jun 2010, 10:43
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Oops Embarassed
I have already wrote a Vesa utility in DOS subforum 640*480 4bit
resolution, this is the same utility but in 80*25 standard vga resolution..
Maybe...... Rolling Eyes

NB:This source code is part of a collection of various utilities that give information about the computer, all gathered in a boot disk.
In the source code you will find things without meaning because they belong
the system I'm writing ..

_________________
Nil Volentibus Arduum Razz
Post 18 Jun 2010, 12:19
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
DJ Mauretto, i have see that you got some topics about VGA/VBE. Can you write a step-by-step article/tutorial about VBE? i have found many difficults to use VBE in the practice (expecially in resolutions like 1280x1024), bc they talk about the teory but do not show how to do in the code (while showing the teory).
Post 18 Jun 2010, 22:57
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Shocked
I do not have time to write a tutorial, if you search on the net
There are lots of information, you can ask in this forum.
If you like programming is important that you learn to take
information from official documents, add a bit of imagination,
and many practical tests as long as you understand, do not ever depend on others,
this is the right path Mad

_________________
Nil Volentibus Arduum Razz
Post 19 Jun 2010, 07:58
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
*ahem* Sad

ok, then i'll start to ask:

1. how to set flat/linear framebuffer in 1280x1024?
2. how to plot a pixel on that resolution?
3. what does these numbers mean (in bold):
119h - 1280x1024 32K (1:5:5:5)
11Ah - 1280x1024 64K (5:6:5)
11Bh - 1280x1024 16.8M (8:8:8 )
4. and what does 32k/64k/16,8M mean? colors possibilities? 32k = 32768 colors?
Post 19 Jun 2010, 11:36
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
yes, 32k is 32768 colors.

1:5:5:5 is color components organisation.
there, one single bit
folowed by 5 for red, 5 for green, 5 for blue.

5:6:5 means, 5 red, 6green, 5blue.


to set flat linera frame buffer in 1280*1024, it is the same as for other modes, when you set the ves mode, the vesa bios returns you vesa info block. in this block, there is a dword that tells you the base linear adress of your frame buffer.

and to plot a pixel, you make it:

mul pixel.y,bpsl
mul pixel.x,bpp
mov [base_adress+pixel.x+pixel.y],color
Post 19 Jun 2010, 11:59
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
edfed, which of these color values is visible to a human eye? 32k is enough to a good color resolution? and how do i know if it is 8, 16 or 32 bit colors?

2. whats bpsl?
3. how can i work with alpha value? (ex: 0xAARRGGBB)

Quote:
there is a dword that tells you the base linear adress of your frame buffer.

I didn't find it. Where it is? [edit] i find it: PhysBasePtr, right?


Last edited by Teehee on 19 Jun 2010, 12:43; edited 1 time in total
Post 19 Jun 2010, 12:16
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
alpha value is virtual.
when you put a pixel with alpha, you should do a calculation with the screen to let back ground appear transparentlly.
on the screen in 32 bit per pixel, the alpha byte is always ignored.

byte per scan line
Post 19 Jun 2010, 12:38
View user's profile Send private message Visit poster's website Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
i'm doing a test to plot a pixel, but something is wrong, i can't see anything:

Code:
org 100h
        mov ax, 0xA000
        mov es, ax

        ;mov ax, 4F00h            ; get info
        ;mov di, VbeInfoBlock
        ;int 10h

        ;call checkSucessful

        mov ax, 4F02h            ; set mode
        mov bx, 11Bh
        int 10h

        call checkSucessful

        mov ax, 4F01h            ; get modeinfo
        mov cx, 11Bh
        mov di, VbeModeInfoBlock
        int 10h

        call checkSucessful

  ; plot pixel

        mov eax, [pixel.y]
        mul [VbeModeInfoBlock.BytesPerScanLine]
        push eax
        mov eax, [pixel.x]
        mul [VbeModeInfoBlock.BitsPerPixel]
        pop ebx
        add eax,ebx
        mov dword[VbeModeInfoBlock.PhysBasePtr+eax],0x000FFFF

  ; exit

exit:   mov ax,1
        int 16h
        int 20h

pixel:
  .y dd 50
  .x dd 50

; ### functions ###

  hex2str:
        ; EAX = value
        ; EDI = buffer
        mov     edx,eax
        mov     ecx,8
    .format_hex:
        rol     edx,4
        movzx   ax,dl
        and     al,0x0f
        cmp     al,0x0a
        sbb     al,0x69
        das
        mov     word[edi],ax
        inc     edi
        loop    .format_hex
        mov     byte[edi],'$'
        ; EDI = string
        ret

  print:
        mov ax,3       ; back text mode
        int 10h
        ; DX = string
        mov ah,9       ; print
        int 21h
        ret

  checkSucessful:
        ; AX = VBE status
        cmp  ax, VBE_SUCESSFUL
        je   @f
        mov  dx, vberror
        call print
    @@: ret

; ### VARS ###

  vberror db '  VBE not supported!$'
  buf     rb 16


  VBE_SUCESSFUL = 004Fh

; structs

VbeInfoBlock:
  .VbeSignature      db 'VESA'      ; VBE Signature
  .VbeVersion        dw 0300h       ; VBE Version
  .OemStringPtr      dd ?           ; VbeFarPtr to OEM String
  .Capabilities      db 4 dup (?)   ; Capabilities of graphics controller
  .VideoModePtr      dd ?           ; VbeFarPtr to VideoModeList
  .TotalMemory       dw ?           ; Number of 64kb memory blocks
  ; Added for VBE 2.0+
  .OemSoftwareRev    dw ?           ; VBE implementation Software revision
  .OemVendorNamePtr  dd ?           ; VbeFarPtr to Vendor Name String
  .OemProductNamePtr dd ?           ; VbeFarPtr to Product Name String
  .OemProductRevPtr  dd ?           ; VbeFarPtr to Product Revision String
                     db 222 dup (?) ; Reserved for VBE implementation scratch
  ; area
  .OemData           db 256 dup (?) ; Data Area for OEM Strings

VbeModeInfoBlock:
  ; Mandatory information for all VBE revisions
  .ModeAttributes        dw ? ; mode attributes
  .WinAAttributes        db ? ; window A attributes
  .WinBAttributes        db ? ; window B attributes
  .WinGranularity        dw ? ; window granularity
  .WinSize               dw ? ; window size
  .WinASegment           dw ? ; window A start segment
  .WinBSegment           dw ? ; window B start segment
  .WinFuncPtr            dd ? ; real mode pointer to window function
  .BytesPerScanLine      dw ? ; bytes per scan line
  ; Mandatory information for VBE 1.2 and above
  .XResolution           dw ? ; horizontal resolution in pixels or characters
  .YResolution           dw ? ; vertical resolution in pixels or characters
  .XCharSize             db ? ; character cell width in pixels
  .YCharSize             db ? ; character cell height in pixels
  .NumberOfPlanes        db ? ; number of memory planes
  .BitsPerPixel          db ? ; bits per pixel
  .NumberOfBanks         db ? ; number of banks
  .MemoryModel           db ? ; memory model type
  .BankSize              db ? ; bank size in KB
  .NumberOfImagePages    db ? ; number of images
                         db 1 ; reserved for page function
  ; Direct Color fields (required for direct/6 and YUV/7 memory models)
  .RedMaskSize           db ? ; size of direct color red mask in bits
  .RedFieldPosition      db ? ; bit position of lsb of red mask
  .GreenMaskSize         db ? ; size of direct color green mask in bits
  .GreenFieldPosition    db ? ; bit position of lsb of green mask
  .BlueMaskSize          db ? ; size of direct color blue mask in bits
  .BlueFieldPosition     db ? ; bit position of lsb of blue mask
  .RsvdMaskSize          db ? ; size of direct color reserved mask in bits
  .RsvdFieldPosition     db ? ; bit position of lsb of reserved mask
  .DirectColorModeInfo   db ? ; direct color mode attributes
  ; Mandatory information for VBE 2.0 and above
  .PhysBasePtr           dd ? ; physical address for flat memory frame buffer
                         dd 0 ; Reserved - always set to 0
                         dw 0 ; Reserved - always set to 0
  ; Mandatory information for VBE 3.0 and above
  .LinBytesPerScanLine   dw ? ; bytes per scan line for linear modes
  .BnkNumberOfImagePages db ? ; number of images for banked modes
  .LinNumberOfImagePages db ? ; number of images for linear modes
  .LinRedMaskSize        db ? ; size of direct color red mask (linear modes)
  .LinRedFieldPosition   db ? ; bit position of lsb of red mask (linear modes)
  .LinGreenMaskSize      db ? ; size of direct color green mask  (linear modes)
  .LinGreenFieldPosition db ? ; bit position of lsb of green mask (linear modes)
  .LinBlueMaskSize       db ? ; size of direct color blue mask  (linear modes)
  .LinBlueFieldPosition  db ? ; bit position of lsb of blue mask (linear modes)
  .LinRsvdMaskSize       db ? ; size of direct color reserved mask (linear modes)
  .LinRsvdFieldPosition  db ? ; bit position of lsb of reserved mask (linear modes)
  .MaxPixelClock         dd ? ; maximum pixel clock (in Hz) for graphics mode
                         db 189 dup (?)  ; reserved: remainder of ModeInfoBlock
    

_________________
Sorry if bad english.
Post 19 Jun 2010, 13:38
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4238
Location: 2018
edfed
Code:
        mov dword[VbeModeInfoBlock.PhysBasePtr+eax],0x000FFFF
    

are you sue you understand what a pointer is?

base adress is a value, the poitner to the value is not the value.
if you want to access the right memory, you should load the pointer first.
then, mov edi,baseaddress
mov [edi+x+y],color
and one more thing is, in real mode, you cannot access the extended memory.
the linear frame buffer of my card is (for example) 480 000
then, i cannot access it from real mode 0A000h segment, i should witch in pmode, and then, create a descriptor for the vesa frame buffer.
Post 19 Jun 2010, 14:16
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Teehee,

Read standard carefully.

Linear frame buffer is requested by setting bit 14 in bx for int10/4F02.

Your address calculation is incorrect: you multiply X coordinate by bits-per-pixel — do you think adjacent pixels are 32 bytes apart?

Anyway, even if address was calculated correctly, without protected/unreal mode you can't access linear frame buffer, A000:0/B000:0 regions are for windowed frame buffer access.
Post 19 Jun 2010, 14:25
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
Quote:
and then, create a descriptor for the vesa frame buffer
How do i create?

baldr wrote:
Read standard carefully.
I'm trying baldr, but i dunno whats happen, it just do not enter in my head.

***

I switched to PM and did this:

Code:
mov edi, VbeModeInfoBlock.PhysBasePtr
mov dword[edi],0xFFFFFFF ; i suposed to be 0,0 pos    

can't see anything.


Description: my test.
Download
Filename: test.7z
Filesize: 4.51 KB
Downloaded: 261 Time(s)

Post 19 Jun 2010, 14:55
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
All completely wrong Shocked , do not use protected mode
do your testing on XP, VESA works fine on xp.

_________________
Nil Volentibus Arduum Razz
Post 20 Jun 2010, 10:32
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3, 4  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.