home *** CD-ROM | disk | FTP | other *** search
- 100 rem**** musik-kurs (teil 7)
- 101 rem**** 5-voice-player
- 102 rem****
- 103 rem**** by a.& f.hugenroth
- 104 rem****
- 105 :
- 106 sys9*4096:.opt oo:s = 54272
- 107 :
- 108 initirq sei
- 109 lda #<newirq:sta $314
- 110 lda #>newirq:sta $315
- 111 lda #4:sta count
- 112 lda fstep:sta cstep
- 113 lda #0:sta cnote
- 114 ldy #31:iirq2 sta snsp1,y
- 115 sta snsp2,y:sta snsp3,y
- 116 dey:bpl iirq2
- 117 lda #<nmi1:sta $318
- 118 lda #>nmi1:sta $319
- 119 lda #$81:sta $dd0d:lda #1:sta $dd0e
- 120 lda #128:sta $dd04:sta $dd05
- 121 lda #$c8:sta $a6:sta $a9
- 122 lda #$c7:sta $a5:sta $a8
- 123 lda #$ff:sta $a4:sta $a7
- 124 lda #$44:sta $c800
- 125 cli
- 126 rts
- 127 :
- 128 nmi1 sta $9b:sty $9e:ldy #0:clc
- 129 lda ($a4),y:adc ($a7),y:sta $9f
- 130 and #15:ora $aa:sta $d418
- 131 lda $a6:cmp $a5:beq nmi1b
- 132 inc $a4:bne nmi1b:inc $a5
- 133 nmi1b lda #<nmi2:sta $318
- 134 lda $dd0d:ldy $9e:lda $9b:rti
- 135 nmi2 sta $9b:lda $9f
- 136 lsr:lsr:lsr:lsr:ora $aa:sta $d418
- 137 lda #<nmi1:sta $318
- 138 lda $a9:cmp $a8:beq nmi2b
- 139 inc $a7:bne nmi2b:inc $a8
- 140 nmi2b lda $dd0d:lda $9b:rti
- 141 :
- 142 newirq lda 1:pha:lda #54:sta 1
- 143 jsr play:jsr sound
- 144 pla:sta 1:jmp $ea31
- 145 :
- 146 play dec count:bmi play2:rts
- 147 play2 lda #4:sta count
- 148 ldx cstep
- 149 lda $a000,x:sta tkt1
- 150 lda $a100,x:sta tsp1
- 151 lda $a200,x:sta tkt2
- 152 lda $a300,x:sta tsp2
- 153 lda $a400,x:sta tkt3
- 154 lda $a500,x:sta tsp3
- 155 lda $a600,x:sta $b0
- 156 lda $a700,x:sta $b1
- 157 lda $a800,x:sta $b2
- 158 lda $a900,x:sta $b3
- 159 lda tkt1:and #3:tax
- 160 lda tktadrlo,x:sta $f7
- 161 lda tkt1:lsr:lsr:tax
- 162 lda tktadrhi,x:sta $f8
- 163 lda tkt2:and #3:tax
- 164 lda tktadrlo,x:sta $f9
- 165 lda tkt2:lsr:lsr:tax
- 166 lda tktadrhi,x:sta $fa
- 167 lda tkt3:and #3:tax
- 168 lda tktadrlo,x:sta $fb
- 169 lda tkt3:lsr:lsr:tax
- 170 lda tktadrhi,x:sta $fc
- 171 ldy cnote
- 172 lda ($f7),y:sta note1
- 173 lda ($f9),y:sta note2
- 174 lda ($fb),y:sta note3
- 175 lda ($b0),y:sta digi1
- 176 lda ($b2),y:sta digi2
- 177 tya:clc:adc #32:tay
- 178 lda ($f7),y:sta snd1
- 179 lda ($f9),y:sta snd2
- 180 lda ($fb),y:sta snd3
- 181 ldx #2
- 182 play3 lda note1,x:and #127
- 183 cmp #96:beq play5
- 184 cmp #95:beq play4
- 185 clc:adc tsp1,x:ldy snd1,x
- 186 bpl play11:sta glideto,x:lda #1
- 187 sta glideon,x:jmp play10
- 188 play11 sta aktnote1,x
- 189 play10 lda note1,x:bmi play0
- 190 lda #1:sta on1,x
- 191 play0 jsr resetfx
- 192 stx $f9:lda snd1,x:and #7:tax
- 193 lda sndadrl,x:sta $f7:lda snd1,x
- 194 and #127
- 195 lsr:lsr:lsr:tax:lda sndadrh,x
- 196 sta $f8:lda $f9:asl:asl:asl:asl:asl
- 197 tax:ldy #0
- 198 play6 lda ($f7),y:sta snsp1,x
- 199 inx:iny:cpy #32:bcc play6
- 200 ldx $f9:jsr fxinit
- 201 jmp play5
- 202 play4 lda #0:sta on1,x
- 203 play5 dex:bmi play9:jmp play3
- 204 play9 ldx digi1:beq play12
- 205 lda $ae00,x:sta $a4
- 206 lda $ae40,x:sta $a5
- 207 lda $ae80,x:sta $a6
- 208 lda $aec0,x:sta $dd04
- 209 lda $af00,x:sta $dd05
- 210 play12 ldx digi2:beq play13
- 211 lda $ae00,x:sta $a7
- 212 lda $ae40,x:sta $a8
- 213 lda $ae80,x:sta $a9
- 214 play13 lda cnote
- 215 lda cnote
- 216 clc:adc #1
- 217 cmp #32:bcc play7
- 218 inc cstep:lda cstep
- 219 cmp lstep:beq play8:bcc play8
- 220 lda fstep:sta cstep
- 221 play8 lda #0
- 222 play7 sta cnote
- 223 rts
- 224 :
- 225 resetfx lda #0:sta arpcount,x
- 226 sta viblo,x
- 227 sta vibhi,x:sta pulsri,x
- 228 sta portlo,x:sta porthi,x
- 229 sta glidlo,x:sta glidhi,x
- 230 rts
- 231 :
- 232 fxinit ldy #24
- 233 lda ($f7),y:sta arpspeed,x
- 234 ldy #9:lda ($f7),y:lsr:sta viblev,x
- 235 ldy #3:lda ($f7),y:sta pcount,x
- 236 dey:lda ($f7),y:pha:asl:asl:asl:asl
- 237 sta pulslo,x:pla:lsr:lsr:lsr:lsr
- 238 sta pulshi,x:ldy #16
- 239 lda ($f7),y:beq fxinit2:stx trigger
- 240 lda #0:sta fricht,x:iny:lda ($f7),y
- 241 sta ftime1,x:iny:lda ($f7),y
- 242 sta ftime2,x
- 243 fxinit2 rts
- 244 :
- 245 setsid lda snsp1+10:sta s+5
- 246 lda snsp1+11:sta s+6
- 247 lda snsp2+10:sta s+5+7
- 248 lda snsp2+11:sta s+6+7
- 249 lda snsp3+10:sta s+5+14
- 250 lda snsp3+11:sta s+6+14
- 251 ldy #0:clc
- 252 lda aktnote1:adc arpnote:sta $f7
- 253 lda aktnote2:adc arpnote+1:sta $f8
- 254 lda aktnote3:adc arpnote+2:sta $f9
- 255 ldx snsp1+29:beq ssid1a
- 256 dec snsp1+31:bpl ssid1b
- 257 sty snsp1+29:ssid1b lda snsp1+30
- 258 sta $f7:jmp ssid2
- 259 ssid1a ldx snsp1
- 260 lda on1:bne ssid2
- 261 ldx snsp1+1
- 262 ssid2 stx s+4
- 263 ldx snsp2+29:beq ssid2a
- 264 dec snsp2+31:bpl ssid2b
- 265 sty snsp2+29:ssid2b lda snsp2+30
- 266 sta $f8:jmp ssid3
- 267 ssid2a ldx snsp2
- 268 lda on2:bne ssid3
- 269 ldx snsp2+1
- 270 ssid3 stx s+4+7
- 271 ldx snsp3+29:beq ssid3a
- 272 dec snsp3+31:bpl ssid3b
- 273 sty snsp3+29:ssid3b lda snsp3+30
- 274 sta $f9:jmp ssid4
- 275 ssid3a ldx snsp3
- 276 lda on3:bne ssid4
- 277 ldx snsp3+1
- 278 ssid4 stx s+4+14
- 279 ldx $f7:clc
- 280 lda notelo,x:adc tlo+0:sta s
- 281 lda notehi,x:adc thi+0:sta s+1
- 282 ldx $f8:clc
- 283 lda notelo,x:adc tlo+1:sta s+7
- 284 lda notehi,x:adc thi+1:sta s+1+7
- 285 ldx $f9:clc
- 286 lda notelo,x:adc tlo+2:sta s+14
- 287 lda notehi,x:adc thi+2:sta s+1+14
- 288 lda pulslo+0:sta s+2
- 289 lda pulshi+0:sta s+3
- 290 lda pulslo+1:sta s+2+7
- 291 lda pulshi+1:sta s+3+7
- 292 lda pulslo+2:sta s+2+14
- 293 lda pulshi+2:sta s+3+14
- 294 lda trigger:asl:asl:asl:asl:asl
- 295 clc:adc #<snsp1:sta $f7
- 296 lda #>snsp1:adc #0:sta $f8
- 297 ldy #22:lda ($f7),y
- 298 asl:asl:asl:asl:sta $f9:ldy #16
- 299 lda ($f7),y:beq ssidend:and #15
- 300 ora $f9:sta s+23:lda ($f7),y
- 301 and #240:sta $aa:lda #0:sta s+21
- 302 ldy #23:lda ($f7),y:sta s+22
- 303 ssidend lda timerl:sta $dc04
- 304 lda timerh:sta $dc05:rts
- 305 :
- 306 sound ldx #0:lda #<snsp1
- 307 sta $f7:lda #>snsp1:sta $f8
- 308 ;**
- 309 ;** arpeggio
- 310 ;**
- 311 sound1 lda #25:clc
- 312 adc arpcount,x:tay:lda ($f7),y
- 313 sta arpnote,x
- 314 dec arpspeed,x:bpl sound2
- 315 ldy #24:lda ($f7),y:sta arpspeed,x
- 316 lda arpcount,x:clc:adc #1
- 317 and #3:sta arpcount,x
- 318 ;**
- 319 ;** vibrato
- 320 ;**
- 321 sound2 ldy #7:lda ($f7),y
- 322 beq sound2b:sec:sbc #1:sta ($f7),y
- 323 jmp sound3
- 324 sound2b dec viblev,x:bpl sound2c
- 325 ldy #8:lda ($f7),y:eor #255
- 326 sta ($f7),y:iny:lda ($f7),y
- 327 sta viblev,x:sound2c ldy #8
- 328 lda ($f7),y:bmi sound2d:clc
- 329 adc viblo,x:sta viblo,x:lda vibhi,x
- 330 adc #0:sta vibhi,x:jmp sound3
- 331 sound2d eor #255:sta $f9:sec
- 332 lda viblo,x:sbc $f9:sta viblo,x
- 333 lda vibhi,x:sbc #0:sta vibhi,x
- 334 ;**
- 335 ;** pulse
- 336 ;**
- 337 sound3 ldy #5:lda ($f7),y:sta $f9
- 338 lda pulsri,x:bmi sound3a
- 339 lda pulslo,x:clc:adc $f9
- 340 sta pulslo,x:lda pulshi,x:adc #0
- 341 sta pulshi,x
- 342 dec pcount,x:bpl sound4
- 343 ldy #4:lda ($f7),y:sta pcount,x
- 344 lda #128:sta pulsri,x:jmp sound4
- 345 sound3a lda pulslo,x:sec:sbc $f9
- 346 sta pulslo,x:lda pulshi,x:sbc #0
- 347 sta pulshi,x:dec pcount,x
- 348 bpl sound4:ldy #3:lda ($f7),y
- 349 sta pcount,x:lda #0:sta pulsri,x
- 350 ldy #6:lda ($f7),y:and #16
- 351 bne sound4:dey:lda #0:sta ($f7),y
- 352 ;**
- 353 ;** portamento
- 354 ;**
- 355 sound4 ldy #6:lda ($f7),y:and #15
- 356 beq sound5:and #3:cmp #1
- 357 beq sound4a:ldy #12:lda portlo,x
- 358 clc:adc ($f7),y:sta portlo,x
- 359 iny:lda porthi,x:adc ($f7),y
- 360 sta porthi,x:iny:cmp ($f7),y
- 361 bcc sound5:jmp sound4b
- 362 sound4a ldy #12:lda portlo,x:sec
- 363 sbc ($f7),y:sta portlo,x
- 364 iny:lda porthi,x:sbc ($f7),y
- 365 sta porthi,x:iny:cmp ($f7),y
- 366 bcs sound5:sound4b ldy #6
- 367 lda ($f7),y:and #4:beq sound4c
- 368 lda #0:sta portlo,x:sta porthi,x
- 369 jmp sound5:sound4c lda ($f7),y
- 370 and #240:sta ($f7),y
- 371 ;**
- 372 ;** filter
- 373 ;**
- 374 sound5 cpx trigger:bne sound6
- 375 lda fricht,x:bmi sound5a
- 376 dec ftime1,x:bpl sound5b:lda #255
- 377 sta fricht,x:sta ftime1,x
- 378 jmp sound6:sound5b ldy #19
- 379 lda ($f7),y:ldy #23:clc:adc ($f7),y
- 380 sta ($f7),y:jmp sound6
- 381 sound5a dec ftime2,x
- 382 bpl sound5d:lda #0:sta fricht,x
- 383 lda #255:sta ftime2,x
- 384 ldy #21:lda ($f7),y:beq sound6
- 385 ldy #17:lda ($f7),y:sta ftime1,x
- 386 iny:lda ($f7),y:sta ftime2,x
- 387 jmp sound6:sound5d ldy #20
- 388 lda ($f7),y:ldy #23:clc:adc ($f7),y
- 389 sta ($f7),y
- 390 ;**
- 391 ;** glide
- 392 ;**
- 393 sound6 lda glideon,x:bne sound6d
- 394 jmp sound7:sound6d ldy aktnote1,x
- 395 lda notelo,y:clc
- 396 adc tlo,x:sta $f9:lda notehi,y
- 397 adc thi,x:sta $fa
- 398 lda glideto,x:cmp aktnote1,x
- 399 bcc sound6a:ldy #12:lda glidlo,x
- 400 clc:adc ($f7),y:sta glidlo,x:iny
- 401 lda glidhi,x:adc ($f7),y
- 402 sta glidhi,x:ldy glideto,x
- 403 lda $fa:cmp notehi,y
- 404 bcc sound7:bne sound6b
- 405 lda $f9:cmp notelo,y:bcc sound7
- 406 jmp sound6b
- 407 sound6a ldy #12:lda glidlo,x
- 408 sec:sbc ($f7),y:sta glidlo,x:iny
- 409 lda glidhi,x:sbc ($f7),y
- 410 sta glidhi,x:ldy glideto,x
- 411 lda notehi,y:cmp $fa:bcc sound7
- 412 bne sound6b:lda notelo,y
- 413 cmp $f9:bcc sound7
- 414 sound6b lda #0:sta glideon,x
- 415 sta glidlo,x:sta glidhi,x
- 416 lda glideto,x:sta aktnote1,x
- 417 ;**
- 418 ;** soundende
- 419 ;**
- 420 sound7 lda viblo,x:clc
- 421 adc portlo,x:sta tlo,x:lda tlo,x
- 422 clc:adc glidlo,x:sta tlo,x
- 423 lda vibhi,x:adc porthi,x:sta thi,x
- 424 lda thi,x:clc:adc glidhi,x
- 425 sta thi,x:lda tlo,x:clc:ldy #15
- 426 adc ($f7),y:sta tlo,x
- 427 lda thi,x:adc #0:sta thi,x
- 428 lda $f7:clc:adc #32:sta $f7
- 429 lda $f8:adc #0:sta $f8
- 430 inx:cpx #3:bcs sounde:jmp sound1
- 431 sounde jmp setsid
- 432 :
- 433 :
- 434 :
- 435 tktadrlo .byt $00,$40,$80,$c0
- 436 tktadrhi .byt $b0,$b1,$b2,$b3
- 437 : .byt $b4,$b5,$b6,$b7
- 438 : .byt $b8,$b9,$ba,$bb
- 439 : .byt $bc,$bd,$be,$bf
- 440 note1 .byt 0
- 441 note2 .byt 0
- 442 note3 .byt 0
- 443 tkt1 .byt 0
- 444 tkt2 .byt 0
- 445 tkt3 .byt 0
- 446 tsp1 .byt 0
- 447 tsp2 .byt 0
- 448 tsp3 .byt 0
- 449 snd1 .byt 0
- 450 snd2 .byt 0
- 451 snd3 .byt 0
- 452 on1 .byt 0
- 453 on2 .byt 0
- 454 on3 .byt 0
- 455 tlo .byt 0,0,0
- 456 thi .byt 0,0,0
- 457 pulsri .byt 0,0,0
- 458 pcount .byt 0,0,0
- 459 pulslo .byt 0,0,0
- 460 pulshi .byt 0,0,0
- 461 arpcount .byt 0,0,0
- 462 arpnote .byt 0,0,0
- 463 arpspeed .byt 0,0,0
- 464 viblev .byt 0,0,0
- 465 viblo .byt 0,0,0
- 466 vibhi .byt 0,0,0
- 467 portlo .byt 0,0,0
- 468 porthi .byt 0,0,0
- 469 fricht .byt 0,0,0
- 470 ftime1 .byt 0,0,0
- 471 ftime2 .byt 0,0,0
- 472 glideon .byt 0,0,0
- 473 glideto .byt 0,0,0
- 474 glidlo .byt 0,0,0
- 475 glidhi .byt 0,0,0
- 476 trigger .byt 0
- 477 cnote .byt 0
- 478 cstep .byt 0
- 479 fstep .byt 0
- 480 lstep .byt 3
- 481 count .byt 0
- 482 speed .byt 0
- 483 timerl .byt 0
- 484 timerh .byt $39
- 485 digi1 .byt 0
- 486 digi2 .byt 0
- 487 snsp1 .asc "********************************"
- 488 snsp2 .asc "********************************"
- 489 snsp3 .asc "********************************"
- 490 aktnote1 .byt 0
- 491 aktnote2 .byt 0
- 492 aktnote3 .byt 0
- 493 notelo .byt 22,39,57,75,95,116,138
- 494 : .byt 161,186,212,240,14,45
- 495 : .byt 78,113,150,190,231,20
- 496 : .byt 66,116,169,224,27,90
- 497 : .byt 156,226,45,123,207,39
- 498 : .byt 133,232,81,193,55,180
- 499 : .byt 56,196,89,247,158,78
- 500 : .byt 10,208,162,129,109,103
- 501 : .byt 112,137,178,237,59,157
- 502 : .byt 20,160,69,3,219,207
- 503 : .byt 225,18,101,219,118,58
- 504 : .byt 39,65,138,5,181,157
- 505 : .byt 193,36,201,182,237,115
- 506 : .byt 78,130,20,10,106,59
- 507 : .byt 130,72,147,107,218,231
- 508 : .byt 156,4,40,20
- 509 notehi .byt 1,1,1,1,1,1,1,1,1,1,1
- 510 : .byt 2,2,2,2,2,2,2,3,3,3,3
- 511 : .byt 3,4,4,4,4,5,5,5,6,6,6
- 512 : .byt 7,7,8,8,9,9,10,10,11
- 513 : .byt 12,13,13,14,15,16,17
- 514 : .byt 18,19,20,21,23,24,26
- 515 : .byt 27,29,31,32,34,36,39
- 516 : .byt 41,43,46,49,52,55,58
- 517 : .byt 62,65,69,73,78,82,87
- 518 : .byt 92,98,104,110,117,124
- 519 : .byt 131,139,147,156,165
- 520 : .byt 175,185,196,208,221
- 521 : .byt 234,248
- 522 sndadrl .byt $00,$20,$40,$60
- 523 : .byt $80,$a0,$c0,$e0
- 524 sndadrh .byt $aa,$ab,$ac,$ad
-