flat assembler
Message board for the users of flat assembler.

Index > DOS > VESA programming

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
I'm begginer in assembler and I want learn code banked VESA. I read VBE2.pdf but I dunno optimize. Has you VESA banked code for FASM or anather assembler for example? I read kelvar, but there is no bancked and I don't understand to much Sad I have old computer video card 2MB VRAM VESA 1.2 suport and I want test it in my computer. Thanks.
Post 29 Jul 2008, 13:26
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 708
Location: Adelaide
sinsi
Here's something I've played with on and off...no comments, no error checking, assumes vesa is there etc, but it's a start

hmmm...no attachment - try again (doesn't like .fasm


Description:
Download
Filename: vesarm.asm
Filesize: 2.52 KB
Downloaded: 231 Time(s)

Post 29 Jul 2008, 14:33
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
Thanks sinsi I'll look at it. Seem very good for my begin with VESA programming.
Post 29 Jul 2008, 16:27
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> begginer in assembler and I want learn code banked VESA. I read VBE2.pdf but I dunno optimize.

VBE2 just introduced the LFB Smile

> Has you VESA banked code for FASM or anather assembler for example?

NO. But what's your card ? There are some drivers around Idea

I don't use bancrupted VESA ... but probably trivial, just set mode and write into VGA RAM. When you have it, find out how to switch the banks.

Evil note 1 : the bank size is not fixed Sad
Evil note 2 : with 24bpp one pixel can sit in 2 banks Shocked
Summary: banked VESA is CRAP Sad


Last edited by DOS386 on 26 Aug 2008, 04:23; edited 1 time in total
Post 23 Aug 2008, 07:28
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
Summary: banked VESA is CRAP

but is the only crap present on many computers without card-specific coding
Post 23 Aug 2008, 07:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> present on many computers without card-specific

AFAIK there are drivers bringing VESA 2.0 Smile
Post 23 Aug 2008, 07:48
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 708
Location: Adelaide
sinsi
linear is for tinkerbells...only works in PM or flatreal.
understand banked mode, understand more about video...

latest nvidia cards are vbe3 (my 8800gt)
latest ati cards are vbe2 (my old 9600pro)

I associate vbe1.2 with the days of cirrus/diamond et al
I still managed my dos programs using vesa1.0
Post 23 Aug 2008, 07:59
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
DOS386 wrote:
AFAIK there are drivers bringing VESA 2.0 Smile


My card is Trident ISA with 2MB VRAM. UNIVBE enable VESA 3.0, but when I run games the screen flashes horribly, they look much better without UNIVBE, using only banked VESA, and are almost as fast, so even if LFB is easier to program, I prefer banked.
Post 24 Aug 2008, 07:36
View user's profile Send private message Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
In the next couple of days I'll post my code for a DOS program which displays a 256-colour Windows bitmap image using banked/paged VESA programming in video mode 101 (640 x 480). It will be based on the code I have used in FAMOS which I developed from scratch using a trial amd error technique Smile , after I discovered that many older VESA cards do not support linear buffering (mode 4101) Sad

_________________
FAMOS - the first memory operating system
Post 25 Aug 2008, 19:07
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
> My card is Trident ISA with 2MB VRAM. UNIVBE enable VESA 3.0

Maybe 2.0 only ? As suspected Very Happy

> but when I run games the screen flashes horribly, they look much better without UNIVBE

Sad Sad Bugged UNIVBE, bugged card or you are doing wrong (no DOS ? boot "DOS" via ME ?)

> I read VBE2.pdf but

Too much Very Happy

Download now :

http://board.flatassembler.net/download.php?id=3913 VESA spec | 580 KiB

http://board.flatassembler.net/download.php?id=3915 VESA code, uses LFB only | 46 KiB
Post 26 Aug 2008, 04:22
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
DOS386 wrote:
Maybe 2.0 only ? As suspected Very Happy


No, VESA 3.0. But is option in UNIVBE to desable VESA 3.0 extension and have just 2.0, but it no work better.

DOS386 wrote:
Sad Sad Bugged UNIVBE, bugged card or you are doing wrong (no DOS ? boot "DOS" via ME ?)


Plain DOS, very good card even if old, lastest UNIVBE.
Post 26 Aug 2008, 05:30
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
sinsi wrote:
I associate vbe1.2 with the days of cirrus/diamond et al
I still managed my dos programs using vesa1.0

Card on my notebook (Intel something) only has vesa1.0. Maybe UNIVBE would do the trick, but maybe not...
Post 26 Aug 2008, 08:22
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
@neville
Thanks. I want to know if you have put horizontal line of color for 24bit per pixel banked modes. Put bitmap line is easier for that modes, is like in the others banked modes, and put pixel of color is not hard even if you have to test for bank change and change the bank sometime. But I not find still good looking fast 24bit per pixel horizontal line of color code for banked VESA.
Post 26 Aug 2008, 13:06
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
See here for simple vesa bank switching example
http://board.flatassembler.net/topic.php?t=6032
Post 26 Aug 2008, 15:24
View user's profile Send private message Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
Thanks Dex4u, but still no banked 24bit per pixel horizontal line of color Sad .
Post 27 Aug 2008, 06:53
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
What's the deal with banked/nonbanked??? Everything real uses at least one backbuffer anyway, and copying backbuffer to banked buffer is primitively easy.
Post 27 Aug 2008, 07:40
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Shahada



Joined: 25 Jul 2008
Posts: 77
Shahada
@vid
Maybe you say true vid, but for learn purpose I want to see a 24bit per pixel horizontal line directly to screen in case of banked modes. I think is tricky to do it as fast as it can be and I want to see what ideas are for this.
Post 27 Aug 2008, 07:53
View user's profile Send private message Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
Here's my paged VESA demo program to display 8-bit Windows bitmaps in DOS, based on my Flat-Real FAMOS code. I haven't used any string instructions because in FR mode it's a pain to set up the required segments in DS and ES.

The attached file is an executable version which displays a well-known image. Its an EXE but "not allowed" so extension renamed to ZIP Smile

Bitmaps should be 640x480 or less in size, and must be Windows bitmaps, not OS/2.

Sometimes the bitmaps are displayed on a slant. I've never figured out why - does anybody know? The slant can be corrected by changing the image width stored in the BMP header, so I've added 'W' and 'w' commands to increase and decrease the image width while the image is being displayed - see the source code below.

Code:
;---------------------------------------------------------------------------
;  W A T K I N    T E C H N O L O G Y    S o f t w a r e  D i v i s i o n
;---------------------------------------------------------------------------
; PROGRAM: Paged VESA Demo Mode 101 (640 x 480 x 8bit) - DOS Bitmap Viewer
; VERSION: 1.0                            PLATFORM: IBM PC
; PROJECT: FAMOS Memory Operating System      FILE: VESADEMO.ASM
;  AUTHOR: Neville Watkin                     DATE: 28 Aug 2008
;---------------------------------------------------------------------------
;                            Revision History
;
;28.08.08  Port to DOS from FAMOS (INT21/09 for string display, no PCA etc.)
;---------------------------------------------------------------------------
;                ORG     0100H           ;flat real COM can be >64K, but
                FORMAT  MZ              ;need DOS .EXE for embedded BMPs >64K

                PUSH    CS
                PUSH    CS
                POP     DS              ;make EXE like COM...
                POP     ES              ;(but let DOS set stack)

                MOV     AX,4F01H
                MOV     DI,VESABUF
                MOV     CX,101H         ;check mode 101
                INT     10H
                CMP     AL,4FH
                JNZ     BADVESA

                XOR     EAX,EAX
                MOV     AX,WORD[ES:DI+4] ;get video Page Granularity
                MOV     DX,AX           ;save it
                MOV     CX,1
GETPGSH:        INC     CX
                SHR     AX,1
                JNC     GETPGSH         ;Page Gran. shift = log2(PGran) + 2
                MOV     WORD[PGSHFT],CX ;save PageShift factor
                MOV     AX,DX           ;restore PGran
                SHL     EAX,0AH         ;multiply by 1K
                DEC     EAX             ;-1 = video page offset mask
                MOV     DWORD[VMASK],EAX ;save it

TRYAGAIN:
                MOV     ESI,IMAGE
                MOV     AL,BYTE[ESI+1CH]
                CMP     AL,08H
                JZ      DRAW
BADVESA:
                MOV     AX,3
                INT     10H
                MOV     DX,ERRMSG
                MOV     AH,9
                INT     21H
                CALL    WAITKEY
                JMP     EXIT

BADDATA:
                MOV     AX,3
                INT     10H
                MOV     DX,ERRMSG1
                MOV     AH,9
                INT     21H
                CALL    WAITKEY
                JMP     EXIT

DRAW:           CALL    INIT101         ;set video mode
                ADD     ESI,36H
                MOV     CX,100H         ;256 palettes
                CALL    PALPROG         ;set palettes
                MOV     ESI,IMAGE
                CALL    DIM256
                CALL    WAITKEY
                CMP     AL,"W"          ;this code often displays bitmaps
                JZ      INCWIDTH        ;slanting to right or left. Correct
                CMP     AL,"w"          ;by pressing W or w as many times as
                JZ      DECWIDTH        ;needed...
EXIT:
                MOV     AX,0003         ;restore video mode
                INT     10H
                MOV     AH,4CH
                INT     21H

INCWIDTH:       MOV     EDX,DWORD[ESI+12H] ;corrects image slanting to right
                CMP     EDX,0FFFFFFFEH     ;by increasing the width in the
                JA      TRYAGAIN           ;bitmap header
                INC     EDX
                MOV     DWORD[ESI+12H],EDX
                JMP     TRYAGAIN
DECWIDTH:       MOV     EDX,DWORD[ESI+12H] ;corrects image slanting to left
                CMP     EDX,0              ;by decreasing the width in the
                JZ      TRYAGAIN           ;bitmap header
                DEC     EDX
                MOV     DWORD[ESI+12H],EDX
                JMP     TRYAGAIN

ERRMSG:
 DB 10," The video card in this computer does not support VESA 101$",13,10
ERRMSG1:
 DB 10," Sorry, the data format is invalid - press any key to exit...$",13,10
;----------------------------------------------------------------------------
;  INITIALIZE VESA MODE 101
;----------------------------------------------------------------------------
INIT101:
                MOV     AX,4F02H        ;select 640x480 SVGA video mode
                MOV     BX,0101H        ;using PAGED memory model
                INT     10H
                RET
;----------------------------------------------------------------------------
;  PALETTE PROGRAMMING
;----------------------------------------------------------------------------
;direct CRT controller register access
;enter with ESI pointing to 4-byte palette data B G R 0, CX=no. palettes
PALPROG:        CLI
                PUSH    ESI
                MOV     DX,3C8H
                XOR     AL,AL
                OUT     DX,AL
PROG:           MOV     AL,[ESI+2]
                SHR     AL,2
                MOV     DX,3C9H
                OUT     DX,AL           ;set red
                MOV     AL,[ESI+1]
                SHR     AL,2
                OUT     DX,AL           ;set green
                MOV     AL,[ESI]
                SHR     AL,2
                OUT     DX,AL           ;set blue
                ADD     ESI,4
                LOOP    PROG
                POP     ESI
                STI
                RET
;----------------------------------------------------------------------------
;  DISPLAY IMAGE (256-colour BMP)
;----------------------------------------------------------------------------
;enter with DS=0,ESI=image source
DIM256:         PUSH    ESI             ;save image source
                MOV     EDI,4AD80H      ;screen line 479+hor 0
                XOR     EAX,EAX
                MOV     AX,WORD[ESI+8H] ;get vert offset
                XOR     EBX,EBX
                MOV     BX,640
                MUL     EBX             ;calc adj for vert offset
                SUB     EDI,EAX         ;apply vert offset
                XOR     EAX,EAX
                MOV     AX,WORD[ESI+6H] ;get horiz offset
                ADD     EDI,EAX         ;add horiz offset
                MOV     EAX,EDI
                MOV     CL,BYTE[PGSHFT] ;PageShift factor
                SHR     EAX,CL          ;AH=current vRAM page
                XOR     DX,DX
                MOV     DL,AH           ;get page into DX
                XOR     BX,BX           ;set window 0
                PUSH    AX              ;save current page
                MOV     AX,4F05H        ;set initial page
                INT     10H
                POP     AX              ;restore current page
                MOV     ECX,[ESI+16H]   ;bmp vert height at 0016H
                MOV     EBX,[ESI+12H]   ;bmp width at 0012H
                ADD     ESI,[ESI+0AH]   ;bmp image data at 000AH
                MOV     EBP,DWORD[VMASK] ;offset mask for video page
NEXTLINE:
                CALL    DLINE           ;display a line of image data
                SUB     EDI,280H        ;go to next line up (280H=scr width)
                SUB     EDI,EBX         ;reset to LHS (EBX=img wdth)
                LOOP    NEXTLINE
                POP     ESI             ;restore image source
                RET
;----------------------------------------------------------------------------
;  DISPLAY ONE HORIZONTAL LINE OF PIXELS (VESA Mode 101)
;----------------------------------------------------------------------------
;enter with vRAM offset (was dest) addr = 0:EDI, BMP image data addr = 0:ESI
;bmp height in ECX, bmp width in EBX, AH=current vRAM page, EBP=offset mask
DLINE:
                PUSH    ECX             ;save height
                PUSH    EBX             ;save width for next line
                MOV     CL,BYTE[PGSHFT] ;PageShift factor
DLINE1:         MOV     EDX,EDI         ;save EDI
                SHR     EDX,CL          ;AH=current vRAM page
                XOR     DL,DL
                XCHG    DH,DL           ;get VRAM page in DX (DL)
                CMP     AH,DL           ;same as current page?
                JZ      SAMEPAGE        ; -yes, don't change it
                PUSH    BX
                MOV     AX,4F05H        ; -no, change the page ("window")
                XOR     BX,BX           ;ready to "set Window 0" (fn 4F05)
                INT     10H
                MOV     AH,DL           ;update current page
                POP     BX
SAMEPAGE:
                MOV     EDX,EDI         ;save EDI again
                AND     EDI,EBP         ;remove page bits =>  16-bit offset
                ADD     EDI,0A0000H     ;add vRAM "segment" => 32-bit addr
                MOV     AL,[ESI]        ;get image palette
                PUSH    0000
                POP     DS
                MOV     [EDI],AL        ;write palette to vRAM
                PUSH    CS
                POP     DS
                MOV     EDI,EDX         ;restore EDI (32-bit offset)
                INC     ESI
                INC     EDI
                DEC     BX              ;next pixel (could use EBX)
                JNZ     DLINE1
                POP     EBX
                POP     ECX
                RET
;----------------------------------------------------------------------------
;  WAIT FOR KEYPRESS (DEBOUNCED)
;----------------------------------------------------------------------------
WAITKEY:        MOV     AH,01
                INT     16H             ;get keyboard status
                MOV     AH,00           ;select Wait for Key service
                JZ      GOTKEY          ;when key gone, go get it
                INT     16H             ;else flush the buffer
                JMP     WAITKEY         ;and wait for it again
GOTKEY:         INT     16H             ;read key from keyboard buffer
                RET

;----------------------------------------------------------------------------
;  DATA
;----------------------------------------------------------------------------
ALIGN 2

PGSHFT: DW 0                    ;Page Granularity Shift factor (byte only used)
VMASK: DD 0                     ;video page offset mask

ALIGN 16
VESABUF:                        ;scratch area for VESA info
 TIMES 512 DB 0
IMAGE:
; FILE 'YOURFILE.BMP'            ;put your 256-colour Windows bitmap here...
 FILE 'MONALISA.BMP'    


Description: This is not a ZIP file - please rename it to .EXE
Download
Filename: VESADEMO.ZIP
Filesize: 73.03 KB
Downloaded: 122 Time(s)


_________________
FAMOS - the first memory operating system
Post 28 Aug 2008, 11:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17663
Location: In your JS exploiting you and your system
revolution
neville wrote:
The attached file is an executable version which displays a well-known image. Its an EXE but "not allowed" so extension renamed to ZIP
How about really ZIPping up the exe and posting the real ZIP. That will save some disk space and download time also.
Post 28 Aug 2008, 11:59
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
revolution wrote:
Quote:
How about really ZIPping up the exe and posting the real ZIP. That will save some disk space and download time also.

When it rejected the EXE I tried various extensions including EEX, DAT etc, but ZIP was the first one that was accepted...

It was only 74K, but OK, the attached 43K ZIP contains the FASM source above, plus the EXE.

Actually you will end up with less disk space unless you delete the ZIP after unzipping it Wink


Description: This is a real ZIP.
Download
Filename: VESADEMO.ZIP
Filesize: 43.19 KB
Downloaded: 113 Time(s)


_________________
FAMOS - the first memory operating system
Post 28 Aug 2008, 22:26
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  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 GitHub, YouTube, Twitter.

Website powered by rwasa.