Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mirror a sprite
#4
Yes - it doesn't mirror a sprite. It returns the input number with the bits reversed.

So hmirror (1) = 128 or in binary hmirror (%00000001) = %10000000
And hmirror (64) =2 or in binary hmirror (%01000000) = %00000010

And so on.

You have to run it over the sprite's data to retrieve each byte the other way around. This means you have a couple of choices - you can reverse each byte of the sprite using hmirror and write it back, so the sprite graphic changes direction in memory (either in a buffer, or where it's stored). You'll have to print multiple square sprites in reverse order too - so a 16 pixel wide sprite tha't's AB becomes mirrored B followed by Mirrored A.

Alrternatively your routine to put it on the screen can choose to poke up reversed bytes if you are doing more direct screen manipulation.

But if you had a standard UDG you could left right reverse it by doing

for i = USR "A" to USR "A" +7
poke i, hmirror (peek i)
next i

For example. This would iterate over the UDG and mirror it left/right - you'd presumably run this when changing directions.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)