|
Well.... I've got the data converted, and it plots.... but only in multiples of 8 pixels on the screen.... so I've got a lot of work to do yet for smoothe movement ..... and its not doing any or's or xors' or anything... however its pretty quick !!
What I might try to do is expand the code so it plots 4x4 char sprites instead of 3x3 chars (using the same code base idea) and move the sprite around in the sprite memory 'before we plot' data.... I'm not quite sure yet... how to approch..
Up and down should be reasonably straight forward, but not sure about left / right..... I am really going to have to compromise on the amount of sprite data, due to the limits of how this machine works.....
Anyway... heres the code I've knocked together... and it must be run in mode 5..... At the moment, you need to copy the 64 bytes to the sprite, and then call the plot.... so there will be an overhead.... This is my first method, more may follow..... once I start to find limitations or bottlenecks...
Comments appreciated.....
Cheers, Colin
.org $1900 ; load a traditional Beeb start address for a disk system ; we'll load in other code lower than this after we've started
.require "Macros" .require "AcornConstants"
Main:
Jsr fixsprites ; Takes the c64 sprite (sprite) , reformats it , copies/unshuffles data to worksprite, them copies it back to Sprite
mainloop:
ldx #$58 ldy #$00 ; screen plot starts at 5800 stx $73 sty $72
ldx #$00 ldy #$00
disploop:
tya pha jsr spritesub ; spritesub only uses Y and A , no need to save X pla tay
lda $72 ; this just adds an offset to the next sprite plot clc adc #$20 sta $72 lda $73 adc #$00 sta $73
inx cpx #10 ; plots 10 sprites bne disploop ldx #$00
lda $72 ; adds another offset so line moves down a little clc adc #$88 sta $72 lda $73 adc #$02 sta $73
iny cpy #9 ; does this 9 times bne disploop
inc working+3 ; This is just to test the speed of the plot lda working+3 and #$01 ; we just alternate between plotting good sprite data and blank sprite data bne blank
ldx #$00 ; copy a nice sprite to sprite copy: lda worksprite,x sta sprite,x inx cpx #64 bne copy jmp mainloop
blank: ; blank the sprite for blank plot ldx #$00 txa bloop: sta sprite,x inx cpx #64 bne bloop jmp mainloop ; sprite is in 'native' c64 format data Sprite: .byte $00,$00,$00,$00,$d7,$00,$01,$55 .byte $40,$05,$55,$50,$35,$55,$5c,$15 .byte $ff,$54,$d7,$aa,$d7,$de,$82,$b7 .byte $7a,$3c,$ad,$78,$d3,$2d,$e8,$c3 .byte $2b,$e8,$cf,$2b,$7a,$3c,$ad,$7a .byte $82,$ad,$de,$aa,$b7,$d7,$aa,$d7 .byte $15,$ff,$54,$35,$55,$5c,$05,$55 .byte $50,$01,$55,$40,$00,$d7,$00,$00
; used for un-shuffling data Worksprite: .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00 .byte $00,$00,$00,$00,00,$00,$00,$00
working: .byte 0,0,0,0
Spritesub:
; works out the 9 characters that we need to copy the data to.....
lda $72 ; add 08 clc adc #8 sta $74 lda $73 adc #$00 sta $75
lda $72 ; add 16 clc adc #16 sta $76 lda $73 adc #$00 sta $77
lda $72 ; add 320 clc adc #$40 sta $78 lda $73 adc #$01 sta $79
lda $72 ; add 328 clc adc #$48 sta $7a lda $73 adc #$01 sta $7b
lda $72 ; add 336 clc adc #$50 sta $7c lda $73 adc #$01 sta $7d
;#######################
lda $72 ; add 640 clc adc #$80 sta $7e lda $73 adc #$02 sta $7f
lda $72 ; add 648 clc adc #$88 sta $80 lda $73 adc #$02 sta $81
lda $72 ; add 656 clc adc #$90 sta $82 lda $73 adc #$02 sta $83
;#######################
; plot 3 chars of sprite into two rows...
ldy #$00 sloop1: Lda Sprite,y sta ($72),y Lda Sprite+8,y sta ($78),y Lda Sprite+21,y sta ($74),y Lda Sprite+29,y sta ($7a),y Lda Sprite+42,y sta ($76),y Lda Sprite+50,y sta ($7c),y
iny cpy #8 bne sloop1
ldy #$00 ; plot last row (not so tall - only 5 pixels high) sloop2: Lda Sprite+16,y sta ($7e),y Lda Sprite+37,y sta ($80),y Lda Sprite+58,y sta ($82),y iny cpy #5 bne sloop2 rts
;#####################
fixsprites:
ldx #$00 loop1: lda sprite,x sta working sta working+2 lda #$00 sta Working+1 sta working+2 ldy #$04 Looprol: asl working rol working+1 asl working rol working+2 dey bne looprol asl working+1 asl working+1 asl working+1 asl working+1 lda working+1 ora Working+2 sta sprite,x inx cpx #64 bne loop1
; alter all the bits in the graphics to bbc format
ldx #$00 ldy #$00 scon1: lda sprite,x sta worksprite,y inx lda sprite,x sta worksprite+21,y inx lda sprite,x sta worksprite+42,y inx iny cpy #21 bne scon1
ldx #$00 scon2: lda worksprite,x sta sprite,x inx cpx #64 bne scon2 ;Sprite now nicely converted to a kind of bbc workable format..... rts
Last edited by ColinD on Fri Sep 18, 2009 9:15 pm, edited 1 time in total.
|