This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.asm
115 lines (91 loc) · 1.89 KB
/
player.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#importonce
#import "macros.asm"
#import "mem.asm"
.filenamespace player
.label position = $05
wait:
.byte $00
loop_found:
.byte $00
loop_position:
.word $0000
init:
lda #<mem.song_bin; sta position
lda #>mem.song_bin; sta position + 1
lda #$00
sta wait
sta loop_found
sta loop_position
sta loop_position + 1
// Set SID registers
// ADSR
lda #$00
sta $D405
lda #$F0
sta $D406
// Square wave with 50% duty
lda #$41
sta $D404
lda #$00
sta $D402
lda #$08
sta $D403
// Master volume to max
lda #$0F
sta $D418
rts
fini:
lda #$00
sta $D400
sta $D401
sta $D402
sta $D403
sta $D404
sta $D405
sta $D406
sta $D418
rts
update:
lda wait
cmp #$00
beq update_step
dec wait
beq update_step
rts
update_step:
ldy #$00
lda (position), y
sta wait
inc16(position)
cmp #$FF
beq update_handle_loop
cmp #$00
beq update_handle_exit
lda (position), y
sta $D400
inc16(position)
lda (position), y
sta $D401
inc16(position)
rts
update_handle_loop:
lda #$00
sta wait
lda loop_found
beq update_set_loop
// Jump to loop
lda loop_position; sta position
lda loop_position + 1; sta position + 1
rts
update_set_loop:
lda #$01
sta loop_found
lda position; sta loop_position
lda position + 1; sta loop_position + 1
rts
update_handle_exit:
// TODO
//raise_error("Unimplemented")
rts
update_end:
rts