As well it rotates the 9 offsets used by the Misc_SprDataOffset for use with various sprites like hammers and coins.
01 .proc SpriteShuffler
02
03 ldy AreaType ; load level type, likely residual code OP
04 mb temp_byte := # ( 10 * 4 ) ; sprite #10
05 ldx #$0e ; start at the end of OAM data offsets
06
07 repeat
08
09 if SprDataOffset[ x ] >= temp_byte ; the preset value if less, skip this part
10
11 ldy SprShuffleAmtOffset ; get current offset to preset value we want to add
12 mb a := a + SprShuffleAmt[ y ] ; get shuffle amount, add to current sprite offset
13 if carry set ; if exceeded $ff, do second add
14 mb a := a + temp_byte ; add preset value 40 to offset to skip first ten sprites again
15 endif
16
17 mb SprDataOffset[ x ] := a ; store new offset here or old one if 2nd add skipped
18
19 endif
20
21 until dex == negative ; move backwards to next one
22
23 mb x := SprShuffleAmtOffset + 1
24 if x = #3
25 ldx #$00 ; init to 0 -> cycles through 0 to 2
26 endif
27
28 stx SprShuffleAmtOffset
29
30 ldx #$08 ; load offsets for values and storage
31 ldy #$02
32
33 repeat ; y from 2 to 0, x = 8, 5, 2
34
35 mb a := SprDataOffset [ 5 + y ] ; 7, 6, 5
36 mb Misc_SprDataOffset [ x - 2 ] := a ; store first one unmodified, 6, 3, 0
37 mb Misc_SprDataOffset [ x - 1 ] := a + #$08 ; but add eight to the second, 7, 4, 1
38 mb Misc_SprDataOffset [ x ] := a + #$08 ; and eight more to the third one, 8, 5, 2
39
40 mb x := x - 3
41
42 until dey == negative
43
44 rts
45
46 .endproc
No comments:
Post a Comment