Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Hive/c/sound
Arcade/!Hive/c/sound
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features |
Filename: | Arcade/!Hive/c/sound |
Read OK: | ✔ |
File size: | 032A bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
#include <string.h> #include "DeskLib:h.SWI" #include "Popcorn:h.Popcorn" #define SWI_QTM_Stereo 0x47E4D #define SWI_QTM_PlayRawSample 0x47E57 #define SWI_QTM_SoundControl 0x47E58 int next_channel = 1; void init_sound(void) { SWI(3, 0, SWI_QTM_SoundControl, 4, 0, -1); SWI(2, 0, SWI_QTM_Stereo, 0, 2); } void kill_sound(void) { int c; for (c=0; c!=5; c++) SWI(2, 0, SWI_QTM_PlayRawSample, c, 0); SWI(3, 0, SWI_QTM_SoundControl, 0, 0, 0); } void make_sound(char *sound_res) { int c=0; while (c != resource_free) { if (strcmp(resource[c]->file, sound_res) == 0) { SWI(7, 0, SWI_QTM_PlayRawSample, next_channel, resource[c]->addr, resource[c]->size, 0, 0, 18, 64); next_channel++; if (next_channel == 5) next_channel = 1; } c++; } }
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 6e 67 |#include <string| 00000010 2e 68 3e 0a 0a 23 69 6e 63 6c 75 64 65 20 22 44 |.h>..#include "D| 00000020 65 73 6b 4c 69 62 3a 68 2e 53 57 49 22 0a 0a 23 |eskLib:h.SWI"..#| 00000030 69 6e 63 6c 75 64 65 20 22 50 6f 70 63 6f 72 6e |include "Popcorn| 00000040 3a 68 2e 50 6f 70 63 6f 72 6e 22 0a 0a 23 64 65 |:h.Popcorn"..#de| 00000050 66 69 6e 65 20 53 57 49 5f 51 54 4d 5f 53 74 65 |fine SWI_QTM_Ste| 00000060 72 65 6f 20 20 20 20 20 20 20 20 30 78 34 37 45 |reo 0x47E| 00000070 34 44 0a 23 64 65 66 69 6e 65 20 53 57 49 5f 51 |4D.#define SWI_Q| 00000080 54 4d 5f 50 6c 61 79 52 61 77 53 61 6d 70 6c 65 |TM_PlayRawSample| 00000090 20 30 78 34 37 45 35 37 0a 23 64 65 66 69 6e 65 | 0x47E57.#define| 000000a0 20 53 57 49 5f 51 54 4d 5f 53 6f 75 6e 64 43 6f | SWI_QTM_SoundCo| 000000b0 6e 74 72 6f 6c 20 20 30 78 34 37 45 35 38 0a 0a |ntrol 0x47E58..| 000000c0 69 6e 74 20 6e 65 78 74 5f 63 68 61 6e 6e 65 6c |int next_channel| 000000d0 20 3d 20 31 3b 0a 0a 76 6f 69 64 20 69 6e 69 74 | = 1;..void init| 000000e0 5f 73 6f 75 6e 64 28 76 6f 69 64 29 0a 7b 0a 20 |_sound(void).{. | 000000f0 20 53 57 49 28 33 2c 20 30 2c 20 53 57 49 5f 51 | SWI(3, 0, SWI_Q| 00000100 54 4d 5f 53 6f 75 6e 64 43 6f 6e 74 72 6f 6c 2c |TM_SoundControl,| 00000110 20 34 2c 20 30 2c 20 2d 31 29 3b 0a 20 20 53 57 | 4, 0, -1);. SW| 00000120 49 28 32 2c 20 30 2c 20 53 57 49 5f 51 54 4d 5f |I(2, 0, SWI_QTM_| 00000130 53 74 65 72 65 6f 2c 20 30 2c 20 32 29 3b 0a 7d |Stereo, 0, 2);.}| 00000140 0a 0a 76 6f 69 64 20 6b 69 6c 6c 5f 73 6f 75 6e |..void kill_soun| 00000150 64 28 76 6f 69 64 29 0a 7b 0a 20 20 69 6e 74 20 |d(void).{. int | 00000160 63 3b 0a 20 20 66 6f 72 20 28 63 3d 30 3b 20 63 |c;. for (c=0; c| 00000170 21 3d 35 3b 20 63 2b 2b 29 0a 20 20 20 20 53 57 |!=5; c++). SW| 00000180 49 28 32 2c 20 30 2c 20 53 57 49 5f 51 54 4d 5f |I(2, 0, SWI_QTM_| 00000190 50 6c 61 79 52 61 77 53 61 6d 70 6c 65 2c 20 63 |PlayRawSample, c| 000001a0 2c 20 30 29 3b 0a 20 20 53 57 49 28 33 2c 20 30 |, 0);. SWI(3, 0| 000001b0 2c 20 53 57 49 5f 51 54 4d 5f 53 6f 75 6e 64 43 |, SWI_QTM_SoundC| 000001c0 6f 6e 74 72 6f 6c 2c 20 30 2c 20 30 2c 20 30 29 |ontrol, 0, 0, 0)| 000001d0 3b 0a 7d 0a 0a 76 6f 69 64 20 6d 61 6b 65 5f 73 |;.}..void make_s| 000001e0 6f 75 6e 64 28 63 68 61 72 20 2a 73 6f 75 6e 64 |ound(char *sound| 000001f0 5f 72 65 73 29 0a 7b 0a 20 20 69 6e 74 20 63 3d |_res).{. int c=| 00000200 30 3b 0a 0a 20 20 77 68 69 6c 65 20 28 63 20 21 |0;.. while (c !| 00000210 3d 20 72 65 73 6f 75 72 63 65 5f 66 72 65 65 29 |= resource_free)| 00000220 0a 20 20 7b 0a 20 20 20 20 69 66 20 28 73 74 72 |. {. if (str| 00000230 63 6d 70 28 72 65 73 6f 75 72 63 65 5b 63 5d 2d |cmp(resource[c]-| 00000240 3e 66 69 6c 65 2c 20 73 6f 75 6e 64 5f 72 65 73 |>file, sound_res| 00000250 29 20 3d 3d 20 30 29 0a 20 20 20 20 7b 0a 20 20 |) == 0). {. | 00000260 20 20 20 20 53 57 49 28 37 2c 20 30 2c 20 53 57 | SWI(7, 0, SW| 00000270 49 5f 51 54 4d 5f 50 6c 61 79 52 61 77 53 61 6d |I_QTM_PlayRawSam| 00000280 70 6c 65 2c 20 6e 65 78 74 5f 63 68 61 6e 6e 65 |ple, next_channe| 00000290 6c 2c 20 72 65 73 6f 75 72 63 65 5b 63 5d 2d 3e |l, resource[c]->| 000002a0 61 64 64 72 2c 20 72 65 73 6f 75 72 63 65 5b 63 |addr, resource[c| 000002b0 5d 2d 3e 73 69 7a 65 2c 20 30 2c 20 30 2c 20 31 |]->size, 0, 0, 1| 000002c0 38 2c 20 36 34 29 3b 0a 20 20 20 20 20 20 6e 65 |8, 64);. ne| 000002d0 78 74 5f 63 68 61 6e 6e 65 6c 2b 2b 3b 0a 20 20 |xt_channel++;. | 000002e0 20 20 20 20 69 66 20 28 6e 65 78 74 5f 63 68 61 | if (next_cha| 000002f0 6e 6e 65 6c 20 3d 3d 20 35 29 0a 20 20 20 20 20 |nnel == 5). | 00000300 20 20 20 6e 65 78 74 5f 63 68 61 6e 6e 65 6c 20 | next_channel | 00000310 3d 20 31 3b 0a 20 20 20 20 7d 0a 20 20 20 20 63 |= 1;. }. c| 00000320 2b 2b 3b 0a 20 20 7d 0a 7d 0a |++;. }.}.| 0000032a