Skip to content

Commit

Permalink
Merge pull request #591 from paulscottrobson/sfx
Browse files Browse the repository at this point in the history
Simple SFX improvements
  • Loading branch information
paulscottrobson authored Aug 12, 2024
2 parents a96373b + 5e475bc commit a71e04e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion basic/test.bsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
noise 1,210,100
sfx 0,7
end

proc snd(ch,fq,ms,sl,ty,v)
Expand Down
12 changes: 3 additions & 9 deletions firmware/common/scripts/sfx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@ def __init__(self):
def translate(self,sfx):
if sfx[0].startswith("EXPL"):
tSample = 1
xlat = []
for i in range(0,int(sfx[0][4:]) // (tSample+1)):
xlat.append(random.randint(0,500)+200)
xlat.append(tSample)
xlat = [ 0xFFFE,int(sfx[0][4:]) ]

elif sfx[0].startswith("LAS"):
tSample = 1
xlat = []
length = int(sfx[0][3:]) // (tSample+1)
for i in range(0,length):
xlat.append(600-400*i // length)
xlat.append(tSample)
xlat = [ 0xFFFD, int(sfx[0][3:])]

else:
sfx = sfx[1:]
xlat = []
Expand Down
15 changes: 13 additions & 2 deletions firmware/common/sources/interface/sfxmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ uint8_t SFXPlay(int channelID,int effect) {
const uint16_t *notes = sfxData[effect]; // List to queue
while (*notes != 0xFFFF) { // Queue them
SOUND_UPDATE u;
u.frequency = notes[0];u.timeCS = notes[1];u.slide = 0;
SNDPlay(channelID,&u);
u.timeCS = notes[1];u.slide = 0;u.volume = 100;u.type = 0;
switch(notes[0]) {
case 0xFFFE:
u.frequency = 100;u.type = 1;
break;
case 0xFFFD:
u.frequency = 200;u.type = 1;u.slide = 40;
break;
default:
u.frequency = notes[0];
break;
}
SNDPlay(channelID,&u);
notes += 2;
}
return 0;
Expand Down

0 comments on commit a71e04e

Please sign in to comment.