Path: utzoo!attcan!uunet!aplcen!wb3ffv!ka3ovk!irscscm!mlake From: mlake@irscscm.UUCP (Marshall Lake) Newsgroups: comp.sys.atari.st.tech Subject: Using Timer A to replay a sample Message-ID: <1990Sep24.122920.15704@irscscm.UUCP> Date: 24 Sep 90 12:29:20 GMT Reply-To: mlake@irscscm.UUCP (Marshall Lake) Organization: Internal Revenue Service, Washington, DC Lines: 100 I have a programming problem and I'm hoping someone here can help me. I am attempting to play back a sample via timer A while allowing other things to go on as it plays. When the program attempts to start the actual playback it blows, sometimes displaying 4 bombs and sometimes 6. I have also tried to place the interrupt code into the main flow of the program to see what would happen. The bombs don't occur but nothing is emitted by the sound chip either. What am I doing wrong? The code follows: #include #include long *buff_cnt, *buff_end, *sound_chip = 0xff8800, *gi_write = 0xff8802; char *trumpet_sound; int snd_value, snd_out[1025] = { }; do_snd () { if (buff_cnt > buff_end) return; snd_value = (*buff_cnt + 128) * 8;*/ *sound_chip = snd_out[snd_value]; *sound_chip = snd_out[snd_value + 4]; buff_cnt++; } play (addr) char *addr; { buff_cnt = addr; buff_end = addr + 58965L; } set_snd_chip () { *sound_chip = 0; *gi_write = 0; *sound_chip = 1; *gi_write = 0; *sound_chip = 2; *gi_write = 0; *sound_chip = 3; *gi_write = 0; *sound_chip = 4; *gi_write = 0; *sound_chip = 5; *gi_write = 0; *sound_chip = 7; *gi_write = 255; *sound_chip = 8; *gi_write = 0; *sound_chip = 9; *gi_write = 0; *sound_chip = 10; *gi_write = 0; } main () { char *save_ssp; int counter, read_handle; if ((trumpet_sound = (char *) Malloc (58 * 1024L)) == 0) { printf ("\n\n NOT ENOUGH MEMORY \n\n"); exit (); } if ((read_handle = Fopen ("trumpet.spl", 0)) < 0) { printf ("\n Cannot find trumpet.spl \n"); exit (); } Fread (read_handle, 58965L, trumpet_sound); Fclose (read_handle); buff_cnt = 1L; buff_end = 0L; Supexec (&set_snd_chip); save_ssp = Super (0L); Xbtimer (0, 7, 0, &do_snd); play (trumpet_sound); counter = 0; while (1) { if (counter == 30000) break; printf ("counter = %d\n", counter++); } Xbtimer (0, 0, 0, &do_snd); Super (save_ssp); } -- Marshall Lake mlake@irscscm.UUCP ...!uunet!media!ka3ovk!irscscm!mlake