Results 1 to 13 of 13

Thread: drawing a pixel using asm

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    drawing a pixel using asm

    I don't know much asm so I want to know how you draw a pixel on the screen (you can also provide the x and y positions). I have seen this exaple in an asm tutorial but I can't find that.

    BTW will the code of drawing pixel only work with DOS?
    Baaaaaaaaah

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Drawing pixels is only for DOS apps, windows doesn't allow it. You can draw pixels directly to the screen using DirectX, there you could assembly.
    There are many books about DirectX and Game Programming, most of them by André LaMothe.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Zaei
    Guest
    You can Get the Destktop DC, and then (assuming MSVC++ here)
    Code:
    __asm
    {
         push DC
         push x
         push y
         call [SetPixelV]
    }
    I dont know if that will work (it does sometimes, in Pascal...). ASk in the Assembly Forums.

    Z.

    [edit]
    it may be push DWORD DC, and push WORD x, but I dont know. The order might be wrong as well.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    yeah, but I'm sure that's not what he wanted to do. Why go through this when you can simply write:
    SetPixel(dc, x, y, etc.);
    and forget asm?
    Writing directly to the video memory is only possible in DOS or DirectX (IDirectDrawSurface::Lock to get pointer to memory)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I don't want to use windows API (which is SetPixel or SetPixelV). You know how you use asm to move the row and column # and the pixel color to two registers and then you call a function or something like that to draw a simple dot. That is how I want to do but I want to give it x and y positions instead to row and column#.

    Will that asm code of drawing pixel (using CPU register,memory and video card access) work without DOS or Window Console. I actually thought that I could use my code in DOS and when the computer boots up.
    Baaaaaaaaah

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    basically, yes it will. Just remember that by this, you're dooming yourself by entering the area of hardware specific code (just don't think this works the same way on every video card) :P
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Remember the Miles Sound System? That must have made game developers' lives much happier
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  8. #8

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    That is cool. But what is the actual code to draw the pixel by privding it x and y positions?

    I am searching for that code in asm but can't find that yet.
    It is just a few lines long.
    Baaaaaaaaah

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Well, I think the video memory is something like 0xA0000000 (no idea) and you just index into that.

    However, that won't work under Windows. Most of the knowledge on doing this is long gone, but look up Allegro, that shows you how
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  10. #10
    Zaei
    Guest
    I dont know (never actually gotten it to work, in DOS or otherwise), but I have two demos that use mode 13h, and they work fine on Win2K.

    Z.

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    But they would most likely be dos programs that run in special mode. Either 16-bit or Protected Mode 32-bit as created by DJGPP.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12
    Zaei
    Guest
    Sure, but that isn't the point =). If you are just learning this stuff, as long as it runs, it's great!

    Oh, and parksie, I was reading over some source code last night, and I think you had the memory address for mode13h right. Mah Bad! =).

    Z.

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Did I? It was just a guess (well, I remembered it was all 0s apart from one A...)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width