How i can Translate MAKEPOINTS macro to PB?

Just starting out? Need help? Post your questions and find answers here.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

How i can Translate MAKEPOINTS macro to PB?

Post by nicolaus »

Hello

How i can translate the MAKEPOINTS macro (WinAPI) to Purebasic?

Thank you

Nico
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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... :)
--Kale

Image
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

I'll assume i got it right then. :P
--Kale

Image
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Post 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
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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..
Post Reply