flat assembler
Message board for the users of flat assembler.

Index > OS Construction > showing imange in vesa

Author
Thread Post new topic Reply to topic
yuka



Joined: 07 Aug 2012
Posts: 4
yuka
now, i have this vesa code..
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. Wink
;*****************************

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  ======================================     


i just want to show an image on that vesa mode.. can anyone, help me?? Crying or Very sad
Post 07 Aug 2012, 05:47
View user's profile Send private message Reply with quote
yuka



Joined: 07 Aug 2012
Posts: 4
yuka
Help..?? Crying or Very sad Crying or Very sad
Post 07 Aug 2012, 06:38
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Don't be eager. In the mean time try to fix things yourself, or at least to explain what is the problem, what actually happens and what you expect to happen instead.
Post 07 Aug 2012, 06:59
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
freecrac



Joined: 19 Oct 2011
Posts: 117
Location: Germany Hamburg
freecrac
Ok, we can display an unpacked/uncompressed 24 Bit Truevison Targa(.tga) picture.
(This example is written for a mapped linux framebuffer device with a resolution of 1024x768x24.)
Code:
%define MaxX 400h
%define MaxY 300h
%define Mapsize (MaxX*MaxY*3)

%define FileLen 2359835                    ; Targa Bildlaenge (DESK1024.TGA)
; %define FileLen 8334                       ; Targa Bildlaenge (DIRKTRUB.TGA)

section .text
     global _start                      ; entry point exportieren
_start:
               mov         ebx, TGANAM      ; pointer/offset auf File/Device-Name
          call OPEN                    ; Datei oeffnen
        cmp         eax, -1
         jz  short ERROR
              call READ                    ; Datei laden
              call CLOSE                   ; Datei schliessen
;------------------------------------------
                 mov         ebx, FBDEV       ; pointer/offset auf File/Device-Name
          call OPEN
           cmp         eax, -1
         jz  short ERROR
              call MAPFB                   ; Frame Buffer mappen
         or          eax, eax
        jz short ERROR
              mov         [FBADR], eax     ; frame buffer adress
;------------------------------------------
           call TGAOUT                  ; Bild zum FRAMEBUFFER
;------------------------------------------
ENDE:         mov         eax, 1
          mov         ebx, 0
          int 80h                      ; exit
;------------------------------------------
ERROR:        mov         eax, 4           ; syscall nr: write
        mov         ebx, 1           ; ausgeben auf fd 1: stdout
        mov         ecx, ERRMSG      ; pointer auf auszugebenen string
              mov         edx, MSG_size    ; laenge des strings
           int 80h
              jmp short ENDE
;-------------------------------------------------------------------------------------
; **** SUB ROUTINE ****
;------------------------------------------
OPEN:         mov         eax, 5           ; syscall nr: open
        mov         ecx, 2           ; /usr/include/bits/fcntl.h = O_RDWR
           xor         edx, edx
        int 80h                      ; ebx = pointer auf Name
       mov         [FD], eax        ; File discriptor retten
       ret
;------------------------------------------
READ:         mov         ebx, eax         ; File discriptor
              mov         ecx, TGAHEAD     ; pointer/offset
       mov         edx, FileLen     ; laenge
W1:        mov         eax, 3           ; syscall nr: read
         int 80h
             cmp         eax, -1
         jz  short OK
        cmp         eax, edx
        jz  short OK
        sub         edx, eax
        add         ecx, eax
        jmp short W1
OK:         ret
;------------------------------------------
CLOSE:        mov         ebx, [FD]        ; File discriptor
              mov         eax, 6           ; syscall nr: close
        int 80h
             ret
;------------------------------------------
MAPFB:        mov         [FBFD], eax       ; File discriptor
              mov        ebx, MMAP
              mov          eax, 5Ah          ; mmap(90)
              int 80h
              ret
;-----------------------------------------------------
;  T a r g a - B i l d   z u m  F r a m e b u f f e r
;-----------------------------------------------------
TGAOUT:       mov         ax, [X1]
       add         ax, [XLEN]
              mov         [X2], ax         ; X2 retten
            mov         ax, [Y1]
        add         ax, [YLEN]
              mov         [Y2], ax         ; Y2 retten

        mov         eax, [X2]
       mov         ebp, MaxX*3
             add         eax, eax
        add         eax, [X2]        ; Bild-Zeilen-Rest
             add         ebp, eax         ; bis zum naechsten Zeilen-Anfang.

         mov         eax, MaxX*3      ; Zeilenlaenge
         mov         ebx, [Y2]
       dec         ebx
             mul         ebx

         xor         ecx, ecx
        xor         ebx, ebx
        mov         cx, [X1]
        mov         bx, cx
          add         ecx, ecx
        add         ecx, ebx
        add         eax, ecx         ; plus X1*3
            mov         edi, eax         ; Bild-Start-Offset links-unten

            mov         esi, TGABODY     ; Tabellen-Zeiger auf Bild-Bytes
       mov         ebx, [FBADR]     ; adress of frame buffer
       mov         dx, [X1]         ; Spalten-Zaehler
              mov         cx, [Y2]         ; Zeilen-Zaehler
;------------------------------------------
ANALYSE:      mov         eax, [esi]       ; Bild-Bytes holen
           inc         dx               ; Spalten-Zaehler veraendern
           add         esi, 3           ; Tabellen-Zeiger veraendern
           mov         [ebx+edi], ax    ; Pixel(blau,grĂ¼n) zum FRAMEBUFFER
            shr         eax, 10h
        mov         [ebx+edi+2], al  ; Pixel(rot) zum FRAMEBUFFER
           cmp         dx, [X2]         ;  letzte Spalte (X2) erreicht ?
       jnz short SPALTE

        sub         edi, ebp         ; auf naechste Zeile setzen
            dec         cx               ; Zeilen-Zaehler veraendern
            mov         dx, [X1]         ; Spalten-Zaehler auf Anfang (X1)

SPALTE:       add         edi, 3           ; naechste Spalte
              cmp         cx, [Y1]         ;  letzte Zeile (Y1) erreicht ?
        ja  ANALYSE
              ret
;-----------------------------------------------------------------------------
section .data

MMAP    DD 0                              ; start - suggest memory address to allocate
        DD Mapsize                        ; length
        DD 3                             ; prot (PROT_READ + PROT_WRITE)
        DD 1                                 ; flags (MAP_SHARED = 1)
FBFD    DD 0                                ; file discriptor(handle)
        DD 0                              ; offset into file to start reading
;-----------------------------------------
FBDEV   DB "/dev/fb0", 0, 0, 0, 0

TGANAM  DB "DESK1024.TGA", 0, 0, 0, 0   ; Name des files
; TGANAM  DB "DIRKTRUB.TGA", 0, 0, 0, 0     ; Name des files
;-----------------------------------------
ERRMSG  DB "Es ist ein Fehler aufgetreten.", 0Ah, 0
MSG_size equ ($-ERRMSG)
;-----------------------------------------------------------------------------
section .bss

FD      resd 1                            ; file discriptor
;-----------------------------------------
FBADR   resd 1                            ; adress of frame buffer
;-----------------------------------------
X2      resw 2                            ; X-Pos. (wird eingetragen)
Y2      resw 2                            ; Y-Pos. (wird eingetragen)
;-------- T a r g a  H e a d e r ---------
TGAHEAD resb 1                            ; 0    Laenge des Identifikations-Feldes
TABLE   resb 1                            ; 0    Flag fuer Farb-Tabelle 1 = F.-Tabelle
KOMP    resb 1                            ; 2    komprimiert Bit 7 / Bit 0-6 Farbe
DACOFF  resw 1                            ; 0    Offset der Farben nach Header
DACLEN  resw 1                            ; 0    Laenge der Farben
DACBIT  resb 1                            ; 0    Bits pro Farbe (3Byte bei 256Farben)
X1      resw 1                            ; 0    X-Pos.
Y1      resw 1                            ; 0    Y-Pos.
XLEN    resw 1                            ; 2Ch  Breite (DIRKTRUB.TGA)
YLEN    resw 1                            ; 3Fh  Hoehe  (DIRKTRUB.TGA)
FAMODE  resb 1                            ; 18h  Bits je Pixel
DIREKT  resb 1                            ; 0    Bit 5 = 0 von unten nach oben
;-------- T a r g a  b o d y -------------
TGABODY resb (FileLen-12h)                ; Targa-Bild-Daten (24 Bit RGB)
    

Feel free to copy, use and to distribute this stuff like you want.

Legal situation:
No personalised spiritual ownership or liquidication rights for usement,
or for spreading out aviable, because all ideas are (at all hazards)
only a small part of the heritage of our common human culture and nobody
can progress an idea without to make a use of our all intergenerational
relationships beginning from our roots thousands of years ago.

Dirk
Post 07 Aug 2012, 07:13
View user's profile Send private message Send e-mail Reply with quote
freecrac



Joined: 19 Oct 2011
Posts: 117
Location: Germany Hamburg
freecrac
yuka wrote:

Code:
        mov  bx,4112h
    

Starting with VBE 2 we can not be sure if the older modenumbers of the VBE 1 ever more exist. So it is recommend to get each modenumbers from the table that comes within our VESA bios.
With my new card the number 112h do not exist in the modelist.
Code:
VESA modelist of the Sapphire 7950
Vesamode,XRes,YRes,Bits per Pixel,Adresse des Framebuffer
0100 640x400x8 C0000000 
0101 640x480x8 C0000000 
0103 800x600x8 C0000000 
0105 1024x768x8 C0000000 
0107 1280x1024x8 C0000000 
0110 640x480x16 C0000000 
0111 640x480x16 C0000000 
0113 800x600x16 C0000000 
0114 800x600x16 C0000000 
0116 1024x768x16 C0000000 
0117 1024x768x16 C0000000 
0119 1280x1024x16 C0000000 
011A 1280x1024x16 C0000000 
010D 320x200x16 C0000000 
010E 320x200x16 C0000000 
0120 320x200x32 C0000000 
0193 320x240x8 C0000000 
0195 320x240x16 C0000000 
0196 320x240x32 C0000000 
01B3 512x384x8 C0000000 
01B5 512x384x16 C0000000 
01B6 512x384x32 C0000000 
01C3 640x350x8 C0000000 
01C5 640x350x16 C0000000 
01C6 640x350x32 C0000000 
0133 720x400x8 C0000000 
0135 720x400x16 C0000000 
0136 720x400x32 C0000000 
0153 1152x864x8 C0000000 
0155 1152x864x16 C0000000 
0156 1152x864x32 C0000000 
0163 1280x960x8 C0000000 
0165 1280x960x16 C0000000 
0166 1280x960x32 C0000000 
0121 640x480x32 C0000000 
0122 800x600x32 C0000000 
0123 1024x768x32 C0000000 
0124 1280x1024x32 C0000000 
0143 1400x1050x8 C0000000 
0145 1400x1050x16 C0000000 
0146 1400x1050x32 C0000000 
0173 1600x1200x8 C0000000 
0175 1600x1200x16 C0000000 
0176 1600x1200x32 C0000000 
0183 1792x1344x8 C0000000 
0185 1792x1344x16 C0000000 
0186 1792x1344x32 C0000000 
01D3 1856x1392x8 C0000000 
01D5 1856x1392x16 C0000000 
01D6 1856x1392x32 C0000000 
01E3 1920x1440x8 C0000000 
01E5 1920x1440x16 C0000000 
01E6 1920x1440x32 C0000000 
01D1 1920x1200x8 C0000000 
01D2 1920x1200x16 C0000000 
01D4 1920x1200x32 C0000000 
    

Dirk
Post 07 Aug 2012, 07:40
View user's profile Send private message Send e-mail Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Heres a demo that may help.


Description:
Download
Filename: BmpView.zip
Filesize: 426.53 KB
Downloaded: 106 Time(s)

Post 07 Aug 2012, 15:06
View user's profile Send private message Reply with quote
freecrac



Joined: 19 Oct 2011
Posts: 117
Location: Germany Hamburg
freecrac
The following sample shows how to get the modenumber of a repuested resolution with a VBE2 or VBE3 bios.
Because we can not be sure if these modenumbers 4112h = 32/24bit ; 0x4101 = 256bit ;4111h = 65535bit (640*480) exist in the modetable of our vesa bios and if those numbers exist, if they enable to set the repuested resolution and bits per pixel. (Maybe the requested resolution become an other number from the card manufacturer.)
Code:
MaxX = 640   ; Horizontal resolution
MaxY = 480   ; Vertical resolution
BpP  = 8     ; 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

; ------Our DS-SEG-----
VINF   DB 512 dup (0AAh) ; Buffer for Vesa-Info(4F00h)
MINF   DB 256 dup (044h) ; Buffer for Mode Info(4F01h)
    

And if we want to use a resolution with 16, 24 or 32 bit per pixel, then we have to make sure wich fild position and mask size we can use. (With 5:5:5 or 5:6:5, or RGB or BGR.)
For to calculate an address of a pixel we have to use the content of the word in the mode info buffer reference to "bytes per scanline", or "LinBytesPerScanLine" (if we use linear modes),
because the length of the scanline can be be longer as the length of the visible horizontal resolution.

vbe3.pdf
Quote:

Starting with VBE version 2.0, VESA will no longer define new VESA mode
numbers and it will no longer be mandatory to support these old mode
numbers. OEM's who wish to add new VBE mode numbers to their
implementations, must make sure that all new modes are defined with
mode numbers above 0x100, However, it is highly recommended
that BIOS implementations continue to support these mode numbers for
compatibility with older software and add new mode numbers after the last
VESA defined mode number). VBE 2.0-aware applications should follow the
guidelines in Appendix 5 - Application Programming Considerations
- for setting a desired mode.


Dirk
Post 08 Aug 2012, 04:45
View user's profile Send private message Send e-mail Reply with quote
ivan_tux



Joined: 23 Jun 2012
Posts: 27
Location: Indonesia
ivan_tux
Quote:

VESA modelist of the Sapphire 7950
Vesamode,XRes,YRes,Bits per Pixel,Adresse des Framebuffer
0100 640x400x8 C0000000
0101 640x480x8 C0000000
0103 800x600x8 C0000000
0105 1024x768x8 C0000000
0107 1280x1024x8 C0000000
0110 640x480x16 C0000000
0111 640x480x16 C0000000
0113 800x600x16 C0000000
0114 800x600x16 C0000000
0116 1024x768x16 C0000000
0117 1024x768x16 C0000000
0119 1280x1024x16 C0000000
011A 1280x1024x16 C0000000
010D 320x200x16 C0000000
010E 320x200x16 C0000000
0120 320x200x32 C0000000
0193 320x240x8 C0000000
0195 320x240x16 C0000000
0196 320x240x32 C0000000
01B3 512x384x8 C0000000
01B5 512x384x16 C0000000
01B6 512x384x32 C0000000
01C3 640x350x8 C0000000
01C5 640x350x16 C0000000
01C6 640x350x32 C0000000
0133 720x400x8 C0000000
0135 720x400x16 C0000000
0136 720x400x32 C0000000
0153 1152x864x8 C0000000
0155 1152x864x16 C0000000
0156 1152x864x32 C0000000
0163 1280x960x8 C0000000
0165 1280x960x16 C0000000
0166 1280x960x32 C0000000
0121 640x480x32 C0000000
0122 800x600x32 C0000000
0123 1024x768x32 C0000000
0124 1280x1024x32 C0000000
0143 1400x1050x8 C0000000
0145 1400x1050x16 C0000000
0146 1400x1050x32 C0000000
0173 1600x1200x8 C0000000
0175 1600x1200x16 C0000000
0176 1600x1200x32 C0000000
0183 1792x1344x8 C0000000
0185 1792x1344x16 C0000000
0186 1792x1344x32 C0000000
01D3 1856x1392x8 C0000000
01D5 1856x1392x16 C0000000
01D6 1856x1392x32 C0000000
01E3 1920x1440x8 C0000000
01E5 1920x1440x16 C0000000
01E6 1920x1440x32 C0000000
01D1 1920x1200x8 C0000000
01D2 1920x1200x16 C0000000
01D4 1920x1200x32 C0000000


All modes starting at 0xC0000000 ??
I just have 512 MB of RAM ! Surprised
Post 17 Aug 2012, 16:37
View user's profile Send private message Reply with quote
freecrac



Joined: 19 Oct 2011
Posts: 117
Location: Germany Hamburg
freecrac
ivan_tux wrote:
All modes starting at 0xC0000000 ??

Yes, the first linear framebuffer will be mapped into the adress space at 0xC0000000 (Sapphire 7950 + ASUS Striker 2 formular).
(The address can be vary with other cards, but most times the linear framebuffer will be mapped somewhere in the 4.GB.)

0xC0000000 - 0xCFFFFFFF first linear framebuffer
0xEFE80000 - 0xEFEBFFFF (info from the windows devicemanager) should be the physical address of the secondary linear framebuffer

0x000A0000 - 0x000BFFFF for lower resolution and banked modes (VGA controller standard address for to map and show the screen content of a grafik mode)
Quote:
I just have 512 MB of RAM ! Surprised

No problem, because videocards comes with own videoram and a part of this videoram will be mapped into our addressspace.
Also if we have a lesser size of physical ram pluged into our mainboard (example with 512 KB or 256 KB with older boards from the past years ago using first VGA cards with banked modes).

Dirk
Post 18 Aug 2012, 06:39
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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 GitHub, YouTube, Twitter.

Website powered by rwasa.