Prev: D637 Up: Map Next: D9C4
D794: Draw Clipped Wide Sprite
Draws a 2-byte-wide, 12-row entity sprite to the screen by toggling each row's pixel data against the existing screen content. Reads the sprite type and screen position from the entity record, looks up the pixel data address in Sprite_Pixel_Data_Table, then renders twelve rows of two bytes each. Each row is bounds-checked against the play area (10 top / B9 bottom); rows outside the play area are skipped. Alternate registers carry the Y position and column offset across all twelve rows.
Input
HL Entity record pointer
Draw_Clipped_Wide_Sprite D794 LD B,H Stash the entity record pointer in BC and read the sprite type.
D795 LD C,L
D796 LD E,(HL)
D797 SLA E Double the sprite type and look up the pixel data address in Sprite_Pixel_Data_Table.
D799 LD D,$00
D79B LD HL,$C60C
D79E ADD HL,DE
D79F LD E,(HL)
D7A0 INC HL
D7A1 LD D,(HL)
D7A2 LD H,B Restore the entity record pointer and advance to the screen column byte.
D7A3 LD L,C
D7A4 INC HL
D7A5 LD B,$46 Load the screen column, stash it in D', and advance to the screen row byte.
D7A7 LD C,(HL)
D7A8 LD A,C
D7A9 EXX
D7AA LD D,A
D7AB EXX
D7AC INC HL
D7AD SLA C Shift the column into the screen address high byte.
D7AF RL B
D7B1 PUSH BC Stash the screen address high byte on the stack.
D7B2 LD A,(HL) Load the screen row byte, extract the block-row bits via three right rotations, and combine with the column to build the screen address in BC.
D7B3 AND A
D7B4 LD HL,$0000
D7B7 RRA
D7B8 RR L
D7BA RRA
D7BB RR L
D7BD RRA
D7BE RR L
D7C0 EXX
D7C1 LD C,A
D7C2 EXX
D7C3 LD A,L
D7C4 RRCA
D7C5 LD L,A
D7C6 RRCA
D7C7 ADD A,L
D7C8 LD L,A
D7C9 ADD HL,DE
D7CA LD B,H
D7CB LD C,L
D7CC POP HL
D7CD EXX
D7CE LD A,D
D7CF EXX
Row 1: return if below the play area, skip if above, else draw.
D7D0 CP $B9 Return if the entity's Y position is below the play area bottom (B9).
D7D2 RET NC
D7D3 CP $10 Skip row 1 if above the play area top (10).
D7D5 JR C,Draw_Clipped_Wide_Sprite_Row2
D7D7 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D7D8 LD A,C
D7D9 EXX
D7DA ADD A,(HL)
D7DB LD E,A
D7DC INC HL
D7DD LD D,(HL)
D7DE INC HL
D7DF EX DE,HL
D7E0 LD A,(BC)
D7E1 XOR (HL)
D7E2 LD (HL),A
D7E3 INC BC
D7E4 INC HL
D7E5 LD A,(BC)
D7E6 XOR (HL)
D7E7 LD (HL),A
D7E8 EX DE,HL
D7E9 DEC BC
Row 2: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row2 D7EA INC BC Advance the sprite data pointer past the skipped row.
D7EB INC BC
D7EC EXX Advance Y by the row stride and decrement the step count.
D7ED LD A,B
D7EE ADD A,D
D7EF LD D,A
D7F0 LD A,B
D7F1 EXX
D7F2 DEC A
Draw_Clipped_Wide_Sprite_Row2_Stride D7F3 INC HL Step HL forward to the next pixel row.
D7F4 INC HL
D7F5 DEC A
D7F6 JR NZ,Draw_Clipped_Wide_Sprite_Row2_Stride
D7F8 EXX Reload the Y position and return if below the play area bottom.
D7F9 LD A,D
D7FA EXX
D7FB CP $B9
D7FD RET NC
D7FE CP $10 Skip row 2 if above the play area top.
D800 JR C,Draw_Clipped_Wide_Sprite_Row3
D802 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D803 LD A,C
D804 EXX
D805 ADD A,(HL)
D806 LD E,A
D807 INC HL
D808 LD D,(HL)
D809 INC HL
D80A EX DE,HL
D80B LD A,(BC)
D80C XOR (HL)
D80D LD (HL),A
D80E INC BC
D80F INC HL
D810 LD A,(BC)
D811 XOR (HL)
D812 LD (HL),A
D813 EX DE,HL
D814 DEC BC
Row 3: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row3 D815 INC BC Advance the sprite data pointer past the skipped row.
D816 INC BC
D817 EXX Advance Y by the row stride and decrement the step count.
D818 LD A,B
D819 ADD A,D
D81A LD D,A
D81B LD A,B
D81C EXX
D81D DEC A
Draw_Clipped_Wide_Sprite_Row3_Stride D81E INC HL Step HL forward to the next pixel row.
D81F INC HL
D820 DEC A
D821 JR NZ,Draw_Clipped_Wide_Sprite_Row3_Stride
D823 EXX Reload the Y position and return if below the play area bottom.
D824 LD A,D
D825 EXX
D826 CP $B9
D828 RET NC
D829 CP $10 Skip row 3 if above the play area top.
D82B JR C,Draw_Clipped_Wide_Sprite_Row4
D82D EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D82E LD A,C
D82F EXX
D830 ADD A,(HL)
D831 LD E,A
D832 INC HL
D833 LD D,(HL)
D834 INC HL
D835 EX DE,HL
D836 LD A,(BC)
D837 XOR (HL)
D838 LD (HL),A
D839 INC BC
D83A INC HL
D83B LD A,(BC)
D83C XOR (HL)
D83D LD (HL),A
D83E EX DE,HL
D83F DEC BC
Row 4: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row4 D840 INC BC Advance the sprite data pointer past the skipped row.
D841 INC BC
D842 EXX Advance Y by the row stride and decrement the step count.
D843 LD A,B
D844 ADD A,D
D845 LD D,A
D846 LD A,B
D847 EXX
D848 DEC A
Draw_Clipped_Wide_Sprite_Row4_Stride D849 INC HL Step HL forward to the next pixel row.
D84A INC HL
D84B DEC A
D84C JR NZ,Draw_Clipped_Wide_Sprite_Row4_Stride
D84E EXX Reload the Y position and return if below the play area bottom.
D84F LD A,D
D850 EXX
D851 CP $B9
D853 RET NC
D854 CP $10 Skip row 4 if above the play area top.
D856 JR C,Draw_Clipped_Wide_Sprite_Row5
D858 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D859 LD A,C
D85A EXX
D85B ADD A,(HL)
D85C LD E,A
D85D INC HL
D85E LD D,(HL)
D85F INC HL
D860 EX DE,HL
D861 LD A,(BC)
D862 XOR (HL)
D863 LD (HL),A
D864 INC BC
D865 INC HL
D866 LD A,(BC)
D867 XOR (HL)
D868 LD (HL),A
D869 EX DE,HL
D86A DEC BC
Row 5: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row5 D86B INC BC Advance the sprite data pointer past the skipped row.
D86C INC BC
D86D EXX Advance Y by the row stride and decrement the step count.
D86E LD A,B
D86F ADD A,D
D870 LD D,A
D871 LD A,B
D872 EXX
D873 DEC A
Draw_Clipped_Wide_Sprite_Row5_Stride D874 INC HL Step HL forward to the next pixel row.
D875 INC HL
D876 DEC A
D877 JR NZ,Draw_Clipped_Wide_Sprite_Row5_Stride
D879 EXX Reload the Y position and return if below the play area bottom.
D87A LD A,D
D87B EXX
D87C CP $B9
D87E RET NC
D87F CP $10 Skip row 5 if above the play area top.
D881 JR C,Draw_Clipped_Wide_Sprite_Row6
D883 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D884 LD A,C
D885 EXX
D886 ADD A,(HL)
D887 LD E,A
D888 INC HL
D889 LD D,(HL)
D88A INC HL
D88B EX DE,HL
D88C LD A,(BC)
D88D XOR (HL)
D88E LD (HL),A
D88F INC BC
D890 INC HL
D891 LD A,(BC)
D892 XOR (HL)
D893 LD (HL),A
D894 EX DE,HL
D895 DEC BC
Row 6: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row6 D896 INC BC Advance the sprite data pointer past the skipped row.
D897 INC BC
D898 EXX Advance Y by the row stride and decrement the step count.
D899 LD A,B
D89A ADD A,D
D89B LD D,A
D89C LD A,B
D89D EXX
D89E DEC A
Draw_Clipped_Wide_Sprite_Row6_Stride D89F INC HL Step HL forward to the next pixel row.
D8A0 INC HL
D8A1 DEC A
D8A2 JR NZ,Draw_Clipped_Wide_Sprite_Row6_Stride
D8A4 EXX Reload the Y position and return if below the play area bottom.
D8A5 LD A,D
D8A6 EXX
D8A7 CP $B9
D8A9 RET NC
D8AA CP $10 Skip row 6 if above the play area top.
D8AC JR C,Draw_Clipped_Wide_Sprite_Row7
D8AE EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D8AF LD A,C
D8B0 EXX
D8B1 ADD A,(HL)
D8B2 LD E,A
D8B3 INC HL
D8B4 LD D,(HL)
D8B5 INC HL
D8B6 EX DE,HL
D8B7 LD A,(BC)
D8B8 XOR (HL)
D8B9 LD (HL),A
D8BA INC BC
D8BB INC HL
D8BC LD A,(BC)
D8BD XOR (HL)
D8BE LD (HL),A
D8BF EX DE,HL
D8C0 DEC BC
Row 7: crosses a character-cell boundary; the Y step doubles to advance to the next screen-third.
Draw_Clipped_Wide_Sprite_Row7 D8C1 INC BC Advance the sprite data pointer past the skipped row.
D8C2 INC BC
D8C3 EXX Advance the Y position to the next character row boundary in alternate registers.
D8C4 LD A,B
D8C5 ADD A,A
D8C6 DEC A
D8C7 ADD A,D
D8C8 LD D,A
D8C9 LD A,B
D8CA ADD A,A
D8CB EXX
D8CC DEC A Adjust the loop counter for the double-height step.
D8CD DEC A
Draw_Clipped_Wide_Sprite_Row7_Stride D8CE INC HL Step HL forward to the next pixel row.
D8CF INC HL
D8D0 DEC A
D8D1 JR NZ,Draw_Clipped_Wide_Sprite_Row7_Stride
D8D3 EXX Reload the Y position and return if below the play area bottom.
D8D4 LD A,D
D8D5 EXX
D8D6 CP $B9
D8D8 RET NC
D8D9 CP $10 Skip row 7 if above the play area top.
D8DB JR C,Draw_Clipped_Wide_Sprite_Row8
D8DD EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D8DE LD A,C
D8DF EXX
D8E0 ADD A,(HL)
D8E1 LD E,A
D8E2 INC HL
D8E3 LD D,(HL)
D8E4 INC HL
D8E5 EX DE,HL
D8E6 LD A,(BC)
D8E7 XOR (HL)
D8E8 LD (HL),A
D8E9 INC BC
D8EA INC HL
D8EB LD A,(BC)
D8EC XOR (HL)
D8ED LD (HL),A
D8EE EX DE,HL
D8EF DEC BC
Row 8: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row8 D8F0 INC BC Advance the sprite data pointer past the skipped row.
D8F1 INC BC
D8F2 EXX Advance Y by the row stride and decrement the step count.
D8F3 LD A,B
D8F4 ADD A,D
D8F5 LD D,A
D8F6 LD A,B
D8F7 EXX
D8F8 DEC A
Draw_Clipped_Wide_Sprite_Row8_Stride D8F9 INC HL Step HL forward to the next pixel row.
D8FA INC HL
D8FB DEC A
D8FC JR NZ,Draw_Clipped_Wide_Sprite_Row8_Stride
D8FE EXX Reload the Y position and return if below the play area bottom.
D8FF LD A,D
D900 EXX
D901 CP $B9
D903 RET NC
D904 CP $10 Skip row 8 if above the play area top.
D906 JR C,Draw_Clipped_Wide_Sprite_Row9
D908 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D909 LD A,C
D90A EXX
D90B ADD A,(HL)
D90C LD E,A
D90D INC HL
D90E LD D,(HL)
D90F INC HL
D910 EX DE,HL
D911 LD A,(BC)
D912 XOR (HL)
D913 LD (HL),A
D914 INC BC
D915 INC HL
D916 LD A,(BC)
D917 XOR (HL)
D918 LD (HL),A
D919 EX DE,HL
D91A DEC BC
Row 9: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row9 D91B INC BC Advance the sprite data pointer past the skipped row.
D91C INC BC
D91D EXX Advance Y by the row stride and decrement the step count.
D91E LD A,B
D91F ADD A,D
D920 LD D,A
D921 LD A,B
D922 EXX
D923 DEC A
Draw_Clipped_Wide_Sprite_Row9_Stride D924 INC HL Step HL forward to the next pixel row.
D925 INC HL
D926 DEC A
D927 JR NZ,Draw_Clipped_Wide_Sprite_Row9_Stride
D929 EXX Reload the Y position and return if below the play area bottom.
D92A LD A,D
D92B EXX
D92C CP $B9
D92E RET NC
D92F CP $10 Skip row 9 if above the play area top.
D931 JR C,Draw_Clipped_Wide_Sprite_Row10
D933 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D934 LD A,C
D935 EXX
D936 ADD A,(HL)
D937 LD E,A
D938 INC HL
D939 LD D,(HL)
D93A INC HL
D93B EX DE,HL
D93C LD A,(BC)
D93D XOR (HL)
D93E LD (HL),A
D93F INC BC
D940 INC HL
D941 LD A,(BC)
D942 XOR (HL)
D943 LD (HL),A
D944 EX DE,HL
D945 DEC BC
Row 10: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row10 D946 INC BC Advance the sprite data pointer past the skipped row.
D947 INC BC
D948 EXX Advance Y by the row stride and decrement the step count.
D949 LD A,B
D94A ADD A,D
D94B LD D,A
D94C LD A,B
D94D EXX
D94E DEC A
Draw_Clipped_Wide_Sprite_Row10_Stride D94F INC HL Step HL forward to the next pixel row.
D950 INC HL
D951 DEC A
D952 JR NZ,Draw_Clipped_Wide_Sprite_Row10_Stride
D954 EXX Reload the Y position and return if below the play area bottom.
D955 LD A,D
D956 EXX
D957 CP $B9
D959 RET NC
D95A CP $10 Skip row 10 if above the play area top.
D95C JR C,Draw_Clipped_Wide_Sprite_Row11
D95E EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D95F LD A,C
D960 EXX
D961 ADD A,(HL)
D962 LD E,A
D963 INC HL
D964 LD D,(HL)
D965 INC HL
D966 EX DE,HL
D967 LD A,(BC)
D968 XOR (HL)
D969 LD (HL),A
D96A INC BC
D96B INC HL
D96C LD A,(BC)
D96D XOR (HL)
D96E LD (HL),A
D96F EX DE,HL
D970 DEC BC
Row 11: advance sprite data if skipped, step Y, step row table, draw.
Draw_Clipped_Wide_Sprite_Row11 D971 INC BC Advance the sprite data pointer past the skipped row.
D972 INC BC
D973 EXX Advance Y by the row stride and decrement the step count.
D974 LD A,B
D975 ADD A,D
D976 LD D,A
D977 LD A,B
D978 EXX
D979 DEC A
Draw_Clipped_Wide_Sprite_Row11_Stride D97A INC HL Step HL forward to the next pixel row.
D97B INC HL
D97C DEC A
D97D JR NZ,Draw_Clipped_Wide_Sprite_Row11_Stride
D97F EXX Reload the Y position and return if below the play area bottom.
D980 LD A,D
D981 EXX
D982 CP $B9
D984 RET NC
D985 CP $10 Skip row 11 if above the play area top.
D987 JR C,Draw_Clipped_Wide_Sprite_Row12
D989 EXX Compute the screen address and toggle the sprite row's two pixel bytes onto the screen.
D98A LD A,C
D98B EXX
D98C ADD A,(HL)
D98D LD E,A
D98E INC HL
D98F LD D,(HL)
D990 INC HL
D991 EX DE,HL
D992 LD A,(BC)
D993 XOR (HL)
D994 LD (HL),A
D995 INC BC
D996 INC HL
D997 LD A,(BC)
D998 XOR (HL)
D999 LD (HL),A
D99A EX DE,HL
D99B DEC BC
Row 12 (final): advance sprite data if skipped, step Y, step row table, draw and return.
Draw_Clipped_Wide_Sprite_Row12 D99C INC BC Advance the sprite data pointer past the skipped row.
D99D INC BC
D99E EXX Advance Y by the row stride and decrement the step count.
D99F LD A,B
D9A0 ADD A,D
D9A1 LD D,A
D9A2 LD A,B
D9A3 EXX
D9A4 DEC A
Draw_Clipped_Wide_Sprite_Row12_Stride D9A5 INC HL Step HL forward to the next pixel row.
D9A6 INC HL
D9A7 DEC A
D9A8 JR NZ,Draw_Clipped_Wide_Sprite_Row12_Stride
D9AA EXX Reload the Y position and return if below the play area bottom.
D9AB LD A,D
D9AC EXX
D9AD CP $B9
D9AF RET NC
D9B0 CP $10 Return if row 12 is above the play area top.
D9B2 RET C
D9B3 EXX Compute the screen address, toggle the sprite row's two pixel bytes onto the screen, and return.
D9B4 LD A,C
D9B5 EXX
D9B6 ADD A,(HL)
D9B7 LD E,A
D9B8 INC HL
D9B9 LD D,(HL)
D9BA EX DE,HL
D9BB LD A,(BC)
D9BC XOR (HL)
D9BD LD (HL),A
D9BE INC BC
D9BF INC HL
D9C0 LD A,(BC)
D9C1 XOR (HL)
D9C2 LD (HL),A
D9C3 RET
Prev: D637 Up: Map Next: D9C4