[futurebasic] Re: Re: [FB] More byte bitten

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1998 : Group Archive : Group : All Groups

From: IMann49542@...
Date: Thu, 10 Dec 1998 10:42:36 EST
Another approach possibly..

	I had  a situation where I was trying to remember a sequence of moves between
two squares on a game board. The possible moves were up down left and right,
ie 4. These could be represented by binary 00,01,10,11 which were held as
strings in array bChar$().

  bPos%(0) = 15
  bPos%(1) = 1
  bPos%(2) = 3
  bPos%(3) = 5
  bPos%(4) = 7
  bPos%(5) = 9
  bPos%(6) = 11
  bPos%(7) = 13

                    BitPos% = SPtr&.MovesToSquare% MOD 8
                    WordNum% = SPtr&.MovesToSquare% / 8
                    bddr& = basememaddr& + WordNum% * 2 - Gets to the right
position
                    a$ = BIN$(bddr&.SqMove%)   -  Gets the two bytes as a
binary string
                    MID$(a$,bPos%(BitPos%),2) = bChar$(CheckCount%) - sticks
them in the right place
                    b$ = "&X" + a$ - reformats
                    bddr&.SqMove% = VAL (b$)  - sticks the full two bytes back
into memory

No peeks pokes or blockmoves, well actually I tried them first.

Ian Mann