| Routines

25618: Prepare sprite tiles used by Sam when somersaulting or rolling

Used by the routine at 25789. Animatory states 9, 10, 15 and 31 - corresponding to the sprites of Sam rolling and somersaulting - use sprite tiles 239-247. These sprite tiles are initialised before Sam starts his acrobatic manoeuvre, and later rotated as he moves through each phase of animation.
25618 | LD L,2 | Copy sprite tiles 2-7 over sprite tiles 239-244
25620 | LD E,239
25622 | LD C,6
25624 | CALL 25600
25627 | LD E,242 | Copy sprite tile 170 over sprite tile 242
25629 | LD L,170
25631 | INC C
25632 | CALL 25600
25635 | LD A,181 | Copy sprite tiles 181, 189 and 197 from base page 215 over sprite tiles 245-247
25637 | LD E,245
25639 | LD L,A
25640 | LD H,215
25642 | INC C
25643 | CALL 25602
25646 | LD A,L
25647 | ADD A,7
25649 | CP 205
25651 | JR NZ,25639
25653 | LD B,8 | Superimpose sprite tile 205 from base page 215 over sprite tile 243 (which is currently a copy of sprite tile 6, the centre tile of Sam's base animatory state); this makes Sam appear to bend his arms and hold his knees while performing the acrobatic feat, at the expense of losing some detail from his current disguise
25655 | LD HL,55245
25658 | LD DE,51187
25661 | LD A,(DE)
25662 | OR (HL)
25663 | INC H
25664 | AND (HL)
25665 | INC H
25666 | LD (DE),A
25667 | INC D
25668 | LD (DE),A
25669 | INC D
25670 | DJNZ 25661
This entry point is used by the routine at 25789. Here we rotate sprite tiles 239-247 and store the results in sprite tile slots 238-246.
25672 | LD L,239 | Tile 239 is the first source tile
25674 | LD E,L | E=238 (the first target tile)
25675 | DEC E
25676 | LD D,199 | The base page for these tiles is 199
25678 | LD B,8 | Rotate the source sprite tile 90 degrees anticlockwise and copy it over the target sprite tile
25680 | LD H,198
25682 | LD C,1
25684 | INC H
25685 | RRC (HL)
25687 | RLA
25688 | INC H
25689 | RRC (HL)
25691 | RL C
25693 | JR NC,25684
25695 | LD (DE),A
25696 | INC D
25697 | LD A,C
25698 | LD (DE),A
25699 | INC D
25700 | DJNZ 25680
25702 | INC L | Move to the next source sprite tile reference
25703 | BIT 3,L | Have we rotated sprite tiles 239-247 yet?
25705 | JR Z,25674 | Jump back if not
Next we move sprite tiles 238-246 up to 239-247.
25707 | LD A,16 | There are 16 bytes of graphic and mask data in each tile
25709 | LD E,247 | Copy sprite tiles 238-246 into slots 239-247
25711 | LD L,246
25713 | LD C,9
25715 | DEC D
25716 | LD H,D
25717 | LDDR
25719 | DEC A
25720 | JR NZ,25709
25722 | RET | Return with the zero flag set