DirectDraw inline assembly fill_screen()
Posted on 1997-05-18
i am having a lot of fun with DirectDraw at the moment, but i'm trying to do some inline assembly coding that essentially involves direct screen writes, which thankfully, we can now do because of DirectX. it's about time!
so, anyway, the following code works just fine to fill the screen with "color" on a 640x480x8 resolution direct draw primary surface.
video_buffer = (unsigned char far *)ddsd.lpSurface;
memset(video_buffer, color, 640*480*2);
video_buffer[640*430+200] = 123;
this code fills the screen with "color" and plots the point 640*430+200 in the color 123 (some sort of green color :)
because i am interested in speed and not elegance, i tried to code this same function in inline assembly and that code looks like this:
// fill the video buffer using inline assembly - it's fast!
les di,video_buffer ; point es:di to video buffer
mov al,BYTE PTR color ; move the color into al
mov ah,al ; replicate color into ah
mov cx,640*480 ; number of words to fill
rep stosw ; move the color into the video buffer fast!
the application gets to this code and nothing happens. unfortunately, it also causes the program to quit. since i am grabbing the entire screen (DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) i cannot debug the program. sufice it to say that the fill function is entered, and if i don't use the inline assembly code, everything works as it's supposed to work. if i try to use my inline assembly instead of memset, it does not work and the application dies.
help? are there many of you using DirectDraw? nebulous question :)
setting children free world-wide!!
no shame press
p.o. box 40039
san francisco, ca 94140-0039
rape crisis hotline (24hr): 800.796.7363/pin: 1099608