The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: death-tree on August 14, 2006, 12:49:10 PM

Title: Masm video memory
Post by: death-tree on August 14, 2006, 12:49:10 PM
I'm totally new to Masm and tryed to find some examples of how to write to the the video memory to write or draw pixels onto the screen. Could someone help me and explain how I would achieve this and also how to make a EXE file that runs but without a window.

Thanks to anyhow who replies.
Title: Re: Masm video memory
Post by: hutch-- on August 14, 2006, 01:42:04 PM
Hi death-tree,

Welcome on board. I move the topic to the Campus so you would get more answers.

Writing to video memory in 32 bit protected mode is very different to DOS graphics. Your options are use the GDI Windows API functions or alternatiively use OpenGL or DirectX where you can get direct access to video memory. Have a look in the OpenGL forum as "hitch" knows a lot about this stuff.
Title: Re: Masm video memory
Post by: death-tree on August 14, 2006, 03:04:07 PM
Would you know how to just simply set a pixel onto the screen like in C++: SetPixel(hwnd,X,Y,RGB(255,255,255));
Title: Re: Masm video memory
Post by: mnemonic on August 14, 2006, 04:37:35 PM
Quote from: death-tree on August 14, 2006, 03:04:07 PM
Would you know how to just simply set a pixel onto the screen like in C++: SetPixel(hwnd,X,Y,RGB(255,255,255));

With SetPixel (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_3030.asp) maybe?  :wink

If you do not know how to obtain an HDC and the like. I would suggest you use the forum search as that question comes up very regularly.
Title: Re: Masm video memory
Post by: death-tree on August 14, 2006, 05:51:53 PM
Mhh yes I know how to set a pixel in C++ (I did post the code?!?). I was wondering how to do it in masm.
Title: Re: Masm video memory
Post by: mnemonic on August 14, 2006, 05:56:29 PM
That is not much more difficult.

; Macro borrowed from Iczelions tutorials
RGB macro red,green,blue
    xor    eax,eax
    mov  ah,blue
    shl     eax,8
    mov  ah,green
    mov  al,red
endm

invoke SetPixel, hwnd, X, Y, RGB(255,255,255)


:8)
Title: Re: Masm video memory
Post by: Mark Jones on August 14, 2006, 06:04:56 PM
Quote from: death-tree on August 14, 2006, 12:49:10 PM
...also how to make a EXE file that runs but without a window.

May I ask why you want to do this?

If there is no window, the user cannot close it easily.
Title: Re: Masm video memory
Post by: ToutEnMasm on August 14, 2006, 06:23:52 PM
Hello,
With graphics all begin with getting the graphic space of the object.
If the object is a window whose handle is Hwnd
Quote
     invoke GetDC,Hwnd        ;or other simular functions specified for the painting object
     mov Hdc,eax
     ........
     invoke SetPixel,Hdc, X, Y, RGB(255,255,255)

You can also have to create the object to draw with,for example a pen
Quote
      invoke CreatePen,PS_SOLID,1,couleur
      mov Hpen,eax      
and draw with it when he is created

Quote
invoke MoveToEx,Hdc,10,300,NULL

But cannot do it on the desk,you need a window .
                     
                                         ToutEnMasm


Title: Re: Masm video memory
Post by: death-tree on August 15, 2006, 03:11:12 PM
Nvm about how to make a programme without window.

Anyways thx for the replies, going to give them a try now. Thanks
Title: Re: Masm video memory
Post by: dicky96 on August 15, 2006, 04:23:59 PM
...also how to make a EXE file that runs but without a window.


I've managed to do that quite a few times by accident while trying to learn win32asm so it can't be that difficult  :bg :lol :bg
Title: Re: Masm video memory
Post by: death-tree on August 15, 2006, 08:37:20 PM
Yeah i found out how to do it, it's the same as in C++.