; Y = rotation index
; Temp+16 = pointer to the raw sprite info with an
; 8 byte cache index table
lda (Temp+16),y ; get cache index using the current rotation index
tay ; into the sprite cache index list
ldx Cache_Next-1,y ; If we are last, then do nothing!!!
lda Cache_Prev-1,y ; get the PREV from our current cache block
sta Cache_Prev-1,x ; and store in the NEXT's Prev
; We've now unlinked from the NEXT item, unlink from PREV item
tax ; and set the PREV of our new one to the OLD last.
; Now link the cache block to the end
sta Cache_Next-1,y ; get the PREV from our current cache block
sta Cache_Prev,y ; Set the LAST entry as our prev.
sta Cache_Next-1,x ; and set the last entry's NEXT as our new item
sta LastCache ; now set thr NEW last as the new item.
So.... There you go! If you spot anything, let me know - while I've still got hair!