Prev: D813 Up: Map Next: D895
D815: Copy a sprite's graphic into a working buffer
Used by the routine at E544.
Input
HL Buffer to copy the sprite to
DE Address of the sprite's graphic data
BC Location of the sprite
D815 LD A,(DE) Put the depth in C and write it to the buffer.
D816 AND $0C
D818 RRCA
D819 RRCA
D81A LD C,A
D81B LD (HL),A
D81C INC HL Move to the next entry.
D81D LD A,(DE) Put the width in B and write it to the buffer.
D81E AND $03
D820 INC A
D821 LD B,A
D822 LD (HL),A
D823 LD ($D72E),BC Store these as the current co-ordinates. (D72E, D72F)
D827 LD A,C Get the depth.
D828 ADD A,A Multiply by 8 to get an appropriate offset.
D829 ADD A,A
D82A ADD A,A
D82B LD ($D813),A Store this (D813) and put it in C.
D82E LD C,A
D82F XOR A Make A the total size (width * depth * 8)
D830 ADD A,C
D831 DJNZ $D830
D833 LD ($D814),A Store this.
D836 INC DE Move to the next entry in the sprite data.
D837 PUSH DE Remember DE as the position in the data.
D838 INC HL Move to the next point in the buffer.
D839 LD ($D730),HL Store this. (D730)
D83C LD E,L Clear all data in the buffer.
D83D LD D,H
D83E INC DE
D83F LD (HL),$00
D841 LD BC,$023F
D844 LDIR
D846 POP DE Restore DE.
D847 LD A,$04
D849 LD HL,($D730)
D84C LD BC,$0048
D84F EX AF,AF'
D850 PUSH BC Draw a moving sprite.
D851 PUSH HL
D852 CALL $DB83
D855 POP HL
D856 POP BC
D857 ADD HL,BC
D858 EX AF,AF'
D859 DEC A
D85A JR NZ,$D84F
D85C LD BC,$0048
D85F LD HL,($D730)
D862 LD A,$02
D864 EX AF,AF'
D865 PUSH BC
D866 PUSH HL
D867 CALL $DB9B Clear the area now the sprite has been drawn.
D86A POP HL
D86B POP BC
D86C ADD HL,BC
D86D EX AF,AF'
D86E ADD A,$02
D870 CP $0A
D872 JR NZ,$D864
D874 LD A,$04
D876 LD HL,($D730)
D879 LD D,H
D87A LD E,L
D87B LD BC,$0120
D87E ADD HL,BC
D87F LD BC,$0048
D882 EX AF,AF'
D883 PUSH BC Reverse direction.
D884 PUSH DE
D885 PUSH HL
D886 CALL $D9B0
D889 POP HL
D88A POP DE
D88B POP BC
D88C ADD HL,BC
D88D EX DE,HL
D88E ADD HL,BC
D88F EX DE,HL
D890 EX AF,AF'
D891 DEC A
D892 JR NZ,$D882
D894 RET
Prev: D813 Up: Map Next: D895