; 8-BIT GUY'S DELAY TESTER PROGRAM
; ================================
;
; Retrieved by manually typing it out from the youtube video:
; https://youtu.be/GXXCj5kqPcM?t=18m11s

!to "delaytest.prg",cbm

*=$0801		; START ADDRESS IS $0801
BASIC:	!BYTE $0B,$08,$01,$00,$9E,$32,$30,$36,$31,$00,$00,$00
	;Adds BASIC line: 1 SYS 2061

	;PREPARE_SID_CHIP
	LDA #$0D	; Volume level 14 (of 16)
	STA $D418	; SID 1 volume register
	LDA #$06	; attack=0, decay=6
	STA $D405	; SID attack/decay register voice 1
	LDA #$00	; sustain=0, release=0
	STA $D406	; SID sustain/release register voice 1
	JMP MAINROUTINE
MAINTEXT:
	!BYTE 147,5	; CLEAR SCREEN AND WHITE
	!PET  "delay test by the 8-bit guy."

MAINROUTINE:
	LDA #$00
	STA $D020
	STA $D021
	LDY #$00
TEXT1:
	LDA MAINTEXT,Y
	JSR $FFD2
	INY
	CPY #30
	BNE TEXT1

LISTEN:
	JSR $F142
	CMP #$00
	BEQ LISTEN
	INC $D020
	INC $D021
	LDA #%00100000
	STA $D404	; control gate voice 1
	LDA #67
	STA $D401	; set freq high byte voice 1
	LDA #135
	STA $D400	; set freq low byte voice 1
	LDA #%00100001
	STA $D404	; control gate voice 1
	JMP LISTEN
