	n; sys-----,#,h,c,bg,yx,xx
; sys-----,#,m,c,c1,c2,bg,yx,xx
; sys-----,#,on/off
; sys-----,#,pointer,x,y
; sys-----,#,pointer,x1,y1,x2,y2
xcoord =$14
multic =53276
xpand  =53277
ypand  =53271
colvc1 =53285
colvc2 =53286
getcor =$b7eb
chkcom =$aefd
xcoor2 =$15
lobyte =$fb
hibyte =$fc
vector =53287
bkgvec =53275
spritn =53269
msbspr =53264
pointr =2040
movex  =53248
movey  =53249
;
;
;
*=49152
;
;
       jmp top7
       jmp sprtog
       jmp sprmov
       jmp sprmv ; sprite line
end3   rts
;
;
;
;
;
; initialize sprite
;
top7   jsr chkcom
       jsr getcor ;
       lda xcoord ; get sprite #
       cmp #8
       bcs end3
       sta sprite
       tay
       lda bitset,y
       sta bitt
       txa        ;
       cmp #0     ;hires or multi?
       bne multi  ;skip if multi
       lda bitt
       eor #$ff
       and multic
       sta multic
       jsr chkcom
       jsr getcor
       lda xcoord  ; get color #1
       cmp #16
       bcs end3    ; to big
       lda sprite  ; which sprite?
       tay
       lda xcoord  ; get color
       sta vector,y ; set color
bkgrd  txa         ;bk priority
       cmp #0      ; bk over
       bne low2    ; lower proty
       lda bitt
       eor #$ff
       and bkgvec
       sta bkgvec
       jmp over
;
low2
       lda bitt
       ora bkgvec
       sta bkgvec
       jmp over
multi  lda bitt
       ora multic
       sta multic
       jsr chkcom
       jsr getcor
       lda xcoord
       cmp #16
       bcs end4
       lda sprite
       tay
       lda xcoord  ; color
       sta vector,y
       txa         ;color 1
       sta colvc1
       jsr chkcom
       jsr getcor
       lda xcoord  ;color 2
       sta colvc2
       jmp bkgrd
end4   rts
over
       jsr chkcom
       jsr getcor
       cpx #0
       bne stepy
       lda bitt
       eor #$ff
       and ypand
       sta ypand
       jmp xck
stepy  lda bitt
       ora ypand
       sta ypand
xck    ldx xcoord
       cpx #0
       bne stepx
       lda bitt
       eor #$ff
       and xpand
       sta xpand
       jmp end4
stepx  lda bitt
       ora xpand
       sta xpand
       rts
;
;
sprtog  ;toggle sprite condition
;
;
;
       jsr chkcom ;sprite on/off
       jsr getcor
       lda xcoord
       cmp #8
       bcs end5   ;sprite # to big
       sta sprite
       ldy sprite
       lda bitset,y
       sta bitt
turnof lda bitt   ;turn off sprite
       cpx #0
       bne turnon
       eor #$ff
       and spritn
       sta spritn
end5   rts
turnon
       ora spritn  ;turn on
       sta spritn
       bne end5
;
;
;
;
sprmov
;
;
       jsr chkcom
       jsr getcor ; move sprite
       lda xcoord ;and set pointer
       cmp #8     ; sprite #
       bcs end8   ;to big
       sta sprite
       tay
       lda bitset,y
       sta bitt
       txa
       sta pointr,y ;set pointer
;
       jsr chkcom
       jsr getcor ; get x and y
       lda xcoor2 ; x>255 ?
       cmp #0
       beq lowspr ; <256
       lda bitt   ; >255
       ora msbspr
       sta msbspr
       jmp mover
lowspr lda bitt   ; turn off msb
       eor #$ff
       and msbspr
       sta msbspr
;
;
mover  lda sprite
       asl a
       tay
       lda xcoord ; set x
       sta movex,y ; move x
       txa         ; get y
       iny         ; get y
       sta movex,y ; move y
end8   rts
;
;
;
bitt   .byte $0
sprite .byte $0
temadr .byte $0
; use instead of bitset
;
bitset .byte $01
       .byte $02
       .byte $04
       .byte $08
       .byte $10
       .byte $20
       .byte $40
       .byte $80
;
;
sprmv
;
;
       jsr chkcom
       jsr getcor ; move sprite
       lda xcoord ;and set pointer
       cmp #8     ; sprite #
       bcs end88  ;to big
       sta sprite
       tay
       lda bitset,y
       sta bitt
       txa
       sta pointr,y ;set pointer
       jmp sline    ; line
lnloop lda $58
       sta xcoord
       ldx $57
       lda $59    ; get x hbyte
       sta xcoor2
       cmp #0
       beq lwspr ; <256
       lda bitt   ; >255
       ora msbspr
       sta msbspr
       jmp movr
lwspr  lda bitt   ; turn off msb
       eor #$ff
       and msbspr
       sta msbspr
;
;
movr   lda sprite
       asl a
       tay
       lda xcoord ; set x
       sta movex,y ; move x
       txa         ; get y
       iny         ; get y
       sta movex,y ; move y
end88  rts
       .lib newsline
temp1  .byte $0  ; x1(l)
temp2  .byte $0  ; x1(h)
temp3  .byte $0  ; y1
temp4  .byte $0
temp5  .byte $0  ; x2(l)
temp6  .byte $0  ; x2(h)
temp7  .byte $0  ; y2
temp8  .byte $0  ; new dx(l)
temp9  .byte $0  ; new dx(h)
temp10 .byte $0
temp11 .byte $0;0,1 orff from lc2a4
temp12 .byte $0
temp13 .byte $0
temp14 .byte $0
temp15 .byte $0
temp16 .byte $0
temp17 .byte $0
temp18 .byte $0
temp19 .byte $0  ; dx(l) or dy
temp20 .byte $0  ; dx(h)
temp21 .byte $0
       .end
