-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSounds.ras
116 lines (96 loc) · 2.29 KB
/
Sounds.ras
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// set up Vic Sounds
procedure StopSounds();
procedure SetupSound();
var
begin
StopSounds();
poke(^@VICvolume, 0, 15);
end;
procedure PlayNote(sindex: byte, note: byte);
begin
poke(^@VICsnd1, sindex, note);
end;
procedure StopSounds();
var
i: byte;
begin
for i:= 0 to 4 do begin
vsnd[i] := 0;
vsndTime[i] := 0;
psnd[i] := #noSound;
end;
poke(^@VICsnd1, 0, 0);
poke(^@VICsnd2, 0, 0);
poke(^@VICsnd3, 0, 0);
poke(^@VICsnd4, 0, 0);
end;
procedure SndTime(s:byte);
begin
// decrease time
if (vsndTime[s] > 0) then vsndTime[s] := vsndTime[s] - 1;
// after decreasing time, if now = 0 then go to next command
if (vsndTime[s] = 0) then psnd[s] := psnd[s] + 2; // goto next command
end;
// Play active sounds on voice 1
procedure UpdateSoundInternal(s : byte);
var
duration: byte;
begin
soundPointer := Int2Ptr(psnd[s]);
// idle
if (soundPointer[0] = @VSA_IDLE) then
begin
if (vsnd[s] <> 0) then
begin
vsnd[s] := 0;
PlayNote(s,0);
//poke(tempPointer[0], 0, 0);
end;
return();
end;
// play note
if (soundPointer[0] = @VSA_NOTE or soundPointer[0] = @VSA_PAUSE) then
begin
//addbreakpoint(); nop(3);
// if time = 0 at start, then this is a new note command
if (vsndTime[s] = 0) then
begin
vsndTime[s] := soundPointer[1]; // get duration
if soundPointer[0] = @VSA_NOTE then begin
PlayNote(s, vsnd[s]);
end;
if soundPointer[0] = @VSA_PAUSE then begin
PlayNote(s,0);
end;
end;
end;
// increment
if (soundPointer[0] & @VSA_INC = @VSA_INC) then
begin
duration := soundPointer[0];
duration := duration - @VSA_INC;
// if time = 0 at start, then this is a new note command
if (vsndTime[s] = 0) then vsndTime[s] := soundPointer[ 1 ]; // get duration
vsnd[s] := vsnd[s] + duration;
PlayNote(s, vsnd[s]);
end;
// decrement
if (soundPointer[0] & @VSA_DEC = @VSA_DEC) then
begin
duration := soundPointer[0];
duration := duration - @VSA_DEC;
if (vsndTime[s] = 0) then vsndTime[s] := soundPointer[1]; // get duration
vsnd[s] := vsnd[s] - duration;
PlayNote(s, vsnd[s]);
end;
SndTime(s);
end;
// ----------------------------------------------------------------------
// Play active sounds
procedure UpdateSound();
begin
UpdateSoundInternal(0);
UpdateSoundInternal(1);
UpdateSoundInternal(2);
UpdateSoundInternal(3);
end;