New pointer syntax

BlitzMax Forums/BlitzMax Programming/New pointer syntax

Steve Elliott(Posted 2005) [#1]
What's the equivalent code using the new pointer syntax?

Local centre_ptr:Int Ptr

centre_ptr = centre_sqr                   ' pointer to centre square array

For Local square:Int = 1 To 64

  nearest_sqr = Var(centre_ptr)
  x = Var(centre_ptr+1) + board_x ; y = Var(centre_ptr+2) + board_y
                                                      
  ' etc

  centre_ptr :+ 3

Next



Azathoth(Posted 2005) [#2]
This is I think

Local centre_ptr:Int Ptr

centre_ptr = centre_sqr                   ' pointer to centre square array

For Local square:Int = 1 To 64

  nearest_sqr = centre_ptr[0]
  x = centre_ptr[1] + board_x ; y = centre_ptr[2] + board_y
                                                      
  ' etc

  centre_ptr :+ 3

Next



Steve Elliott(Posted 2005) [#3]
That doesn't seem to work Azathoth - but I use pointers throughout my program so it might be another routine that also needs to be modified.


Azathoth(Posted 2005) [#4]
Is 'Var(centre_ptr+1)' using an offset of 1 byte or 1 int (4 bytes)? If its 1 byte you might have to cast it to a byte pointer or use banks.


Steve Elliott(Posted 2005) [#5]
Int...

Local centre_ptr:Int Ptr