Right.....
I'm now experimenting with Sprite Masks.... Yes this is very fisher price basic stuff for you guys, but its pretty essential that I learn all the basics first of all.....
Now... I thought it was pretty speed inefficent, to work out the mask while plotting (
please please correct me if there is a fast on the fly bbc mask trick - maybe using a table of 256 bytes ????), ... SO basically I've just got my sprite data, and manipulated it to build me a negative mask.... So essentially there are now two sprites... one normal and one mask.... (all pre calculated but uses twice the memory so halves my sprite count)
Ok... While plotting, I get the mask byte, AND it with the Screen memory, OR it with the sprite byte, and then plot it back to screen memory....and repeat for all sprite bytes in the image...
Its working.... Not pretty code or whatever, but I'm learning the techniques now....
Heres a quick screen shot to show progress....
Attachment:
smask.JPG [18.9 KiB]
Downloaded 296 times
So.. what do I need to suss out next them ?? - I guess I should snapshot the screen background for all 8 sprites, before plotting, so afterwards I can then restore the screen background, before moving the sprites and replotting them somewhere else..... does this make sense ? -Is it the right approach I'm taking ?
I also need to work out a better sprite storage format for speed.... as its still a bit of a hybrid c64/bbc model... (with the bits shuffled around as the order is different on the bbc) - At the moment I can only plot the horizonal position in coarse steps..... SO a long way to go/learn yet !!
Cheers, Colin
Ps.. heres the mask code.....that runs at the start (similar to the sprite conversion code, but tweaked to combine the colour nybles and invert for mask) - I've edited in some comments since first posting...
(Pretty simple brute force bit shifting code eh ??)
makemask:
lda #<sprite
sta $70
lda #>sprite
sta $71
lda #<smasks
sta $80
lda #>smasks
sta $80
ldy #$3f
lda #$00
sta ($70),y ; clear 'unused' 63rd byte !! - just incase image has corrupt data in for sanity
ldy #$00
mmloop1:
lda ($70),y ;get sprite 'byte'
sta working
lda #$00
sta Working+1 ; clear our working nybles (in separate bytes before re-combining)
sta working+2
ldx #$04
mmLooprol:
asl working ; shuffle the c64 bits around to bbc hi/lo nybles style in two separate bytes
rol working+1
asl working
rol working+2
dex
bne mmlooprol
lda working+1 ; or both nyble pairs together so aways use 11 (if any of the bits are set)
ora working+2 ; if nyble pairs are 00 then they stay at 00
sta working+1 ; store combined nyble bytes back into both nyble bytes
;sta working+2 ; dont need to store it !!
asl working+1 ;rotate them all back into place - eg combine the nyble bytes into one byte - hi/lo bbc format
asl working+1 ; we only have to do this for the high nyble as its 'out of place'
asl working+1
asl working+1
;lda working+2 ; get the low nyble (we already got this in accumulator)
ora Working+1 ; combine with high nyble
eor #$FF ; invert the mask
sta ($80),y ; store fixed sprite mask value
iny
cpy #64
bne mmloop1 ; repeat for all sprite bytes in the image
rts