I think, the GDI api LineDDA don't works correct. Look at this. The black line was made with MoveToEx/LineTo and the blue line was made with LineDDA and callback procedure:



Here is my code (in XProfan with inlineassembler XPIA):

{$iq}

Declare x&,y&,text$

Cls

If 0
  AsmInclude
    LineDDAProc proc ;#################################################################################################

      mov eax,
      mov ebx,
      mov ecx,

      invoke SetPixel,ecx,eax,ebx,0FF0000h

      mov eax,1
      ret 12
    LineDDAProc endp
  AsmEnd
EndIf

AsmStart LinePoints(%HDC)

  invoke MoveToEx,para1,40,40,0
  invoke LineTo,para1,400,150
 
  invoke LineDDA,40,40,400,150,addr LineDDAProc,para1

AsmEnd

WaitInput
End


Does someone know what's goeing wrong?

Best regards,
Nordwind64
Posted on 2006-12-23 15:51:58 by Nordwind64
You're trashing EBX?
Posted on 2006-12-23 18:44:52 by f0dder
Thank you f0dder!

You're right. Silly bug... This one works correct:

    LineDDAProc proc ;#################################################################################################

      push ebp
      mov  ebp,esp

      push eax
      push ebx
      push ecx
     
      mov eax,
      mov ebx,
      mov ecx,
      invoke SetPixel,ecx,eax,ebx,0FF0000h

      pop ecx
      pop ebx
      pop eax
     
      pop ebp
      ret 12
    LineDDAProc endp
Posted on 2006-12-24 04:58:23 by Nordwind64
Happens to us all from time to time :)

Remember: register preservation in callbacks.

You don't need to preserve EAX,ECX,EDX so you can get by without any preservation at all... you don't even need to trash registers, you can directly re-push "dword ptr ESP+xx" :)
Posted on 2006-12-24 14:30:24 by f0dder
Hi.

you don't even need to trash registers, you can directly re-push "dword ptr ESP+xx"


...only an examplecode  8)

Regards, Nordwind
Posted on 2006-12-25 04:58:23 by Nordwind64