Prev: B716 Up: Map Next: B7EF
B76C: Masked sprite plotter which flips
This moves the destination on by the byte width so that the second entry point starts at the right hand edge of the sprite, then falls into plot_masked_sprite_flipped_entrypt2, which draws right to left.
Used by the routine at draw_object_right.
Input
A Byte width
HL Destination address of the left hand edge of the sprite
B' Number of source data rows (loop counter)
E' Source data stride in bytes
HL' Source data (bitmap, mask byte pairs)
plot_masked_sprite_flipped B76C LD D,$00 DE = A
B76E LD E,A
B76F ADD HL,DE HL += DE
This entry point is used by the routine at draw_cherry_light.
plot_masked_sprite_flipped_entrypt2 B770 EX DE,HL
B771 LD ($B792),SP Save SP to be restored on exit
B775 LD IX,$B79C Point IX at jump table
B779 CPL Subtract A from 8
B77A ADD A,$09
B77C RLCA Multiply by 8 -- length of jump table sequences
B77D RLCA
B77E RLCA
B77F LD C,A Add to IX
B780 LD B,$00
B782 ADD IX,BC
B784 LD H,$EF HL = $EFxx
B786 EXX Bank
B787 LD D,$00 DE' = $00xx -- the caller passes the row stride in E' alone, so D' must be cleared before the ADD HL,DE at pmsf_next_scanline steps the source on by one row
B789 JR pmsf_start goto pmsf_start
pmsf_reset_next B78B EX AF,AF'
B78C LD E,A
pmsf_next B78D EX AF,AF'
B78E EXX Bank
B78F DJNZ pmsf_next_scanline Next scanline
B791 LD SP,$0000 Restore original SP (self modified)
B794 RET Return
pmsf_next_scanline B795 ADD HL,DE Calculate address of next bitmap scanline
pmsf_start B796 LD SP,HL Put it in SP (so we can use PUSH for speed)
B797 EXX Unbank
B798 LD A,E Bank E for next-scanline code below
B799 EX AF,AF'
B79A JP (IX) Jump into table
pmsf_jumptable B79C POP BC Load a bitmap and mask pair (B,C)
B79D LD L,C Set flip table index (assuming table is aligned)
B79E LD A,(DE) Load the screen pixels
B79F AND (HL) AND screen pixels with flipped mask
B7A0 LD L,B Set flip table index
B7A1 OR (HL) OR in new flipped pixels
B7A2 LD (DE),A Store back to the screen
B7A3 DEC E Move to next screen pixel (downwards in memory)
B7A4 POP BC 7
B7A5 LD L,C
B7A6 LD A,(DE)
B7A7 AND (HL)
B7A8 LD L,B
B7A9 OR (HL)
B7AA LD (DE),A
B7AB DEC E
B7AC POP BC 6
B7AD LD L,C
B7AE LD A,(DE)
B7AF AND (HL)
B7B0 LD L,B
B7B1 OR (HL)
B7B2 LD (DE),A
B7B3 DEC E
B7B4 POP BC 5
B7B5 LD L,C
B7B6 LD A,(DE)
B7B7 AND (HL)
B7B8 LD L,B
B7B9 OR (HL)
B7BA LD (DE),A
B7BB DEC E
B7BC POP BC 4
B7BD LD L,C
B7BE LD A,(DE)
B7BF AND (HL)
B7C0 LD L,B
B7C1 OR (HL)
B7C2 LD (DE),A
B7C3 DEC E
B7C4 POP BC 3
B7C5 LD L,C
B7C6 LD A,(DE)
B7C7 AND (HL)
B7C8 LD L,B
B7C9 OR (HL)
B7CA LD (DE),A
B7CB DEC E
B7CC POP BC 2
B7CD LD L,C
B7CE LD A,(DE)
B7CF AND (HL)
B7D0 LD L,B
B7D1 OR (HL)
B7D2 LD (DE),A
B7D3 DEC E
B7D4 POP BC 1
B7D5 LD L,C
B7D6 LD A,(DE)
B7D7 AND (HL)
B7D8 LD L,B
B7D9 OR (HL)
B7DA LD (DE),A
Move to next scanline (shorter form).
B7DB LD A,D Save for checking in a moment
B7DC DEC D Move to next scanline (visually upwards)
B7DD AND $0F Would it have rolled over into the top nibble?
B7DF JP NZ,pmsf_reset_next No - continue (resetting scanline)
It rolled over.
B7E2 EX AF,AF' Move to next chunk of 16 scanlines
B7E3 SUB $20
B7E5 LD E,A
B7E6 JR C,pmsf_next Carry set if CCC field was zero - don't compensate 1111 field and continue (not resetting)
Otherwise have to compensate 1111 field.
B7E8 LD A,D Put back the bit stolen since BAAA field was zero
B7E9 ADD A,$10
B7EB LD D,A
B7EC JP pmsf_next Loop (not resetting)
Prev: B716 Up: Map Next: B7EF