I used ddraw.all as my test case. This is not meant to be a tutorial on Direct-Draw.

This has been quite a learning experience for me. How to prototype a function that the location is not know and there is no name or relocation data to import? Well that kinda the case with dlls....

So I decided to see if I could get MASM to prototype and invoke a procedure pointer in a vtable.

I've done it. I can do stuff like:

invoke CreateSurface, LPDD, ADDR ddsd, ADDR LPDDSF, 0

No macros used.

It's probably not very clever for some here, but perhaps someone can learn something usefulfrom my code.
If you assemble and run, the exe will make a 640x480 window that shows whatever garbage is in the backbuffer.

You could use the same method for any dll, or vtable you pointer that you want to use a real name for.
Posted on 2002-10-03 04:43:22 by ThoughtCriminal
nice work ThoughtCriminal
... it is more clean now

one request: if you have time to write a small tutorial
about directdraw using your technique.

thanks,
TBD


i found a nice DirectX Tutorial [.DOC]
Posted on 2002-10-03 05:50:09 by TBD
I was asked by PM if one could use DX to get a pointer to the desktop surface.

I just found out you can. Here is my quickly hacked code:



invoke DS_mLock, LPDDSF, 0, ADDR ddsd, DDLOCK_WAIT, 0
mov eax, [ddsd.lpSurface]
mov Logical, eax ;
invoke DS_Unlock, LPDDSF, ddsd.lpSurface

mov edx, -1
lea eax, Logical
mov eax,[eax]

mov ecx, 256
@@:
mov [eax],edx
add eax, 4
loop @B

Change LPDDSB to LPDDSF.

The above puts white line in the upper corner of my desktop window.

32-bit mode Geforce2. You card might work diffrently.

You are not supposed to write to a surface outside a Lock-Unlock block. Use at your own risk.
Posted on 2002-10-05 01:05:37 by ThoughtCriminal
thanks for sharing ...
if you live LPDDSB you can paint on the window, right ?
the problem is that is kinda slow ...

what is wrong, if i changed to this it displays:
		

lea eax, Logical
mov eax,[eax]

mov ecx, 640*480
mov edx, 000FF00h
@@:
mov [eax],edx
add eax, 4
loop @B


if i changed to this it displays a pattern, not a filled screen ...
hmmm
Posted on 2002-10-07 00:56:47 by TBD
Quick note:

LPDDSF = front or primary display
LPDDSB = back or offscreeen surface.

Regarding the code; it was just a quick hack to diplay somethind on the screen.

I posted my card type and bit depth. The code I gave works for a Geforce card at 32-bit depth.

The code is solw, it is not the best way to draw, it is just a hack. You don't really want to put pixels one-by-one. It would be better to keep your bitmap resouces in a buffer(or mabey a DDsurface)and use the BltFast method to blit to the backbuffer. Directx can use the cards blitter.

Regarding you screenshot, I do not know what video card you have, or what bit depth you are running in.
You will have different results running in 16, 24, or 32. If you are in 16-bit mode try changeing add eax,4 to add eax, 2.

I'm not an expert in DirectX yet, I'm still earning alot of this stuff. If you have any more questions, I try to answer.
Posted on 2002-10-07 03:28:46 by ThoughtCriminal
my system: WinNT4SP6, Intel 82815 chip on gfx card
i am in 1024x768x16bit

no changes if i modify add eax, 4
what is weird that i works if i put edx with -1 (0FFFFFFh = white) :)
Posted on 2002-10-07 04:23:25 by TBD
This does not bring the pixels together?:


lea eax, Logical
mov eax,[eax]

mov ecx, 640*480
mov edx, 000FF00h
@@:
mov [eax],edx
add eax, 2 <*****************?
loop @B


I don't use 16 bit mode so I'm not sure.

For 32 bit color there is:

ARGB
BGRA

and maybe some others.
So 32 bit color is:

byte1||byte2||byte3||byte4
A R G B

8 bits each for red green and blue

16 bit is somthing like:

byte1||byte2
5 6 5 red=5 bit green = 6 bits blue = 5 bits or
5 5 5 red=5 bit green = 5 bits blue = 5 bits

-1 is the same as filling the memory with FFFFFFFF, which put a color value of 255 in each color(32 bit)

Try putting 1Fh in edx, you should get pure blue.

3E0h should be green, or 7E0h

1F800h for red.....maybe
Posted on 2002-10-07 08:05:11 by ThoughtCriminal
add eax, 2 put the lines only half of the screen ...

i can get a filled screen if i put all bytes with the same value:
mov edx, 3E3E3E3Eh

and i get a grey screen

i tested with 1Fh, 3Eh - same lines problem.
( in 24bit, 16bit works ok)


dumb me ... i was in 24bit mode ... sorry

paper on pixel addressing in direct x here (it is in greek, but has pictures in english)

maybe someone can translate this :rolleyes:
Posted on 2002-10-07 08:48:13 by TBD