;: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
	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
	beq null
	rts
null	lda $dd01
	and #1
	pha
	beq low
	lda 5
	bne low
	inc 2
	bne low
	inc 3
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
