flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Vbe - Wrong way to calculate positions?

Author
Thread Post new topic Reply to topic
Another Stupid Coder



Joined: 24 May 2005
Posts: 5
Location: Vienna, Austria, Europe
Another Stupid Coder
Hi Smile
I've got a little problem with vesa. wrote a bit of code (putpixel,...) a while ago and now i wanted to use it again, but: it doesn't work correctly. when i wrote it, i put only 1 pixel on the screen so i did not realize the bug in that time: pixels are always a bit to far right...
Source:
Code:
PutPixel:
        push            ebp                             ; save extended base pointer.
        mov             ebp,            esp             ; move the stackpointer to ebp.
        push            eax
        push            ebx
        push            edi
        mov             edi,    [LinearFrameBuffer]

        mov             eax,            [ebp + 8]
        shl             eax,            10
        add             edi,            eax
        mov             eax,            [ebp + 8]
        shl             eax,            9
        add             edi,            eax
        mov             eax,            [ebp + 8]
        shl             eax,            6
        add             edi,            eax
        mov             eax,            [ebp + 8]
        shl             eax,            1
        add             edi,            eax
        

        mov             eax,            [ebp + 12]
        shl             eax,            1
        add             edi,            eax
        mov             ax,             1111111111111111b ; color ( 1 unused, 5 red, 5 green, 5 blue).
        mov             [edi],          ax              ; draw the pixel.

        pop             edi
        pop             ebx
        pop             eax
        pop             ebp                             ; restore the basepointer.
        retn            8                               ; return to the main-code and delete the 2 args on the stack.
    

mode is 113h
here's a screenshot: http://ffo-tbc.ath.cx/asc/Bildschirmfoto.png (server is often down -_-)

well, the code with uses putpixel is only:
Code:
push 0
push 0
call PutPixel
push 1
push 1
call PutPixel
push 2
push 2
call PutPixel
push 3
push 3
call PutPixel
push 4
push 4
call PutPixel
push 5
push 5
call PutPixel
push 6
push 6
call PutPixel
    

_________________
terribly bad english speaker.
Post 26 Jun 2005, 14:50
View user's profile Send private message ICQ Number Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade
hmm, well, what mode are you in? resolution and bit depth.

from some calculations, it seems you might be in 1600x1200x16?, not sure though, please post that info.


thanks,
gunblade
Post 26 Jun 2005, 16:30
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Humm, don't you need to take surface *pitch* and not *width* into account under VESA?
Post 26 Jun 2005, 20:40
View user's profile Send private message Visit poster's website Reply with quote
Another Stupid Coder



Joined: 24 May 2005
Posts: 5
Location: Vienna, Austria, Europe
Another Stupid Coder
well, i said 113h...in vesa3 docs its 800x600 with 16bit depth...(1:5:5:5)

EDIT: Hm...its possible that this is the fault: maybe i used 1024x768x24, when using it first.

_________________
terribly bad english speaker.
Post 27 Jun 2005, 11:14
View user's profile Send private message ICQ Number Reply with quote
Octavio



Joined: 21 Jun 2003
Posts: 366
Location: Spain
Octavio
Another Stupid Coder wrote:
well, i said 113h...in vesa3 docs its 800x600 with 16bit depth...(1:5:5:5)

EDIT: Hm...its possible that this is the fault: maybe i used 1024x768x24, when using it first.

Your are doing a multiplication for 1602 not 1600.
Why you donĀ“t use 'mul' instruction?
Post 27 Jun 2005, 11:58
View user's profile Send private message Visit poster's website Reply with quote
Another Stupid Coder



Joined: 24 May 2005
Posts: 5
Location: Vienna, Austria, Europe
Another Stupid Coder
aerhmm...because mul is quite slow, i think...and putpixel should be fast Wink

_________________
terribly bad english speaker.
Post 27 Jun 2005, 12:03
View user's profile Send private message ICQ Number 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.