Posted By
 Luca on 2025-03-29 11:16:43
 | Re: Sound / Music
Oh well yes, that's like music: any sfx has its own little table of values, which get called every X times per frame and read by a tiny driver code which assigns the useful values to the right addresses ($FF0E/0F/10/11/12). In BASIC, it would be something like:
100 VOL8 110 READ A,B:IF B=-1 THEN END 120 SOUND2,A,B:GOTO 110 130 DATA 700,1,800,1,900,1,950,1,965,1,967,1 140 DATA 960,2,878,2,700,3,440,3,200,4,,-1
Alternative sfx player can be envelope-based: the player considers a specified formula which uses a starting value only, or e.g. a starting value and a coefficient. In BASIC, it would be something like:
100 VOL8:TT=0 110 INPUT "STARTING VALUE (0-1023)";VA 120 INPUT "COEFFICIENT (0-63)";CO 130 SOUND1,(VA*CO/(256-VA))AND255*4,1 140 SOUND2,ABS(VA-TT*CO),1 150 TT=TT+1:IF TT=21 THEN STOP 160 GOTO 130 |