-
Notifications
You must be signed in to change notification settings - Fork 0
/
squarewave.asm
68 lines (51 loc) · 831 Bytes
/
squarewave.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
PORTB = $6000
PORTA = $6001
DDRB = $6002
DDRA = $6003
T1CL = $6004
T1CH = $6005
T2CL = $6008
T2CH = $6009
SR = $600A
ACR = $600B
IFR = $600D
IER = $600E
PITCH_HIGH = $0000
.org $8000
sing_note: ;precondition number of 64th notes (16 in 1 beat) to play for in A register; pitch low byte in y; pitch high byte in PITCH_HIGH
sty T1CL
ldy PITCH_HIGH
sty T1CH
tay
sing_note_counter_loop:
lda #$d0
sta T2CL
lda #$84
sta T2CH
sing_note_wait_loop:
lda IFR
and #%00100000
beq sing_note_wait_loop
dey
bne sing_note_counter_loop
rts
reset:
ldx #$ff
txs
stx IFR
lda #$00
sta PORTA
sta PORTB
lda #%11010100 ;Set ACR
sta ACR
lda #$70
sta T1CL
lda #$04
sta T1CH
lda #%11111111
sta PORTA
halt:
jmp halt
.org $fffc
.word reset
.word $0000