Direct Memorry Accessing?

BlitzMax Forums/BlitzMax Programming/Direct Memorry Accessing?

Function PokeByte( addr,value )
(Byte Ptr addr)[0]=value
End Function

Function PeekByte( addr,value )
Return (Byte Ptr addr)[0]
End Function

...etc with Int Ptr and so on...

However, you're better just sticking with pointers and [] if you want to do lots of mem access, eg:

Local p:Byte Ptr=MemAlloc( 1024 )
p[0]=0 'same as Poke p,0
p[1]=1 'same as Poke p,1 etc...don't poke beyond 1023 though!

If you need to cast the pointer:

(Int Ptr p)[0]=0 'pokes p[0..3]
(Int Ptr p)[1]=1 'pokes p[4...7]

And if you need to poke an int into a non-4 byte aligned offset:

(Int Ptr (p+offset))[0]=0