]> git.sur5r.net Git - cc65/blob - testcode/lib/gamate/audiotest.s
6d9670bca5aba17ea19795f067e9f6bced86aa0e
[cc65] / testcode / lib / gamate / audiotest.s
1 .include "gamate.inc"
2         .zeropage
3 addr: .word 0
4 psa:    .word 0
5
6 .word 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 ; get out of sensitiv area
7
8 readaddr: .word 0
9 editbuffer1: .byte 0,0,0,0, 0,0,0,0 ;0,1,2,3,4,5,6,7
10 writeaddr: .word 0
11 editbuffer2: .byte 0,0,0,0, 0,0,0,0 ;8,9,$a,$b,$c,$d,$e,$f
12 cursor: .byte 0
13 controlslast: .byte 0
14 controlsedge: .byte 0
15
16         .data
17 temp_x: .byte 0
18 temp_y: .byte   0
19 temp_a: .byte 0
20 irq_count:      .byte 0
21 nmi_count:      .byte 0
22 psx:    .byte 0
23 psy:    .byte 0
24 xpos: .byte 0
25 ypos:   .byte 0
26
27         .code
28 checksum:       .word 0
29         .byte 1,0,1
30         .byte "COPYRIGHT BIT CORPORATION", 0, $ff
31         jmp     reset
32         jmp nmi
33         jmp irq
34
35 chars:
36 .incbin "cga2.chr"
37                         
38 hex2asc:        .byte "0123456789abcdef"
39
40 .proc nmi
41                         inc nmi_count
42                         rts
43 .endproc
44
45 .proc   irq
46                         inc irq_count
47                         rts
48 .endproc
49
50 .proc reset
51                         lda #>audio_base
52                         sta writeaddr+1
53                         sta readaddr+1
54                         lda #<audio_base
55                         sta writeaddr
56                         sta readaddr
57
58                         lda #$10
59                         sta editbuffer1+6
60                         lda #$e
61                         sta editbuffer2+5
62                         lda #$ff
63                         sta editbuffer2+3
64                         lda #$ff
65                         sta editbuffer2+4
66                         lda #$0f
67                         sta editbuffer2
68                         lda #$0f
69                         sta editbuffer2+1
70                         lda #$0e
71                         sta editbuffer2+2
72                         lda     #$38
73                         sta editbuffer1+7
74
75                         lda #0
76                         sta     lcd_x_pos
77                         sta lcd_y_pos
78                         sta irq_count
79                         sta cursor
80                         lda #1
81                         sta nmi_count
82                         cli
83                         lda     #lcd_mode_y_increment
84                         sta     lcd_mode
85
86                         jsr printy
87
88                         lda #1
89                         sta nmi_enable
90
91 loop:   
92                         lda irq_count
93 loop1:
94                         cmp irq_count
95                         beq     loop1
96                         lda irq_count
97                         and #7
98                         bne loop1               
99
100                         lda     #lcd_mode_y_increment
101                         sta     lcd_mode
102
103                         ldx #3
104                         ldy #32
105                         lda irq_count
106                         jsr printhex
107
108
109                         lda cursor
110                         ldy     #0
111                         cmp #20
112                         bcc firstline
113                         sec
114                         sbc     #20
115                         ldy #24
116 firstline:
117                         sta lcd_x
118                         sty lcd_y
119                         lda #' '
120                         jsr printsign
121 norclearcursor:
122                         
123                         jsr inputs
124
125                         lda irq_count
126                         and #8
127                         bne nocursor
128                         lda cursor
129                         ldy     #0
130                         cmp #20
131                         bcc firstline2
132                         sec
133                         sbc     #20
134                         ldy #24
135 firstline2:
136                         sta lcd_x
137                         sty lcd_y
138                         lda #'x'
139                         jsr printsign
140 nocursor:
141
142                         lda     #lcd_mode_y_increment
143                         sta     lcd_mode
144                         jsr printy                      
145                         jmp loop
146 .endproc
147
148 .proc printy
149
150                         ldy #0
151 loop1: 
152                         tya
153                         pha
154                         asl
155                         tax
156                         lda readaddr,y
157                         ldy #8
158                         jsr printhex
159                         pla
160                         tay
161                         iny
162                         cpy #10
163                         bne loop1
164
165 loop2:
166                         tya
167                         pha
168                         tya
169                         sec
170                         sbc #10
171                         asl
172                         tax
173                         lda readaddr,y
174                         ldy #16
175                         jsr printhex
176                         pla
177                         tay
178                         iny
179                         cpy #20
180                         bne loop2
181
182                         ldx #0
183                         ldy #32
184                         lda nmi_count
185                         jsr printhex
186
187                         rts             
188 .endproc
189
190 .proc inputs
191                         lda controlslast
192                         eor controls
193                         and controlslast
194                         eor #$ff
195                         sta controlsedge
196                         and #up
197                         bne notup
198
199                         lda cursor
200                         lsr
201                         tay
202                         bcs uplow
203                         lda readaddr,y
204                         clc
205                         adc #$10
206                         sta readaddr,y
207                         jmp notup
208 uplow:lda readaddr,y
209                         clc
210                         adc #1
211                         sta readaddr,y
212 notup:lda controlsedge
213                         and #down
214                         bne notdown
215                         lda cursor
216                         lsr
217                         tay
218                         bcs downlow
219                         lda readaddr,y
220                         sec
221                         sbc #$10
222                         sta readaddr,y
223                         jmp notdown
224 downlow:
225                         lda readaddr,y
226                         sec
227                         sbc #1
228                         sta readaddr,y
229 notdown:lda controlsedge
230                         and #left
231                         bne notleft
232                         lda cursor
233                         beq notleft
234                         dec cursor
235 notleft:lda controlsedge
236                         and #right
237                         bne notright
238                         lda cursor
239                         cmp #40
240                         beq notright
241                         inc cursor
242 notright:lda controlsedge
243                         and #start
244                         bne notstart
245                         lda #0
246                         sta audio_base
247                         sta audio_base+1
248                         sta audio_base+2
249                         sta audio_base+3
250                         sta audio_base+4
251                         sta audio_base+5
252                         sta audio_base+6
253                         sta audio_base+8
254                         sta audio_base+9
255                         sta audio_base+10
256                         sta audio_base+11
257                         sta audio_base+12
258                         sta audio_base+13
259                         sta audio_base+7
260 notstart:lda controlsedge
261                         and #select
262                         bne notselect
263                         lda editbuffer1
264                         sta audio_base
265                         lda editbuffer1+1
266                         sta audio_base+1
267                         lda editbuffer1+2
268                         sta audio_base+2
269                         lda editbuffer1+3
270                         sta audio_base+3
271                         lda editbuffer1+4
272                         sta audio_base+4
273                         lda editbuffer1+5
274                         sta audio_base+5
275                         lda editbuffer1+6
276                         sta audio_base+6
277                         lda editbuffer2
278                         sta audio_base+8
279                         lda editbuffer2+1
280                         sta audio_base+9
281                         lda editbuffer2+2
282                         sta audio_base+10
283                         lda editbuffer2+3
284                         sta audio_base+11
285                         lda editbuffer2+4
286                         sta audio_base+12
287                         lda editbuffer2+5
288                         sta audio_base+13
289                         lda editbuffer1+7
290                         sta audio_base+7
291 notselect:lda controlsedge
292                         and #button_a
293                         bne notbuttona
294                         ldy #0
295                         ldy #0
296 writea:lda editbuffer1,y
297                         sta (writeaddr),y
298                         iny
299                         cpy     #8
300                         bne writea
301 writeb:lda editbuffer2-8,y
302                         sta (writeaddr),y
303                         iny
304                         cpy     #16
305                         bne writeb
306 notbuttona:lda controlsedge
307                         and #button_b
308                         bne notbuttonb
309                         ldy #0
310 reada:lda (readaddr),y
311                         sta editbuffer1,y
312                         iny
313                         cpy     #8
314                         bne reada
315 readb:lda (readaddr),y
316                         sta editbuffer2-8,y
317                         iny
318                         cpy     #16
319                         bne readb
320 notbuttonb:
321                         lda controls
322                         sta     controlslast
323                         rts
324 .endproc
325
326 .proc printstring
327                         sta     psa
328                         stx psa+1
329                         ldx #0
330                         stx     psx
331                         sty psy
332 printstring2:
333                         ldy     #0
334                         lda     (psa),y
335                         beq printstring1
336                         ldx psx
337                         stx     lcd_x
338                         ldy psy
339                         sty     lcd_y
340                         jsr printsign                   
341                         inc psx
342                         lda psa
343                         clc
344                         adc     #1
345                         sta psa
346                         lda psa+1
347                         adc     #0
348                         sta psa+1
349                         jmp printstring2
350 printstring1:
351                         rts                     
352 .endproc
353
354 .proc printstringy
355                         sta     psa
356                         stx psa+1
357 printstring2:
358                         ldy     #0
359                         lda     (psa),y
360                         beq printstring1
361                         jsr printsign                   
362                         lda psa
363                         clc
364                         adc     #1
365                         sta psa
366                         lda psa+1
367                         adc     #0
368                         sta psa+1
369                         jmp printstring2
370 printstring1:
371                         rts                     
372 .endproc
373
374
375 .proc printhex
376                         pha
377                         lsr
378                         lsr
379                         lsr
380                         lsr
381                         and #$0f
382                         stx     temp_x
383                         tax                     
384                         lda     hex2asc,x
385                         ldx     temp_x
386                         stx     lcd_x
387                         sty     lcd_y
388                         jsr     printsign
389                         pla
390                         and     #$0f
391                         inx
392                         stx     temp_x
393                         tax
394                         lda     hex2asc,x
395                         ldx     temp_x
396                         stx     lcd_x
397                         sty     lcd_y
398                         jmp printsign
399 .endproc
400
401 .proc printsign
402                         sty     temp_y
403                         stx     temp_x
404                         sta     temp_a
405                         lda temp_a
406                         sta     addr
407                         lda #0
408                         sta addr+1
409                         asl     addr
410                         rol     addr+1
411                         asl     addr
412                         rol addr+1
413                         asl addr
414                         rol addr+1
415                         lda addr
416                         clc
417                         adc     #<chars
418                         sta     addr
419                         lda     addr+1
420                         adc     #>chars
421                         sta addr+1
422                         ldx     #8
423                         ldy #0
424 printsign1:
425                         lda     (addr),y
426                         sta     lcd_data
427                         iny
428                         dex
429                         bne printsign1
430                         ldx     temp_x
431                         ldy     temp_y
432                         rts
433 .endproc
434