defint a-z 'must use this for this algorithm
'rot 90 degrees
'iref is the 1st index of the sprite
'sprData is your array the image is in
'this is info inside each sprite that tells
'qb the dimensions of the sprite
xi = sprData(iref) / 8
yi = sprData(iref + 1)
'this is the integers(or elements) per image
intperimg = (x1 * yi \ 2) + 2
'sets the default segment to that of the
'data array
DEF SEG = VARSEG(sprData(0))
'sets the byte counter up at the first pixel
i = iref * 2 + 4
'converts dimenstions to width and height
wid = xi - 1
hei = yi - 1
'sets rotation point
x0! = wid / 2
y0! = hei / 2
'create temp array
REDIM rotmap(hei, wid)
'do 90 degree rotation inside temp array
FOR y = 0 TO hei
FOR x = 0 TO wid
x2 = hei - y 'formula for 90 degree rotation
y2 = x 'formula for 90 degree rotation
rotmap(x2, y2) = PEEK(i + x + y * xi)
NEXT
NEXT
'swap dimension definition values
x = sprData(iref) / 8
y = sprData(iref + 1)
sprData(iref) = y * 8
sprData(iref+1) = x
'swap this subs version of the same values above
SWAP xi, yi
'export results to sprite array
FOR y = 0 TO wid
FOR x = 0 TO hei
POKE i + x + y * xi, rotmap(x, y)
NEXT
NEXT
for 180 rotation use
x2=wid-x
y2=hei-y
for 270 rotation of 180 use
x2=wid-y
y2=x
for other rotations, its a bit more complicated and a pain
here is the formula:
x = x * cos(angle!) - y * sin (angle!)
y = x * sin(angle!) + y * cos (angle!)
angle! must be in radians