; SpriteBlitt ; written by Erik Huizing (ehuizing@acs.ucalgary.ca) ; plots sprites with masks ; inputs: ; hl = sprite data ; bc = coords ; outputs: ; af, bc, de, hl, ix destoryed ; sprite plotted on screen (with mask) ; ; sprite format: ; .db xSize, ySize ; .db sprite data ; .db mask data ; ; xSize is the number of bytes wide your sprite is ; ySize is the height ; ; Optimizations: ; if the mask byte is zero, SpriteBlitt skips to the next byte ; the mask lookup is faster if your sprite is taller than it is wide 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 push bc push de ld d, 0 ld e, c loop: add ix, de djnz loop pop de pop bc ex de, hl vLoop: push bc push hl hLoop: push bc ld b, 8 ld c, a push de ld a, (de) ld e, a ld a, (ix+0) or a jr nz, bitLoop inc hl jr noMask bitLoop: rl a jr nc, noMaskBit bit 7, e push af ld a, c jr z, white or (hl) jr setPixel white: xor 0xFF and (hl) setPixel: ld (hl), a pop af noMaskBit: srl c jr nc, noReset ld c, %10000000 inc hl noReset: rl e djnz bitLoop noMask: ld a, c pop de 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