flat assembler
Message board for the users of flat assembler.

Index > Main > Using VESA mode

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Hey, I just learned how to use VGA mode (sooo SIMPLE!) and now I'm moving on up to VBE3 VESA mode, and I'm trying to print a whole mess of colors to the screen by incrementing the color value each time I go to a new pixel. Now, I can use the loop counter register CX for only WORD values, but the whole screen in even 640 x 480 mode goes beyond the 1 WORD limit (640 * 480 = 307200 decimal, 04B000 in hexadecimal). So after I tried that, I then tried creating my own DOUBLE WORD variable, and in the loop incremented it's value and compared it's value to the full amount of pixels on the screen. All that happens when I do that is that the screen just comes up black. If someone could help me here, I'd be very appreciative. Heres the code:

Code:
org 100h
mov ah, 4Fh    ;tells cpu it's VESA mode
mov al, 02h    ;function for setmode
mov bx, 0101h  ;640 x 480 mode
int 10h

mov bx, 0A000h
mov es, bx
mov bx, 0
mov al, 0

;mov cx, 64000 ;should be 307200, but not sure how to get that much in a loop counter!

startloop:
mov [es:bx], al
inc bx
inc al
inc [mynum]
cmp [mynum], 307200
je done
loop startloop

mov ax, 0100h
int 21h
int 20h

done:
        ret

mynum dd 0
    


Thanks for your time!

-Rhyno
Post 02 Aug 2006, 18:23
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Also, I have another issue, if I try to go any higher than mode 101h (640 x 480 with 256 colors), it compiles okay but when I run it, my monitor puts up a message "Out of scan range" then below that "14.8kHz/154Hz".
Post 02 Aug 2006, 18:38
View user's profile Send private message Reply with quote
donkey7



Joined: 31 Jan 2005
Posts: 127
Location: Poland, Malopolska
donkey7
i've programmed some demos a few years ago - http://asembler.republika.pl/bin/progsy.zip (comments and labels in polish - demos for directx, vesa banked and linear modes - from 320x200x8 to 640x480x24).

there are two vesa modes - banked and linear.

in 16- bit you can use only banked mode. why it's named banked? screen is divided into 64 kb parts called banks. you must switch to apropriate bank before drawing anything on screen.

in 32- bit (protected mode - you can use dpmi, pmodew, wdosx or other pmode servers) you can use linear framebuffer. but it uses paging to map video memory to system memory. it's much faster and imo it's easier to use.

i recommend you linear mode, but if you will be using banked mode don't forget about bank switching. afair it done like that:
Code:
mov ax,$4f05
mov dx,bank_number_starting_from_zero
int $10
    
Post 02 Aug 2006, 20:21
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
I'll be doing this as a test for an OS GUI most likely, but how does accessing the linear framebuffer work? Is that what I'm doing in that program by accessing video memory directly?
Post 03 Aug 2006, 01:35
View user's profile Send private message Reply with quote
donkey7



Joined: 31 Jan 2005
Posts: 127
Location: Poland, Malopolska
donkey7
in both modes you accesses video memory directly. the only difference is that in banked mode you can use only 16- bit addressing, while in linear mode you can use 32- bit addressing and you don't need to switch between banks (which is slow on moder gfx cards).

example of filling screen with color.

16- bit banked mode:
Quote:

number_of_banks = roundup(number_of_pixels / 65536)
a = 0
repeat
switch to bank a
set segment $a000
fill memory from 0 to 65535 with byte color
until a++ = number_of_banks


32- bit linear mode:
Code:
mov edi,screen_bufer
mov ecx,number_of_pixels
mov al,color
rep stosb
    
Post 03 Aug 2006, 11:45
View user's profile Send private message Visit poster's website Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Thanks again, Donkey! I think I get it now... But I'm wondering, with my source code up there, how can I write to all of the screen the way I'm going? Or is it impossible because the loop counter and BX are both only limited to one word each?
Post 03 Aug 2006, 17:54
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
This probably should have gone in the OS Construction area...

What I did is enable gate A20 and setup VESA mode with linear buffer bit set in 16 bit real mode, then switch to protected mode, this allows you to load the 32 bit video address pointer and use ecx to loop your drawing algorithm.

Enabling A20 means it uses linear buffer, as I learnt recently Laughing . Using protected mode you can also use larger screen resolutions easily (if you want).

HTH
Post 03 Aug 2006, 22:19
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Ah, I see! Thanks!
Post 04 Aug 2006, 03:44
View user's profile Send private message 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.

Powered by rwasa.