Page 1 of 1
How i can Translate MAKEPOINTS macro to PB?
Posted: Sun Dec 12, 2004 11:49 pm
by nicolaus
Hello
How i can translate the MAKEPOINTS macro (WinAPI) to Purebasic?
Thank you
Nico
Posted: Mon Dec 13, 2004 12:17 am
by Kale
Something like this?
Code: Select all
DWORD_CONTAINING_COORDS.l = %00000100000000000000001100000000
Procedure.l MakePoints(Value.l)
Static Coords.POINT
Coords\x = Value & $FFFF
Coords\y = (Value >> 16) & $FFFF
ProcedureReturn @Coords
EndProcedure
*POINTS_STRUCTURE = MakePoints(DWORD_CONTAINING_COORDS)
XPos.l = PeekW(*POINTS_STRUCTURE + 4)
YPos.l = PeekW(*POINTS_STRUCTURE)
Debug XPos
Debug YPos
[edit] Can someone else confirm if this is right, im a bit drunk and i think im getting my hi/loword mixed up! hic...hic...

Posted: Tue Dec 14, 2004 4:00 pm
by Kale
I'll assume i got it right then.

Posted: Tue Dec 14, 2004 5:54 pm
by Justin
i would say is
Code: Select all
Procedure.l MakePoints(Value.l)
Static Coords.POINT
Coords\x = Value & $FFFF
Coords\y = Value >> 16
ProcedureReturn @Coords
EndProcedure
you don't need the extra '&' to get the high word part
Posted: Tue Dec 14, 2004 6:09 pm
by Pupil
Justin wrote:i would say is
Code: Select all
Procedure.l MakePoints(Value.l)
Static Coords.POINT
Coords\x = Value & $FFFF
Coords\y = Value >> 16
ProcedureReturn @Coords
EndProcedure
you don't need the extra '&' to get the high word part
I would say that you need the extra '&' because PB uses arithmetic shift so if bit 32 is set 1:s are shifted in from the left. Just try your procedure with a negative number and see..