cpu 6502
nam Bouncer
chrout = $fded ; display a character
int_lo = $0314
int_hi = $0315
* = $0900  ; assemble at $900
code

	lda int_lo		; load a with the lo order byte of old int
	sta new_vec_lo		; store it in memory
	lda int_hi		; load a with the hi order byte of old int
	sta new_vec_hi		; store it in memory
	sei			; freeze interrupts

	
	lda #$10		; put the new routine into the old vector
	sta int_lo
	lda #$0A
	sta int_hi
	cli			; unfreeze interrupts
	lda #$20		; put locations of sprites in sprite vecotors
	sta $07F8
	lda #$21
	sta $07F9
	lda #$22
	sta $07FA

.lddta	lda sprite1,x		; copy sprite data
	sta $0800,x
	lda sprite2,x
	sta $0840,x
	lda sprite3,x
	sta $0880,x
	inx			; increment index (x)
	cpx #$3F		; compare it (x) with 63 decimal
	bne .lddta		; <= 63 do it again
	
	lda #$80		; locations of sprites
	sta $D000
	sta $D001
	
	lda #$07		; colours of sprites
	sta $D027
	
	lda #$01		; turn on sprite1
	sta $D015
	rts

	;; SPRITE DATA
sprite1 db $0E, $00, $00, $11, $00, $00, $11, $00
	db $00, $0E, $00, $00, $04, $00, $00, $3F
	db $80, $00, $2E, $80, $00, $2E, $80, $00
	db $2E, $80, $00, $2E, $40, $00, $2E, $40
	db $00, $2A, $30, $00, $0A, $00, $00, $0A
	db $30, $00, $0A, $78, $00, $0A, $78, $00
	db $0A, $30, $00, $0A, $00, $00, $0A, $00
	db $00, $3B, $80, $00, $00, $00, $00

sprite2 db $0E, $00, $00, $11, $00, $00, $11, $00
	db $00, $0E, $00, $00, $04, $00, $00, $3F
	db $80, $00, $2E, $80, $00, $2E, $80, $00
	db $2E, $80, $00, $2E, $40, $00, $2E, $40
	db $00, $2A, $30, $00, $0A, $00, $00, $0A
	db $00, $00, $0A, $30, $00, $0A, $78, $00
	db $0A, $78, $00, $0A, $30, $00, $0A, $00
	db $00, $3B, $80, $00, $00, $00, $00

sprite3 db $0E, $00, $00, $11, $00, $00, $11, $00
	db $00, $0E, $00, $00, $04, $00, $00, $3F
	db $80, $00, $2E, $80, $00, $2E, $80, $00
	db $2E, $80, $00, $2E, $40, $00, $2E, $40
	db $00, $2A, $30, $00, $0A, $00, $00, $0A
	db $00, $00, $0A, $00, $00, $0A, $00, $00
	db $0A, $30, $00, $0A, $78, $00, $0A, $78
	db $00, $3B, $B0, $00, $00, $00, $00

	;; PLACE TO STORE NEW INTERRUPT VECTORS
	new_vec_lo db $FF
	new_vec_hi db $FF

	;; DRIBBLE
.newrtn	lda $07F8
	adc #$01
	cmp #$23
	bne .skip
	lda #$20
.skip	sta $07F8
	jmp (new_vec_lo)
	rts

	;; UNINSTALL
.uninst	sei
	lda new_vec_lo
	sta int_lo
	lda new_vec_hi
	sta int_hi
	cli
	rts
code
