; SpriteBlitt by Erik Huizing (ehuizing@acs.ucalgary.ca) (Nov 18/97)
; plots sprites larger than 8x8
; code size = 87 bytes(?)
;
; inputs:
; hl = sprite data      bc = coords
; outputs:
; af, bc, de, hl, ix destoryed
; sprite plotted on screen
;
; sprite format:
; .db xSize, ySize
; .db sprite data
; 1 bits are black pixels, 0 bits are white
; so %11110000 is 4 black pixels, then 4 white
;
; mask and data are same size
; xSize is the number of bytes wide your sprite is
; ySize is the height
;
; Optimizations:
; if a zero byte is encountered, it is skipped (ie .db %00000000)
;
; Other notes: caz will compile this with no complaints
; Version history:
; - Nov 18/97 vers. 1: initial relase
;
; If you use this, gimme credit somewhere
;

SpriteBlitt:
 ld a, 63
 sub c
 ld c, a
 push hl
 CALL ROM_CALL
 .dw FIND_PIXEL
 ld de, VIDEO_MEM
 add hl, de
 pop de
 ex de, hl
 ld b, (hl)
 inc hl
 ld c, (hl)
 inc hl
 push hl
 pop ix
 ex de, hl
vLoop:
 push bc
 push hl
hLoop:
 push bc
 ld b, 8
 ld c, a
 ld a, (ix+0)
 or a
 jr nz, bitLoop
 inc hl
 jr noData
bitLoop:
 bit 7, a
 push af
 ld a, c
 jr z, white
 or (hl)
 jr setPixel
white:
 xor 0xFF
 and (hl)
setPixel:
 ld (hl), a
 pop af
 srl c
 jr nc, noReset
 ld c, %10000000
 inc hl
noReset:
 rl a
djnz bitLoop
noData:
ld a, c
pop bc
inc de
inc ix
djnz hLoop
pop hl
push de
ld de, 16
add hl, de
pop de
pop bc
dec c
jr nz, vLoop
ret
