I thieved a piece of code from the CPC forums to use in the draw routine. It checks for transparent pixels in the sprite frame and doesn't draw them. It works really well, and I actually know what's going on in the code (in theory), but there are still some blue pixels around the edge of the sprite that it seems to have missed and they are still showing. The picture below shows what's happening:
It seems to be skipping over a horizontal pixel byte, because it looks like it's every second byte that is being checked when it reaches the actual player pixels. I'm sure that one Mode 0 pixel is one byte, but it looks like it's taking it as two per byte.
This is the code I'm using. As always, many thanks in advance!
Code: Select all
DRAW2SCREEN: ld a,(SPRITE_HEIGHT) ; Load sprite height value to 'a' ld b,a ; Height (LINES) Spritenextline: push hl ld a,(SPRITE_WIDTH) ; Width (BYTES) ld c,a ; Bytes per line SpriteNextByte: ld a,(de) ; Read sprite pixels inc de ; Update sprite pixel pointer or a ; Zero (i.e. fully transparent?) jr z,NO_MASK ; If yes, then skip ld (hl),a ; If no, then write byte to screen NO_MASK: inc hl ; Increase destination (Screen) Address dec c ; Repeat for next byte jr nz,SpriteNextByte pop hl call GetNextLine ; Scr Next Line (Alter HL to move down a line) djnz SpriteNextLine ; Repeat for next line RET