flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > showing imange in vesa |
Author |
|
yuka 07 Aug 2012, 06:38
Help..??
|
|||
07 Aug 2012, 06:38 |
|
JohnFound 07 Aug 2012, 06:59
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.
|
|||
07 Aug 2012, 06:59 |
|
freecrac 07 Aug 2012, 07:13
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 |
|||
07 Aug 2012, 07:13 |
|
freecrac 07 Aug 2012, 07:40
yuka wrote:
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 |
|||
07 Aug 2012, 07:40 |
|
Dex4u 07 Aug 2012, 15:06
Heres a demo that may help.
|
|||||||||||
07 Aug 2012, 15:06 |
|
freecrac 08 Aug 2012, 04:45
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:
Dirk |
|||
08 Aug 2012, 04:45 |
|
ivan_tux 17 Aug 2012, 16:37
Quote:
All modes starting at 0xC0000000 ?? I just have 512 MB of RAM ! |
|||
17 Aug 2012, 16:37 |
|
freecrac 18 Aug 2012, 06:39
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 ! 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 |
|||
18 Aug 2012, 06:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.