Say hello to D-Pad Hero 2 repository
[dpadhero2.git] / ampdisplay.asm
blobaf024fc239f8357b56a897f09dc10110e457f3e0
2 ; Copyright (C) 2010 Kent Hansen.
4 ; This program is free software; you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation; either version 3 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .include "common/ppubuffer.h"
19 .include "sound/mixer.h"
21 .dataseg
23 channel_index .db
24 temp_sound_status .db
26 .codeseg
28 .public update_ampdisplay
30 .extrn sound_status:byte
31 .extrn volume_table:byte
33 .proc update_ampdisplay_step
34 ; Only one channel's display is updated per frame.
35 lda channel_index
36 bne +
37 lda sound_status
38 sta temp_sound_status
39 + tay
40 lda @@channel_offsets,y
41 tax
42 .ifndef NO_MUTABLE_CHANNELS
43 lsr temp_sound_status
44 .endif
45 lda mixer.tonals.period.lo,x
46 ora mixer.tonals.period.hi,x
47 beq ++
48 lda mixer.envelopes.master,x
49 .ifndef NO_MUTABLE_CHANNELS
50 bcc +
51 lda #0 ; the channel is muted
53 .endif
54 ++ and #$F0
55 ora mixer.envelopes.vol.int,x
56 tay
57 lda volume_table,y
58 ora mixer.master_vol
59 tay
60 lda volume_table,y ; 0..15
61 asl
62 cmp #17
63 bcc +
64 lda #16
65 + pha
66 ldy #$21 : ldx #$84
67 lda channel_index
68 clc
69 adc #$03
70 jsr begin_ppu_string
71 pla
72 asl
73 asl
74 tay
75 lda @@display_tiles+0,y
76 jsr put_ppu_string_byte
77 lda @@display_tiles+1,y
78 jsr put_ppu_string_byte
79 .if 1
80 ; 16 levels
81 lda @@display_tiles+2,y
82 jsr put_ppu_string_byte
83 lda @@display_tiles+3,y
84 jsr put_ppu_string_byte
85 .endif
86 jsr end_ppu_string
88 inc channel_index
89 lda channel_index
90 and #3
91 sta channel_index
92 rts
94 @@channel_offsets:
95 .db sizeof tonal_state * 0
96 .db sizeof tonal_state * 1
97 .db sizeof tonal_state * 2
98 .db sizeof tonal_state * 3
99 .db sizeof tonal_state * 4
101 @@display_tiles:
102 .if 0
103 ; 9 levels
104 .db $88,$88
105 .db $88,$89
106 .db $88,$8A
107 .db $88,$8B
108 .db $88,$8C
109 .db $89,$8C
110 .db $8A,$8C
111 .db $8B,$8C
112 .db $8C,$8C
113 .else
114 ; 17 levels
115 .db $88,$88,$88,$88 ; 0
116 .db $88,$88,$88,$89 ; 1
117 .db $88,$88,$88,$8A ; 2
118 .db $88,$88,$88,$8B ; 3
119 .db $88,$88,$88,$8C ; 4
120 .db $88,$88,$89,$8C ; 5
121 .db $88,$88,$8A,$8C ; 6
122 .db $88,$88,$8B,$8C ; 7
123 .db $88,$88,$8C,$8C ; 8
124 .db $88,$89,$8C,$8C ; 9
125 .db $88,$8A,$8C,$8C ; 10
126 .db $88,$8B,$8C,$8C ; 11
127 .db $88,$8C,$8C,$8C ; 12
128 .db $89,$8C,$8C,$8C ; 13
129 .db $8A,$8C,$8C,$8C ; 14
130 .db $8B,$8C,$8C,$8C ; 15
131 .db $8C,$8C,$8C,$8C ; 16
132 .endif
133 .endp
135 .proc update_ampdisplay
136 jsr update_ampdisplay_step
137 jmp update_ampdisplay_step
138 .endp
140 .end