/[projet1]/users/twilighte/Stormlord/sfx.s
Defence Force logotype

Contents of /users/twilighte/Stormlord/sfx.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 412 - (show annotations)
Thu Oct 7 20:50:23 2010 UTC (8 years, 5 months ago) by dbug
File size: 16988 byte(s)
Added Stormlord
1 ;SFX Command Codes
2 #define SETCHANNEL_A 0
3 #define SETCHANNEL_B 1
4 #define SETCHANNEL_C 2
5
6 #define SETCHANNEL_A_ 3
7 #define SETCHANNEL_A_E 4
8 #define SETCHANNEL_A_N 5
9 #define SETCHANNEL_A_NE 6
10 #define SETCHANNEL_A_T 7
11 #define SETCHANNEL_A_TE 8
12 #define SETCHANNEL_A_TN 9
13 #define SETCHANNEL_A_TNE 10
14 #define SETCHANNEL_B_ 11
15 #define SETCHANNEL_B_E 12
16 #define SETCHANNEL_B_N 13
17 #define SETCHANNEL_B_NE 14
18 #define SETCHANNEL_B_T 15
19 #define SETCHANNEL_B_TE 16
20 #define SETCHANNEL_B_TN 17
21 #define SETCHANNEL_B_TNE 18
22 #define SETCHANNEL_C_ 19
23 #define SETCHANNEL_C_E 20
24 #define SETCHANNEL_C_N 21
25 #define SETCHANNEL_C_NE 22
26 #define SETCHANNEL_C_T 23
27 #define SETCHANNEL_C_TE 24
28 #define SETCHANNEL_C_TN 25
29 #define SETCHANNEL_C_TNE 26
30
31 #define SETPITCH 27
32
33 #define SETVOLUME 28
34
35 #define PLAY 44
36
37 #define END_A_OFF 94
38 #define END_B_OFF 95
39 #define END_AB_OFF 96
40 #define END_C_OFF 97
41 #define END_AC_OFF 98
42 #define END_BC_OFF 99
43 #define END_ABC_OFF 100
44
45 #define SFXJUMP 101
46
47 #define ADJUSTVOLUME 102+15
48
49 #define LOOPONVOLUMERANGE 133
50
51 #define LOOPONCOUNTERRANGE 134
52
53 #define SETNOISE 135
54
55 #define SETENV 167
56
57 #define TRIGGER_SAWTOOTH 168
58 #define TRIGGER_TRIANGLE 169
59 #define TRIGGER_DESCEND 170
60 #define TRIGGER_ASCEND 171
61
62 #define ADJUSTPITCH 172+15
63
64 #define END_NORMAL 203
65
66 #define SETNOTE 204
67
68 #define SETCOUNTER 205
69
70 #define RANDOM_HIGH 0
71
72
73 ;Simple SFX Driver
74 ;Utilising all three channels and EG with Software Envelopes
75 ;1) End of Puzzle Memory - A High Beep
76 ;2) Exit Pocket Computer - B Low Beep
77 ;3) Enter Pocket Computer - B Mid beep
78 ;4) Pause Game - A Mid beep
79 ;5) Resume game - A High beep
80 ;6) merge failed - A Low Beep
81 ;7) merge successful - A High Beep
82 ;8) Passcode found - ABC Chord
83 ;9) Dial Tone - AB Tone
84 ;10)Dial option1 - AB Sequence of set pitches/notes, long high note then random high note then silence
85 ;11)Dial option2 - AB Sequence of set pitches/notes, long high note then random high note then silence
86 ;12)SC Scale - BC Note fading
87 ;13)SC Sequence wrong - BC Low Beep
88 ;14)SC Sequence right - BC High Beep
89 ;15)Footstep Left - AN Tsh
90 ;16)Footstep Right - AN Tsh
91 ;17)Robot plasma - CE tzz
92 ;18)Lift start - BC Pitchbend up then constant dischord
93 ;19)Lift end - BC Pitchbend down to silence
94 ;24)Robot Turn - B Tone osc
95 ;25)Robot Motors - B Tone Low pitch Pattern
96 ;26)Plasma Ethan(Kill) - CE intermittant random tzz
97
98
99
100 ;All Sounds are dedicated to a particular sound source, be it A,B,C,N,E or a combination thereof.
101 ;Simplicity is the name of the game here since the code must fit into the smallest space.
102 ;Scripts are chosen for their flexibility (though not neccesarily for their speed).
103
104 ;Each script is dedicated to a unique SFX.
105 ;The script dictates the channels used.
106 ;A single script may be as much as 256 bytes long.
107
108 ;000 SETCHANNEL_A
109 ;001 SETCHANNEL_B
110 ;002 SETCHANNEL_C
111 ;
112 ;003 SETCHANNEL_A_tne
113 ;004 SETCHANNEL_A_tnE
114 ;005 SETCHANNEL_A_tNe
115 ;006 SETCHANNEL_A_tNE
116 ;007 SETCHANNEL_A_Tne
117 ;008 SETCHANNEL_A_TnE
118 ;009 SETCHANNEL_A_TNe
119 ;010 SETCHANNEL_A_TNE
120 ;011 SETCHANNEL_B_tne
121 ;012 SETCHANNEL_B_tnE
122 ;013 SETCHANNEL_B_tNe
123 ;014 SETCHANNEL_B_tNE
124 ;015 SETCHANNEL_B_Tne
125 ;016 SETCHANNEL_B_TnE
126 ;017 SETCHANNEL_B_TNe
127 ;018 SETCHANNEL_B_TNE
128 ;019 SETCHANNEL_C_tne
129 ;020 SETCHANNEL_C_tnE
130 ;021 SETCHANNEL_C_tNe
131 ;022 SETCHANNEL_C_tNE
132 ;023 SETCHANNEL_C_Tne
133 ;024 SETCHANNEL_C_TnE
134 ;025 SETCHANNEL_C_TNe
135 ;026 SETCHANNEL_C_TNE
136 ;
137 ;027 SETPITCH,PitchLo
138 ;
139 ;028 SETVOLUME+15
140 ;
141 ;044 PLAY+49
142 ;
143 ;094 END_A_OFF
144 ;095 END_B_OFF
145 ;096 END_AB_OFF
146 ;097 END_C_OFF
147 ;098 END_AC_OFF
148 ;099 END_BC_OFF
149 ;100 END_ABC_OFF
150 ;
151 ;101 JUMP,lo,hi
152 ;
153 ;102 ADJUSTVOLUME-15 to ADJUSTVOLUME+15
154 ;
155 ;133 LOOPONVOLUMERANGE,offset
156 ;
157 ;134 LOOPONCOUNTERRANGE,offset
158 ;
159 ;135 SETNOISE+31
160 ;
161 ;167 SETENV,lo,hi
162 ;
163 ;168 TRIGGER_SAWTOOTH
164 ;169 TRIGGER_TRIANGLE
165 ;170 TRIGGER_DESCEND
166 ;171 TRIGGER_ASCEND
167 ;
168 ;172 ADJUSTPITCH-15
169 ;
170 ;203 END_NORMAL
171 ;
172 ;204 SETCOUNTER+52
173
174 ;A SFX ID
175 KickSFX
176 .(
177 stx vector1+1
178 sty vector2+1
179 tax
180 ldy sfx_PrimaryIndex,x
181 lda sfx_ScriptAddressLo,x
182 sta sfx_AddressLo,y
183 lda sfx_ScriptAddressHi,x
184 sta sfx_AddressHi,y
185 ;Now reset current sfx for this index
186 lda #00
187 sta ay_PitchHi,y
188 sta sfx_Index,y
189 sta sfx_PlayPeriod,y
190 lda #1
191 sta sfx_Status,y
192 vector1 ldx #00
193 vector2 ldy #00
194 .)
195 rts
196
197
198
199 sfx_ScriptEngine
200 ;Are bees present on the screen?
201 ldx #2
202 .(
203 loop2 lda sfx_Status,x
204 beq skip1
205 ; nop
206 ; jmp loop2 ;???
207 lda sfx_PlayPeriod,x
208 beq skip2
209 dec sfx_PlayPeriod,x
210 jmp skip1
211 skip2 lda sfx_AddressLo,x
212 sta sfx
213 lda sfx_AddressHi,x
214 sta sfx+1
215 loop3 ldy sfx_Index,x
216 lda (sfx),y
217 iny
218 sty sfxTemp2
219 ldy #17
220 loop1 dey
221 cmp sfxValueThreshhold,y
222 bcc loop1
223 sbc sfxValueThreshhold,y
224 sta sfxTemp1
225
226 lda sfx_Index,x
227 adc sfxCodeBytes,y
228 sta sfx_Index,x
229
230 lda sfxCodeVectorLo,y
231 sta vector1+1
232 lda sfxCodeVectorHi,y
233 sta vector1+2
234
235 ldy sfxTemp2
236 lda sfxTemp1
237 sec
238 vector1 jsr $dead
239 bcs loop3
240 skip1 dex
241 bpl loop2
242 .)
243 SendAYBank
244 ;Send AY Bank
245 ldx #$0D
246 .(
247 loop1 lda ay_Bank,x
248 ldy ayVolumeFlag,x
249 beq skip2
250 ldy Option_Sound
251 beq skip2
252 dey
253 bne skip3
254 and #15
255 sbc #6
256 bcs skip2
257 skip3 lda #00
258 skip2 cmp ayr_Bank,x
259 beq skip1
260 sta ayr_Bank,x
261 ldy ay_RegisterID,x
262 sty VIA_PORTA
263 ldy #$FF
264 sty VIA_PCR
265 ldy #$DD
266 sty VIA_PCR
267 sta VIA_PORTA
268 lda #$FD
269 sta VIA_PCR
270 sty VIA_PCR
271 skip1 dex
272 bpl loop1
273 .)
274 rts
275
276 ay_Bank
277 ay_PitchLo .byt 0,0,0
278 ay_PitchHi .byt 0,0,0
279 ay_Noise .byt 0
280 ay_Status .byt 127
281 ay_Volume .byt 0,0,0
282 ay_EGPeriodLo .byt 0
283 ay_EGPeriodHi .byt 0
284 ay_Cycle .byt 0
285 ayr_Bank
286 ayr_PitchLo .byt 128,128,128
287 ayr_PitchHi .byt 128,128,128
288 ayr_Noise .byt 128
289 ayr_Status .byt 128
290 ayr_Volume .byt 128,128,128
291 ayr_EGPeriodLo .byt 128
292 ayr_EGPeriodHi .byt 128
293 ayr_Cycle .byt 128
294 ay_RegisterID
295 .byt 0,2,4 ;ayr_PitchLo
296 .byt 1,3,5 ;ayr_PitchHi
297 .byt 6 ;ayr_Noise
298 .byt 7 ;ayr_Status
299 .byt 8,9,10 ;ayr_Volume
300 .byt 11 ;ayr_EGPeriodLo
301 .byt 12 ;ayr_EGPeriodHi
302 .byt 13 ;ayr_Cycle
303
304
305 ;sfx_Status
306 ;0 Inactive
307 ;1 Active
308 sfx_Status
309 .dsb 3,0
310 ;sfx_PlayPeriod
311 ;0 Timed out
312 ;1-52 Playing
313 sfx_PlayPeriod
314 .dsb 3,0
315 sfx_ScriptAddressLo
316 .byt <Script_Killed ;00
317 .byt <Script_FireOrb ;01
318 .byt <Script_FireSword ;02
319 .byt <Script_FireHeart ;03
320 .byt <Script_Launcher ;04
321 .byt <Script_CollectKey ;05
322 .byt <Script_RainDrop ;06
323 .byt <Script_FreeFairy ;07
324 .byt <Script_Trampolene ;08
325 .byt <Script_Door ;09
326 .byt <Script_Footstep ;10
327 .byt <Script_Spider ;11
328 .byt <Script_Bees ;12
329 .byt <Script_Explosion ;13
330 .byt <Script_GameOver ;14
331 .byt <Script_LevelComplete ;15
332 .byt <Script_CollectUmbrella ;16
333 .byt <Script_CollectHoney ;17
334 .byt <Script_CollectBoots ;18
335 .byt <Script_Starfield ;19
336
337 sfx_ScriptAddressHi
338 .byt >Script_Killed ;00
339 .byt >Script_FireOrb ;01
340 .byt >Script_FireSword ;02
341 .byt >Script_FireHeart ;03
342 .byt >Script_Launcher ;04
343 .byt >Script_CollectKey ;05
344 .byt >Script_RainDrop ;06
345 .byt >Script_FreeFairy ;07
346 .byt >Script_Trampolene ;08
347 .byt >Script_Door ;09
348 .byt >Script_Footstep ;10
349 .byt >Script_Spider ;11
350 .byt >Script_Bees ;12
351 .byt >Script_Explosion ;13
352 .byt >Script_GameOver ;14
353 .byt >Script_LevelComplete ;15
354 .byt >Script_CollectUmbrella ;16
355 .byt >Script_CollectHoney ;17
356 .byt >Script_CollectBoots ;18
357 .byt >Script_Starfield ;19
358 ;A - Hero Fire
359 ;B - Pickup
360 ;C - NPC's
361 sfx_PrimaryIndex
362 .byt 0 ;00 Script_
363 .byt 0 ;01 Script_FireOrb
364 .byt 0 ;02 Script_
365 .byt 0 ;03 Script_
366 .byt 2 ;04 Script_Launcher
367 .byt 1 ;05 Script_CollectKey
368 .byt 1 ;06 Script_RainDrop
369 .byt 1 ;07 Script_FreeFairy
370 .byt 0 ;08 Script_Trampolene
371 .byt 1 ;09 Script_Door
372 .byt 0 ;10 Script_Footstep
373 .byt 2 ;11 Script_Spider
374 .byt 2 ;12 Script_Bees
375 .byt 2 ;13 Script_Explosion
376 .byt 0 ;14 Script_GameOver
377 .byt 0 ;15 Script_LevelComplete
378 .byt 1 ;16 Script_CollectUmbrella
379 .byt 1 ;17 Script_CollectHoney
380 .byt 1 ;18 Script_CollectBoots
381 .byt 0 ;19 Script_Starfield
382 sfx_AddressLo
383 .dsb 3,0
384 sfx_AddressHi
385 .dsb 3,0
386 sfx_Index
387 .dsb 3,0
388 sfx_Counter
389 .dsb 3,0
390
391 sfxValueThreshhold
392 .byt 0 ;00 SETCHANNEL_A etc.
393 .byt 3 ;01 SETCHANNEL_A_tne etc.
394 .byt 27 ;02 SETPITCH,PitchLo
395 .byt 28 ;03 SETVOLUME+15
396 .byt 44 ;04 PLAY+49
397 .byt 94 ;05 END_A_OFF etc.
398 .byt 101 ;06 JUMP,lo,hi
399 .byt 102 ;07 ADJUSTVOLUME-15 to ADJUSTVOLUME+15
400 .byt 133 ;08 LOOPONVOLUMERANGE,offset
401 .byt 134 ;09 LOOPONCOUNTERRANGE,offset
402 .byt 135 ;10 SETNOISE+31
403 .byt 167 ;11 SETENV,lo,hi
404 .byt 168 ;12 TRIGGER_SAWTOOTH etc.
405 .byt 172 ;13 ADJUSTPITCH-15
406 .byt 203 ;14 END_NORMAL
407 .byt 204 ;15 SETNOTE,Note
408 .byt 205 ;16 SETCOUNTER+51
409 sfxCodeBytes ;Like how many parameters?
410 .byt 0 ;SETCHANNEL_A etc.
411 .byt 0 ;SETCHANNEL_A_tne etc.
412 .byt 1 ;SETPITCH,PitchLo
413 .byt 0 ;SETVOLUME+15
414 .byt 0 ;PLAY+49
415 .byt 0 ;END_A_OFF etc.
416 .byt 2 ;JUMP,lo,hi
417 .byt 0 ;ADJUSTVOLUME-15 to ADJUSTVOLUME+15
418 .byt 1 ;LOOPONVOLUMERANGE,offset
419 .byt 1 ;LOOPONCOUNTERRANGE,offset
420 .byt 0 ;SETNOISE+31
421 .byt 2 ;SETENV,lo,hi
422 .byt 0 ;TRIGGER_SAWTOOTH etc.
423 .byt 0 ;ADJUSTPITCH-15
424 .byt 0 ;END_NORMAL
425 .byt 1 ;SETNOTE,Note
426 .byt 0 ;SETCOUNTER+52
427 sfxCodeVectorLo
428 .byt <sfxcom_SetChannel ;SETCHANNEL_A etc.
429 .byt <sfxcom_SetChannelFlags ;SETCHANNEL_A_tne etc.
430 .byt <sfxcom_SetPitch ;SETPITCH,PitchLo
431 .byt <sfxcom_SetVolume ;SETVOLUME+15
432 .byt <sfxcom_Play ;PLAY+49
433 .byt <sfxcom_End_ ;END_A_OFF etc.
434 .byt <sfxcom_Jump ;JUMP,lo,hi
435 .byt <sfxcom_AdjustVolume ;ADJUSTVOLUME-15 to ADJUSTVOLUME+15
436 .byt <sfxcom_LoopOnVolume ;LOOPONVOLUMERANGE,offset
437 .byt <sfxcom_LoopOnCounter ;LOOPONCOUNTERRANGE,offset
438 .byt <sfxcom_SetNoise ;SETNOISE+31
439 .byt <sfxcom_SetEnv ;SETENV,lo,hi
440 .byt <sfxcom_TriggerCycle ;TRIGGER_SAWTOOTH etc.
441 .byt <sfxcom_AdjustPitch ;ADJUSTPITCH-15
442 .byt <sfxcom_End ;END_NORMAL
443 .byt <sfxcom_SetNote ;SETNOTE,Note
444 .byt <sfxcom_SetCounter ;SETCOUNTER+52
445 sfxCodeVectorHi
446 .byt >sfxcom_SetChannel ;SETCHANNEL_A etc.
447 .byt >sfxcom_SetChannelFlags ;SETCHANNEL_A_tne etc.
448 .byt >sfxcom_SetPitch ;SETPITCH,PitchLo
449 .byt >sfxcom_SetVolume ;SETVOLUME+15
450 .byt >sfxcom_Play ;PLAY+49
451 .byt >sfxcom_End_ ;END_A_OFF etc.
452 .byt >sfxcom_Jump ;JUMP,lo,hi
453 .byt >sfxcom_AdjustVolume ;ADJUSTVOLUME-15 to ADJUSTVOLUME+15
454 .byt >sfxcom_LoopOnVolume ;LOOPONVOLUMERANGE,offset
455 .byt >sfxcom_LoopOnCounter ;LOOPONCOUNTERRANGE,offset
456 .byt >sfxcom_SetNoise ;SETNOISE+31
457 .byt >sfxcom_SetEnv ;SETENV,lo,hi
458 .byt >sfxcom_TriggerCycle ;TRIGGER_SAWTOOTH etc.
459 .byt >sfxcom_AdjustPitch ;ADJUSTPITCH-15
460 .byt >sfxcom_End ;END_NORMAL
461 .byt >sfxcom_SetNote ;SETNOTE,Note
462 .byt >sfxcom_SetCounter ;SETCOUNTER+52
463
464
465 ;000 SETCHANNEL_A
466 ;001 SETCHANNEL_B
467 ;002 SETCHANNEL_C
468 sfxcom_SetChannel ;SETCHANNEL_A etc.
469 sta sfx_CurrentChannel,x
470 rts
471
472 ;000 SETCHANNEL_A_tne
473 ;001 SETCHANNEL_A_tnE
474 ;002 SETCHANNEL_A_tNe
475 ;003 SETCHANNEL_A_tNE
476 ;004 SETCHANNEL_A_Tne
477 ;005 SETCHANNEL_A_TnE
478 ;006 SETCHANNEL_A_TNe
479 ;007 SETCHANNEL_A_TNE
480 ;008 SETCHANNEL_B_tne
481 ;009 SETCHANNEL_B_tnE
482 ;010 SETCHANNEL_B_tNe
483 ;011 SETCHANNEL_B_tNE
484 ;012 SETCHANNEL_B_Tne
485 ;013 SETCHANNEL_B_TnE
486 ;014 SETCHANNEL_B_TNe
487 ;015 SETCHANNEL_B_TNE
488 ;016 SETCHANNEL_C_tne
489 ;017 SETCHANNEL_C_tnE
490 ;018 SETCHANNEL_C_tNe
491 ;019 SETCHANNEL_C_tNE
492 ;020 SETCHANNEL_C_Tne
493 ;021 SETCHANNEL_C_TnE
494 ;022 SETCHANNEL_C_TNe
495 ;023 SETCHANNEL_C_TNE
496 sfxcom_SetChannelFlags ;SETCHANNEL_A_tne etc.
497 ;Set Current Channel
498 tay
499 lda StatusCode,y
500 .(
501 sta vector2+1
502 tya
503 and #1
504 asl
505 asl
506 asl
507 asl
508 sta vector1+1
509 ; pha
510 tya
511 lsr
512 lsr
513 lsr
514 sta sfx_CurrentChannel,x
515 tay
516 ; ;We must store here too so that if we overflow volume through rel steps we'll know its not EG flag
517 ; pla
518 ; sta ay_EnvelopeFlag,y
519 ;Write away Status Register
520 lda ay_Status
521 and StatusBitMask4Channel,y
522 vector2 ora #00
523 sta ay_Status
524 ;Set Envelope
525 lda ay_Volume,y
526 and #15
527 vector1 ora #00
528 .)
529 sta ay_Volume,y
530 sec
531 rts
532
533 StatusCode ;24
534 .byt %00001001,%00001001,%00000001,%00000001,%00001000,%00001000,%00000000,%00000000
535 .byt %00010010,%00010010,%00000010,%00000010,%00010000,%00010000,%00000000,%00000000
536 .byt %00100100,%00100100,%00000100,%00000100,%00100000,%00100000,%00000000,%00000000
537 StatusBitMask4Channel
538 .byt %11110110 ;A
539 .byt %11101101 ;B
540 .byt %11011011 ;C
541
542 ;027 SETPITCH,PitchLo
543 sfxcom_SetPitch ;SETPITCH,PitchLo
544 lda (sfx),y
545 cmp #RANDOM_HIGH
546 .(
547 bne WriteAsPitch
548 ;Randomise Pitch High
549 jsr GetRandomNumber
550 and #31
551 ; adc #10
552 WriteAsPitch
553 .)
554 ldy sfx_CurrentChannel,x
555 sta ay_PitchLo,y
556 sec
557 rts
558
559 sfxcom_SetNote
560 lda (sfx),y
561 cmp #RANDOM_HIGH
562 .(
563 bne WriteAsNote
564 jsr GetRandomNumber
565 and #127
566 WriteAsNote
567 .)
568 ;Split note into Semitone and Octave
569 ldy #255
570 sec
571 .(
572 loop1 iny
573 sbc #12
574 bcs loop1
575 adc #12
576
577 sty vector2+1
578 tay
579 lda BasePitchHi,y
580
581 sta vector1+1
582 lda BasePitchLo,y
583 vector2 ldy #00
584 beq skip1
585 loop2 lsr vector1+1
586 ror
587 dey
588 bne loop2
589 skip1 ldy sfx_CurrentChannel,x
590 sta ay_PitchLo,y
591 vector1 lda #00
592 .)
593 sta ay_PitchHi,y
594 sec
595 rts
596
597 BasePitchLo ;Base Note Pitches Lo
598 .byt $EE,$16,$4C
599 .byt $8E,$D8,$2E
600 .byt $8E,$F6,$66
601 .byt $E0,$60,$E8
602 BasePitchHi ;Base Note Pitches Hi
603 .byt $0E,$0E,$0D
604 .byt $0C,$0B,$0B
605 .byt $0A,$09,$09
606 .byt $08,$08,$07
607
608
609
610
611
612
613 ;028 SETVOLUME+15
614 sfxcom_SetVolume ;SETVOLUME+15
615 ldy sfx_CurrentChannel,x
616 sta ay_Volume,y
617 rts
618
619 ;044 PLAY+49
620 sfxcom_Play ;PLAY+49
621 cmp #00
622 .(
623 bne skip1
624 jsr GetRandomNumber
625 and #7
626 adc #2
627 skip1 sbc #1
628 sta sfx_PlayPeriod,x
629 .)
630 clc
631 rts
632
633
634 ;094 001 END_A_OFF
635 ;095 010 END_B_OFF
636 ;096 011 END_AB_OFF
637 ;097 100 END_C_OFF
638 ;098 101 END_AC_OFF
639 ;099 110 END_BC_OFF
640 ;100 111 END_ABC_OFF
641 ;B0==A
642 ;B1==B
643 ;B2==C
644 sfxcom_End_ ;END_A_OFF etc.
645 tay
646 iny
647 tya
648 and #1
649 .(
650 beq skip1
651 lda #00
652 sta ay_Volume
653 skip1 tya
654 and #2
655 beq skip2
656 lda #00
657 sta ay_Volume+1
658 skip2 tya
659 and #4
660 beq skip3
661 lda #00
662 sta ay_Volume+2
663 skip3 sta sfx_Status,x
664 .)
665 clc
666 rts
667
668 ;101 JUMP,lo,hi
669 sfxcom_Jump ;JUMP,lo,hi
670 lda #00
671 sta sfx_Index,x
672 lda (sfx),y
673 sta sfx_AddressLo,x
674 pha
675 iny
676 lda (sfx),y
677 sta sfx_AddressHi,x
678 sta sfx+1
679 pla
680 sta sfx
681 rts
682
683 ;102 ADJUSTVOLUME-15 to ADJUSTVOLUME+15
684 sfxcom_AdjustVolume ;ADJUSTVOLUME-15 to ADJUSTVOLUME+15
685 tay
686 lda TwosCompliment32,y
687 .(
688 sta vector1+1
689 ldy sfx_CurrentChannel,x
690 lda ay_Volume,y
691 clc
692 vector1 adc #00
693 .)
694 sta ay_Volume,y
695 sec
696 rts
697 TwosCompliment32
698 .byt 241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
699 .byt 0
700 .byt 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
701
702 ;133 LOOPONVOLUMERANGE,offset ;Cannot Loop with EG flag set!
703 sfxcom_LoopOnVolume ;LOOPONVOLUMERANGE,offset
704 lda (sfx),y
705 sta sfxTemp1
706 ldy sfx_CurrentChannel,x
707 lda ay_Volume,y
708 cmp #16
709
710 bcs AbortLoop
711 PerformLoop
712 lda sfxTemp1
713 sta sfx_Index,x
714 sec
715 rts
716 AbortLoop clc
717 rts
718
719 ;134 LOOPONCOUNTERRANGE,offset
720 sfxcom_LoopOnCounter ;LOOPONCOUNTERRANGE,offset
721 lda (sfx),y
722 sta sfxTemp1
723 lda sfx_Counter,x
724 beq AbortLoop
725 dec sfx_Counter,x
726 jmp PerformLoop
727
728 ;135 SETNOISE+31
729 sfxcom_SetNoise ;SETNOISE+31
730 sta ay_Noise
731 rts
732 ;167 SETENV,lo,hi
733 sfxcom_SetEnv ;SETENV,lo,hi
734 lda (sfx),y
735 sta ay_EGPeriodLo
736 iny
737 lda (sfx),y
738 sta ay_EGPeriodHi
739 rts
740
741 ;168 TRIGGER_SAWTOOTH
742 ;169 TRIGGER_TRIANGLE
743 ;170 TRIGGER_DESCEND
744 ;171 TRIGGER_ASCEND
745 sfxcom_TriggerCycle ;TRIGGER_SAWTOOTH etc.
746 tay
747 lda EGWaveCode,y
748 sta ay_Cycle
749 ;And ensure this does trigger cycle (by setting reference wild)
750 lda #128
751 sta ayr_Cycle
752 rts
753 EGWaveCode
754 .byt 8 ;168 TRIGGER_SAWTOOTH
755 .byt 10 ;169 TRIGGER_TRIANGLE
756 .byt 0 ;170 TRIGGER_DESCEND
757 .byt 4 ;171 TRIGGER_ASCEND
758
759 ;172 ADJUSTPITCH-15
760 sfxcom_AdjustPitch ;ADJUSTPITCH-15
761 tay
762 .(
763 bne skip1
764 ;If adjust 0 then random adjust -32 to +31 but on 12 bit pitch
765 jsr GetRandomNumber
766 and #63
767 sec
768 sbc #32
769 bmi Negative12BitPitchStep
770 jmp Positive12BitPitchStep
771 skip1 lda TwosCompliment32,y
772 skip2 sta vector1+1
773 ldy sfx_CurrentChannel,x
774 lda ay_PitchLo,y
775 clc
776 vector1 adc #00
777 sta ay_PitchLo,y
778 sec
779 rts
780 Negative12BitPitchStep
781 sta vector2+1
782 ldy sfx_CurrentChannel,x
783 lda ay_PitchLo,y
784 vector2 sbc #00
785 sta ay_PitchLo,y
786 lda ay_PitchHi,y
787 sbc #00
788 jmp skip3
789 Positive12BitPitchStep
790 clc
791 ldy sfx_CurrentChannel,x
792 adc ay_PitchLo,y
793 sta ay_PitchLo,y
794 lda ay_PitchHi,y
795 adc #00
796 skip3 and #15
797 .)
798 sta ay_PitchHi,y
799 sec
800 rts
801
802 ;203 END_NORMAL
803 sfxcom_End
804 lda #00
805 sta sfx_Status,x
806 rts
807
808 ;204 SETCOUNTER+51
809 sfxcom_SetCounter ;SETCOUNTER+52
810 cmp #00
811 .(
812 bne skip1
813 jsr GetRandomNumber
814 and #7
815 clc
816 adc #1
817 skip1 sta sfx_Counter,x
818 .)
819 sec
820 rts
821

  ViewVC Help
Powered by ViewVC 1.1.26