Prev: 63539 Up: Map Next: 63982
63668: Draw Entity
Used by the routine at JumpTable_DrawEntity.
Draws the entity pointed to by IX.
Input
IX Entity data
Draw_Entity 63668 XOR A Clear the self-modified OR at Draw_Entity_Merge.
63669 LD (63785),A
63672 LD H,A Stash *CHARS on the stack.
63673 LD DE,(23606)
63677 PUSH DE
63678 PUSH IY Stash IY and IX on the stack.
63680 PUSH IX
63682 LD A,7 Write 7-*IX+2 to the shift count at 63767.
63684 SUB (IX+2)
63687 LD (63767),A
63690 LD E,(IX+4) DE=the sprite width and height.
63693 LD D,(IX+5)
63696 LD C,D IY=23742+(height+1)*8.
63697 INC C
63698 SLA C
63700 SLA C
63702 SLA C
63704 LD B,0
63706 LD IY,23742
63710 ADD IY,BC
63712 LD A,E Write the width*8 to the stride at 63798.
63713 SLA A
63715 SLA A
63717 SLA A
63719 LD (63798),A
63722 LD A,(IX+7) Jump to Advance_Entity_Target if bit 7 of the colour is set.
63725 BIT 7,A
63727 JP NZ,Advance_Entity_Target
63730 LD (23695),A Write the colour to *ATTR_T.
63733 LD DE,(23606) DE=*CHARS.
63737 LD L,(IX+6) Point HL at this frame's source UDGs.
63740 LD H,0
63742 ADD HL,HL
63743 ADD HL,HL
63744 ADD HL,HL
63745 ADD HL,DE
63746 LD D,(IX+5) DE=the sprite width and height.
63749 LD E,(IX+4)
63752 PUSH HL Copy HL to IX (using the stack).
63753 POP IX
63755 LD HL,23742 HL=23742.
Draw_Entity_Continue 63758 PUSH IX Stash the source pointer and remaining size.
63760 PUSH DE
Draw_Entity_Continue2 63761 PUSH IX Stash the source pointer on the stack.
63763 LD B,8 B=8.
Draw_Entity_Target 63765 PUSH BC Stash the row count.
Draw_Entity_ShiftCount 63766 LD B,255 B=the shift count (self-modified).
63768 XOR A A=0.
63769 CP B Test the shift count.
63770 LD C,A C=0.
63771 LD A,(IX+0) A=the next source byte.
63774 JR Z,Draw_Entity_Skip Jump to Draw_Entity_Skip if the shift count is zero.
Draw_Entity_Target2 63776 SRL A Shift one source bit into the overflow byte.
63778 RR C
63780 DJNZ Draw_Entity_Target2
Draw_Entity_Skip 63782 LD (IY+0),C Write the overflow bits to the next column.
Draw_Entity_Merge 63785 NOP Self-modified: NOP or OR (HL).
63786 LD (HL),A Write the rotated byte.
63787 INC HL Advance the destination and source pointers.
63788 INC IX
63790 INC IY
63792 POP BC Restore the row count from the stack.
63793 DJNZ Draw_Entity_Target Decrease the count and loop back to Draw_Entity_Target.
63795 POP IX Restore the source pointer from the stack.
Draw_Entity_Stride 63797 LD BC,0 BC=the stored stride (self-modified).
63800 ADD IX,BC Advance to the next source column and loop back to Draw_Entity_Continue2.
63802 DEC D
63803 JR NZ,Draw_Entity_Continue2
63805 LD A,182 Write OR (HL) into *Draw_Entity_Merge.
63807 LD (63785),A
63810 XOR A A=0.
63811 LD B,8 B=8.
Draw_Entity_Target3 63813 LD (HL),A Clear one overflow byte and loop back to Draw_Entity_Target3.
63814 LD (IY+0),A
63817 INC HL
63818 INC IY
63820 DJNZ Draw_Entity_Target3
63822 POP DE Step to the next source character and loop back to Draw_Entity_Continue.
63823 POP IX
63825 LD BC,8
63828 ADD IX,BC
63830 DEC E
63831 JR NZ,Draw_Entity_Continue
This entry point is used by the routine at Advance_Entity_Target.
Draw_Entity_Target4 63833 LD HL,23478 Point *CHARS at the shifted workspace plus the fine-Y.
63836 POP IX
63838 LD E,(IX+3)
63841 INC E
63842 LD D,A
63843 ADD HL,DE
63844 LD (23606),HL
63847 LD D,(IX+5) Increase the printed width when the fine-X is not 7.
63850 LD A,(IX+2)
63853 CP 7
63855 LD E,(IX+4)
63858 JR Z,Draw_Entity_Skip2
63860 INC E
Draw_Entity_Skip2 63861 INC D Store the printed height in *25620.
63862 LD A,D
63863 LD (25620),A
63866 LD A,7 Decrease the height when the fine-Y is 7.
63868 CP (IX+3)
63871 JR NZ,Draw_Entity_Continue3
63873 DEC D
Draw_Entity_Continue3 63874 LD B,(IX+1) Call Draw_Entity_Target5 at the entity column and row.
63877 LD C,(IX+0)
63880 POP IY
63882 CALL Draw_Entity_Target5
63885 POP HL Restore *CHARS from the stack.
63886 LD (23606),HL Write it back to *CHARS.
63889 RET Return.
Print the shifted sprite inside the clip window.
Draw_Entity_Target5 63890 LD L,31 Write the remaining width into the load at 63898.
63892 LD A,E
63893 LD (63898),A
Draw_Entity_Target6 63896 INC L Advance the glyph base.
Draw_Entity_Width 63897 LD E,0 E=the remaining width (self-modified).
63899 LD A,(25625) Jump to Draw_Entity_Branch if this row is inside *ClipWindow.
63902 CP B
63903 JR NC,Draw_Entity_Branch
Draw_Entity_Target7 63905 DEC D Skip down until the row is inside the clip window.
63906 RET Z
63907 INC L
63908 DEC B
63909 CP B
63910 JR NC,Draw_Entity_Branch
63912 JR Draw_Entity_Target7
Draw_Entity_Branch 63914 LD A,(25628) Return if this column is past *25628.
63917 CP C
63918 RET NC
63919 LD A,(25626) Return if this row is below *ClipWindow_MaximumRow.
63922 CP B
63923 RET NC
63924 PUSH BC Jump to Draw_Entity_Branch3 if this column is inside *ClipWindow_MinimumColumn.
63925 LD A,(25627)
63928 CP C
63929 JR NC,Draw_Entity_Branch3
63931 LD H,L Copy the glyph base into H.
Draw_Entity_Branch2 63932 DEC E Jump to Draw_Entity_Skip3 if the remaining width is zero.
63933 JR Z,Draw_Entity_Skip3
63935 LD A,(25620) Skip left until the column is inside the clip window.
63938 ADD A,H
63939 LD H,A
63940 DEC C
63941 LD A,(25627)
63944 CP C
63945 JR C,Draw_Entity_Branch2
63947 CALL Set_PrintPosition Call Set_PrintPosition.
63950 LD A,H A=the clipped glyph.
63951 JR Draw_Entity_Continue4 Jump to Draw_Entity_Continue4.
Draw_Entity_Branch3 63953 CALL Set_PrintPosition Call Set_PrintPosition with the unclipped glyph.
63956 LD A,L
Draw_Entity_Continue4 63957 CALL Print_Character Call Print_Character and keep the glyph in H.
63960 LD H,A
63961 DEC C Jump to Draw_Entity_Skip3 if this column is past *25628.
63962 LD A,(25628)
63965 CP C
63966 JP NC,Draw_Entity_Skip3
63969 LD A,(25620) Advance the glyph and loop back to Draw_Entity_Continue4.
63972 ADD A,H
63973 DEC E
63974 JR NZ,Draw_Entity_Continue4
Draw_Entity_Skip3 63976 POP BC Restore the position from the stack.
63977 DEC D Return if the remaining height is zero.
63978 RET Z
63979 DEC B Move up one row.
63980 JR Draw_Entity_Target6 Jump to Draw_Entity_Target6.
View the equivalent code in Booty.
Prev: 63539 Up: Map Next: 63982