;:sys36864
	;.opt oo
	*= $c000
tk	=10*1000
	lda #<985
	ldy #>985
	sta $dd04
	sty $dd05
	lda #<tk
	ldy #>tk
	sta $dd06
	sty $dd07
	lda #0
	sta 2
	sta 3
	sta 6
	lda #0
	sta $dd03
	lda #%10000010
	sta $dd0d
	lda #<nmi
	ldy #>nmi
	sta 792
	sty 793
	lda #%01011000
	sta $dd0f
	ora #1
	and #239
	sta $dd0f
	lda #%10010000
	sta $dd0e
	ora #1
	and #239
	sta $dd0e
	lda #0
	sta 4
	lda #1
	sta 5
loop	lda 4
	bne raus
	lda $dd01
	and #1
	pha
	beq low
	lda 5
	bne low
	inc 2
	bne low
	inc 3
	bne low
over	lda #1
	sta 6
	rts
low	pla
	sta 5
	jmp loop
nmi	pha
	txa
	pha
	tya
	pha
	ldy $dd0d
	tya
	and #%10
	bne alarm
	jmp $fe56
alarm	sta 4
	jmp $febc
raus	lda 2
	sta 4
	lda 3
	sta 5
	asl 2
	rol 3
	bcs over
	lda 4
	adc 2
	sta 2
	lda 5
	adc 3
	sta 3
	bcs over
	asl 2
	rol 3
	bcs over
	rts
