Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DrawClippedSprite: ;D=X E=Y A=spriteID. Allows negative numbers to an extent.
- ;screen dimensions are 64x64 pixels
- rrca
- rrca ;%11000000 get
- ld c,a
- ld a,d
- and %00000111
- ld b,a ;save for getting mask address
- add a,a
- add a,a
- add a,a ;x8 %00111000
- add a,c ;merge to get correct sprite position
- ld c,a ;position saved
- ld a,b
- add a,8 ;getting spritemask position
- ld h,$40
- ld L,a
- ld b,(hl) ;B=spritemask
- Getbfraddr:
- ld h,$00
- ld a,e
- add a,a
- add a,a ;x4
- ld l,a
- add hl,hl ; sets xpos on buffer into hl
- ld a,d
- ld d,e
- add a,a
- add a,a
- add a,a ;*8
- ld e,a
- ld a,d ; used for alignment later on needs to be preserved here
- ld d,$80
- add hl,de ;leaves HL as the position on the buffer
- Getspraddr:
- ld e,b ;put mask into e
- ld b,$87
- push bc
- pop ix ;put sprite into ix
- ld b,8
- Draw:
- and 7
- jp z,_aligned
- _Unaligned:
- ld a,(ix) ;load a with ix
- or (hl) ;or with screen
- ld (hl),a ;draw to screen
- inc l ;inc to next byte for alignment
- ld a,(ix) ;load a with ix
- or e ;or with mask
- or (hl) ;or with screen
- ld (hl),a ;draw to screen
- ld de,8 ;move to next row
- add hl,de
- ret c ;ret if off screen
- djnz _Unaligned
- ret ;done
- _alinged:
- ld a,(ix) ;load a with ix
- or e ;or with mask
- or (hl) ;or with screen
- ld (hl),a ;draw to screen
- ld de,8 ;move to next row
- add hl,de
- ret c ;ret if off screen
- djnz _aligned
- ret ;done
Advertisement
Add Comment
Please, Sign In to add comment