home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Emulatoren / UAE061.LZH / uae-0.6.1 / os.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  14.9 KB  |  713 lines

  1.  /* 
  2.   * UAE - The Un*x Amiga Emulator
  3.   * 
  4.   * OS specific functions
  5.   * 
  6.   * (c) 1995 Bernd Schmidt
  7.   * (c) 1996 Marcus Sundberg
  8.   */
  9.  
  10. #include "sysconfig.h"
  11. #include "sysdeps.h"
  12.  
  13. #include "config.h"
  14. #include "options.h"
  15. #include "memory.h"
  16. #include "custom.h"
  17. #include "os.h"
  18.  
  19. #ifdef HAVE_LINUX_JOYSTICK_H
  20.  
  21. static int js0;
  22. static int joystickpresent = 0;
  23.  
  24. struct JS_DATA_TYPE jscal;
  25.  
  26. void read_joystick(UWORD *dir, int *button)
  27. {
  28.     static int minx = MAXINT, maxx = MININT,
  29.                miny = MAXINT, maxy = MININT;
  30.     int left = 0, right = 0, top = 0, bot = 0;
  31.     struct JS_DATA_TYPE buffer;
  32.     int len;
  33.     
  34.     *dir = 0;
  35.     *button = 0;
  36.     if (!joystickpresent)
  37.         return;
  38.     
  39.     len = read(js0, &buffer, sizeof(buffer));
  40.     if (len != sizeof(buffer)) 
  41.         return;
  42.     
  43.     if (buffer.x < minx) minx = buffer.x;
  44.     if (buffer.y < miny) miny = buffer.y;
  45.     if (buffer.x > maxx) maxx = buffer.x;
  46.     if (buffer.y > maxy) maxy = buffer.y;
  47.     
  48.     if (buffer.x < (minx + (maxx-minx)/3))
  49.         left = 1;
  50.     else if (buffer.x > (minx + 2*(maxx-minx)/3))
  51.         right = 1;
  52.  
  53.     if (buffer.y < (miny + (maxy-miny)/3))
  54.         top = 1;
  55.     else if (buffer.y > (miny + 2*(maxy-miny)/3))
  56.         bot = 1;
  57.         
  58.     if (left) top = !top;
  59.     if (right) bot = !bot;
  60.     *dir = bot | (right << 1) | (top << 8) | (left << 9);
  61.     *button = (buffer.buttons & 3) != 0;
  62. }
  63.  
  64. void init_joystick(void)
  65. {
  66.     js0 = open("/dev/js0", O_RDONLY);
  67.     if (js0 < 0)
  68.         return;
  69.     joystickpresent = 1;
  70. }
  71.  
  72. void close_joystick(void)
  73. {
  74.     if (joystickpresent)
  75.     close(js0);
  76. }
  77.  
  78. #elif defined(__DOS__)
  79.  
  80. static int joystickpresent = 0;
  81.  
  82. void read_joystick(UWORD *dir, int *button)
  83. {
  84.     static int minx = MAXINT, maxx = MININT,
  85.            miny = MAXINT, maxy = MININT;
  86.     int left = 0, right = 0, top = 0, bot = 0;
  87.     char JoyPort;
  88.     int laps, JoyX, JoyY;
  89.  
  90.     *dir = 0;
  91.     *button = 0;
  92.     if (!joystickpresent)
  93.     return;
  94.  
  95.     JoyX = 0;
  96.     JoyY = 0;
  97.     laps = 0;
  98.     __asm__ __volatile__("cli");
  99.     outportb(0x201, 0xff);
  100.     do {
  101.     JoyPort = inportb(0x201);
  102.     JoyX = JoyX + (JoyPort & 1);
  103.     JoyY = JoyY + ((JoyPort & 2) >> 1);
  104.     laps++;
  105.     } while(((JoyPort & 3) != 0) && (laps != 65535));
  106.     __asm__ __volatile__("sti");
  107.  
  108.     if (JoyX < minx) minx = JoyX;
  109.     if (JoyY < miny) miny = JoyY;
  110.     if (JoyX > maxx) maxx = JoyX;
  111.     if (JoyY > maxy) maxy = JoyY;
  112.  
  113.     if (JoyX < (minx + (maxx-minx)/3))
  114.     left = 1;
  115.     else if (JoyX > (minx + 2*(maxx-minx)/3))
  116.     right = 1;
  117.  
  118.     if (JoyY < (miny + (maxy-miny)/3))
  119.     top = 1;
  120.     else if (JoyY > (miny + 2*(maxy-miny)/3))
  121.     bot = 1;
  122.  
  123.     if (left) top = !top;
  124.     if (right) bot = !bot;
  125.     *dir = bot | (right << 1) | (top << 8) | (left << 9);
  126.     *button = ((~JoyPort) & 48) != 0;
  127. }
  128.  
  129. void init_joystick(void)
  130. {
  131.     int laps = 0;
  132.     char JoyPort;
  133.     __asm__ __volatile__("cli");
  134.     outportb(0x201, 0xff);
  135.     do {
  136.     JoyPort = inportb(0x201);
  137.     laps++;
  138.     } while(((JoyPort & 3) != 0) && (laps != 65535));
  139.     __asm__ __volatile__("sti");
  140.     if (laps != 65535)
  141.     joystickpresent = 1;
  142. }
  143.  
  144. void close_joystick(void)
  145. {
  146. }
  147.  
  148. #elif defined(AMIGA)
  149.  
  150. #define EXEC_TYPES_H
  151. typedef CPTR APTR;
  152.  
  153. #include <hardware/custom.h>
  154. #include <hardware/cia.h>
  155.  
  156. #define CIAAPRA 0xBFE001 
  157. #define CUSTOM  0xDFF000
  158.  
  159. static struct Custom *custom= (struct Custom*) CUSTOM;
  160. static struct CIA *cia = (struct CIA *) CIAAPRA;
  161.  
  162. void read_joystick(UWORD *dir, int *button)
  163. {
  164.     int bot, right, top, left, joy,fire;
  165.     
  166.     joy   = custom->joy1dat;
  167.     fire  = !( cia->ciapra & 0x0080 ) ? 1 : 0;
  168.  
  169.     right = (joy & 0x0002) ? 1 : 0;
  170.     left  = (joy & 0x0200) ? 1 : 0;
  171.     bot   = (joy & 0x0001) ? 1 : 0;
  172.     top   = (joy & 0x0100) ? 1 : 0;
  173.     
  174.     *button = fire;
  175.     *dir = bot | (right << 1) | (top << 8) | (left << 9);
  176. }
  177.  
  178. void init_joystick(void)
  179. {
  180. }
  181.  
  182. void close_joystick(void)
  183. {
  184. }
  185.  
  186. #else
  187. void read_joystick(UWORD *dir, int *button)
  188. {
  189.     *dir = 0;
  190.     *button = 0;
  191. }
  192.  
  193. void init_joystick(void)
  194. {
  195. }
  196.  
  197. void close_joystick(void)
  198. {
  199. }
  200.  
  201. #endif
  202.  
  203. CPTR audlc[4], audpt[4];
  204. UWORD audvol[4], audper[4], audlen[4], audwlen[4];
  205. int audwper[4];
  206. UWORD auddat[4];
  207. int audsnum[4];
  208.  
  209. /* Audio states. This is not an exact representation of the Audio State Machine
  210.  * (HRM p. 166), but a simplification. To be honest, I don't completely
  211.  * understand that picture yet.
  212.  */
  213. int audst[4];
  214.  
  215. int sound_table[256][64];
  216.  
  217. static void init_sound_table16(void)
  218. {
  219.     int i,j;
  220.     
  221.     for (i = 0; i < 256; i++)
  222.     for (j = 0; j < 64; j++)
  223.         sound_table[i][j] = j * (BYTE)i;
  224. }
  225.  
  226. static void init_sound_table8(void)
  227. {
  228.     int i,j;
  229.     
  230.     for (i = 0; i < 256; i++)
  231.     for (j = 0; j < 64; j++)
  232.         sound_table[i][j] = (j * (BYTE)i) / 256;
  233. }
  234.  
  235. #ifdef LINUX_SOUND
  236.  
  237. #include <sys/ioctl.h>
  238. #include <sys/soundcard.h>
  239.  
  240. static const int n_frames = 10;
  241.  
  242. /* The buffer is too large... */
  243. static UWORD buffer[44100], *bufpt;
  244. static UBYTE snddata[4];
  245.  
  246. static int frames = 0;
  247. static int smplcnt = 0;
  248. static int dsprate, dspbits, dspomit = 0;
  249. static int sndbufsize;
  250.  
  251. static int sfd;
  252. static int have_sound;
  253.  
  254. int init_sound (void)
  255. {
  256.     int tmp;
  257.     int rate;
  258.     
  259.     unsigned long formats;
  260.     
  261.     sfd = open ("/dev/dsp", O_WRONLY);
  262.     have_sound = !(sfd < 0);
  263.     if (!have_sound) {
  264.     return 0;
  265.     }
  266.     
  267.     ioctl (sfd, SNDCTL_DSP_GETFMTS, &formats);
  268.  
  269.     tmp = 0x0004000D;
  270.     ioctl (sfd, SNDCTL_DSP_SETFRAGMENT, &tmp);
  271.     ioctl (sfd, SNDCTL_DSP_GETBLKSIZE, &sndbufsize);
  272. #ifndef LINUX_SOUND_SLOW_MACHINE
  273.     dspbits = 16;
  274.     ioctl(sfd, SNDCTL_DSP_SAMPLESIZE, &dspbits);
  275.     ioctl(sfd, SOUND_PCM_READ_BITS, &dspbits);
  276.     if (dspbits != 16)
  277. #endif
  278.     {
  279.     dspbits = 8;
  280.     ioctl(sfd, SNDCTL_DSP_SAMPLESIZE, &dspbits);
  281.     ioctl(sfd, SOUND_PCM_READ_BITS, &dspbits);
  282.     if (dspbits != 8)
  283.         return 0;
  284.     }
  285.  
  286.     tmp = 0;
  287.     ioctl(sfd, SNDCTL_DSP_STEREO, &tmp);
  288.     
  289. #ifndef LINUX_SOUND_SLOW_MACHINE
  290.     dsprate = 0;
  291.     rate = 44100;
  292.     ioctl(sfd, SNDCTL_DSP_SPEED, &rate);
  293.     ioctl(sfd, SOUND_PCM_READ_RATE, &rate);
  294.     if (rate < 43000 || rate > 45000) 
  295. #endif
  296.     {
  297.     dsprate = 1;
  298.     rate = 22050;
  299.     ioctl(sfd, SNDCTL_DSP_SPEED, &rate);
  300.     ioctl(sfd, SOUND_PCM_READ_RATE, &rate);
  301.     /* Some soundcards return 22222 here. */
  302.     if (rate < 21000 || rate > 23000)
  303.         return 0;
  304.     }
  305.     if (dspbits == 16) {
  306.     /* Will this break horribly on Linux/Alpha? Possible... */
  307.     if (!(formats & AFMT_S16_LE))
  308.         return 0;
  309.     init_sound_table16 ();
  310.     } else {
  311.     if (!(formats & AFMT_U8))
  312.         return 0;
  313.     init_sound_table8 ();
  314.     }
  315.     printf ("Sound driver found and configured for %d bits at %d Hz, buffer is %d bytes\n",
  316.         dspbits, rate, sndbufsize);
  317.     audst[0] = audst[1] = audst[2] = audst[3] = 0;
  318.     bufpt = buffer;
  319.     frames = n_frames;
  320.     smplcnt = 0;
  321.     return 1;
  322. }
  323.  
  324. static void channel_reload (int c)
  325. {
  326.     audst[c] = 1;
  327.     audpt[c] = audlc[c];
  328.     audwper[c] = 0;
  329.     audwlen[c] = audlen[c];
  330.     audsnum[c] = 1;    
  331. }
  332.  
  333. void do_sound (void)
  334. {
  335.     smplcnt -= 227;
  336.     while (smplcnt < 0) {
  337.     int i;
  338.     smplcnt += 80;
  339.     dspomit ^= dsprate;
  340.     
  341.     for(i = 0; i < 4; i++) {
  342.         if (dmaen (1<<i)) {
  343.         if (audst[i] == 0) {        
  344.             /* DMA was turned on for this channel */
  345.             channel_reload (i);
  346.             continue;
  347.         }
  348.         
  349.         if (audwper[i] <= 0) {
  350.             audwper[i] += audper[i];
  351.             if (audst[i] == 1) {
  352.             /*  Starting a sample, cause interrupt */
  353.             put_word (0xDFF09C, 0x8000 | (0x80 << i));
  354.             audst[i] = 2;
  355.             }
  356.             audsnum[i] ^= 1;
  357.             if (audsnum[i] == 0) {
  358.             auddat[i] = get_word (audpt[i]);
  359.             audpt[i] += 2;
  360.             audwlen[i]--;
  361.             if (audwlen[i] == 0) {
  362.                 channel_reload (i);
  363.             }
  364.             }
  365.         }
  366.         if (adkcon & (0x11 << i)) {
  367.             snddata[i] = 0;
  368.             audsnum[i] ^= 2;
  369.             audsnum[i] |= 1;
  370.             if (i < 3) {
  371.             if (adkcon & (0x11 << i)) {
  372.                 if (audsnum[i] & 2)
  373.                 audvol[i+1] = auddat[i];
  374.                 else
  375.                 audper[i+1] = auddat[i];
  376.             } else if (adkcon & (1 << i)) {
  377.                 audvol[i+1] = auddat[i];
  378.             } else {
  379.                 audper[i+1] = auddat[i];
  380.             }
  381.             }
  382.         } else {
  383.             snddata[i] = audsnum[i] & 1 ? auddat[i] : auddat[i] >> 8;
  384.         }
  385.         audwper[i] -= 80;        
  386.         } else 
  387.             audst[i] = snddata[i] = 0;
  388.     }
  389.     if (dspbits == 16) {
  390.         if (dspomit == 0)
  391.         *bufpt++ = (sound_table[snddata[0]][audvol[0]] 
  392.                 + sound_table[snddata[1]][audvol[1]]
  393.                 + sound_table[snddata[2]][audvol[2]] 
  394.                 + sound_table[snddata[3]][audvol[3]]);
  395.     } else {
  396.         unsigned char *bp = (unsigned char *)bufpt;
  397.         if (dspomit == 0)
  398.         *bp++ = (sound_table[snddata[0]][audvol[0]] 
  399.              + sound_table[snddata[1]][audvol[1]]
  400.              + sound_table[snddata[2]][audvol[2]] 
  401.              + sound_table[snddata[3]][audvol[3]] + 128);
  402.         bufpt = (UWORD *)bp;
  403.     }
  404.     if ((char *)bufpt - (char *)buffer >= sndbufsize) {
  405.         write(sfd, buffer, sndbufsize);
  406.         bufpt = buffer;
  407.     }
  408.     }
  409. }
  410.  
  411. #elif defined(AF_SOUND)
  412.  
  413. #include <AF/AFlib.h>
  414.  
  415. /* The buffer is too large... */
  416. static UWORD buffer[44100], *bufpt;
  417. static UBYTE snddata[4];
  418.  
  419. static int smplcnt = 0;
  420. static int dspbits = 0;
  421. static int sndbufsize;
  422.  
  423. static AFAudioConn  *aud;
  424. static AC            ac;
  425. static long          count = 0;
  426. static long          aftime;
  427. static int           rate;
  428. static int           freq_divisor;    
  429.  
  430.  
  431. static int have_sound;
  432.  
  433. int init_sound (void)
  434. {
  435.     AFSetACAttributes   attributes;
  436.     AFDeviceDescriptor *aDev;
  437.     int                 device;
  438.     
  439.     aud = AFOpenAudioConn(NULL);
  440.     have_sound = !(aud == NULL);
  441.     if (!have_sound) {
  442.     return 0;
  443.     }
  444.     
  445.     for(device = 0; device < ANumberOfAudioDevices(aud); device++) {
  446.     aDev = AAudioDeviceDescriptor(aud, device);
  447.     rate = aDev->playSampleFreq;
  448.     sndbufsize = (rate / 8) * 4;
  449.     if(aDev->inputsFromPhone == 0
  450.        && aDev->outputsToPhone == 0
  451.        && aDev->playNchannels == 1)
  452.         break;
  453.     }
  454.     if (device == ANumberOfAudioDevices(aud)) {
  455.     return 0;
  456.     }
  457.     
  458.     dspbits = 16;
  459.     attributes.type = LIN16;
  460.     ac = AFCreateAC(aud, device, ACEncodingType, &attributes);
  461.     aftime = AFGetTime(ac);
  462.  
  463.     if (dspbits == 16) {
  464.     init_sound_table16 ();
  465.     } else {
  466.     init_sound_table8 ();
  467.     }
  468.  
  469.     freq_divisor = 44100 / rate;
  470.     
  471.     audst[0] = audst[1] = audst[2] = audst[3] = 0;
  472.     bufpt = buffer;
  473.     smplcnt = 0;
  474.     printf ("Sound driver found and configured for %d bits at %d Hz, buffer is %d bytes\n", dspbits, rate, sndbufsize);
  475.     return 1;
  476. }
  477.  
  478. static void channel_reload (int c)
  479. {
  480.     audst[c] = 1;
  481.     audpt[c] = audlc[c];
  482.     audwper[c] = 0;
  483.     audwlen[c] = audlen[c];
  484.     audsnum[c] = 1;    
  485. }
  486.  
  487. void do_sound (void)
  488. {
  489.     smplcnt -= 227;
  490.     while (smplcnt < 0) {
  491.     int i;
  492.     smplcnt += 80;
  493.     
  494.     for(i = 0; i < 4; i++) {
  495.         if (dmaen (1<<i)) {
  496.         if (audst[i] == 0) {        
  497.             /* DMA was turned on for this channel */
  498.             channel_reload (i);
  499.             continue;
  500.         }
  501.         
  502.         if (audwper[i] <= 0) {
  503.             audwper[i] += audper[i];
  504.             if (audst[i] == 1) {
  505.             /*  Starting a sample, cause interrupt */
  506.             put_word (0xDFF09C, 0x8000 | (0x80 << i));
  507.             audst[i] = 2;
  508.             }
  509.             audsnum[i] ^= 1;
  510.             if (audsnum[i] == 0) {
  511.             auddat[i] = get_word (audpt[i]);
  512.             audpt[i] += 2;
  513.             audwlen[i]--;
  514.             if (audwlen[i] == 0) {
  515.                 channel_reload (i);
  516.             }
  517.             }
  518.         }
  519.         if (adkcon & (0x11 << i)) {
  520.             snddata[i] = 0;
  521.             audsnum[i] ^= 2;
  522.             audsnum[i] |= 1;
  523.             if (i < 3) {
  524.             if (adkcon & (0x11 << i)) {
  525.                 if (audsnum[i] & 2)
  526.                 audvol[i+1] = auddat[i];
  527.                 else
  528.                 audper[i+1] = auddat[i];
  529.             } else if (adkcon & (1 << i)) {
  530.                 audvol[i+1] = auddat[i];
  531.             } else {
  532.                 audper[i+1] = auddat[i];
  533.             }
  534.             }
  535.         } else {
  536.             snddata[i] = audsnum[i] & 1 ? auddat[i] : auddat[i] >> 8;
  537.         }
  538.         audwper[i] -= 80;        
  539.         } else 
  540.             audst[i] = snddata[i] = 0;
  541.     }
  542.     if ((count++ % frq_divisor) == 0) {
  543.         long size;
  544.         *bufpt++ = (sound_table[snddata[0]][audvol[0]] 
  545.             + sound_table[snddata[1]][audvol[1]]
  546.             + sound_table[snddata[2]][audvol[2]] 
  547.             + sound_table[snddata[3]][audvol[3]];
  548.         size = (char *)bufpt - (char *)buffer;
  549.         if (size >= sndbufsize) {
  550.         if (AFGetTime(ac) > aftime)
  551.             aftime = AFGetTime(ac);
  552.         AFPlaySamples(ac, aftime, size, (unsigned char*) buffer);
  553.         aftime += size / 2;
  554.         bufpt = buffer;
  555.         }
  556.     }
  557.     }
  558. }
  559.  
  560. #elif defined(__mac__)
  561.  
  562. #include <Sound.h>
  563.  
  564. static SndChannelPtr newChannel;
  565. static ExtSoundHeader theSndBuffer;
  566. static SndCommand theCmd;
  567. static const int n_frames = 10;
  568.  
  569. /* The buffer is too large... */
  570. static UWORD buffer0[44100], buffer1[44100], *bufpt;
  571. static UBYTE snddata[4];
  572.  
  573. static int frames = 0;
  574. static int smplcnt = 0;
  575. static long count = 0;
  576. static int have_sound;
  577. static int sndbufsize=44100;
  578. static int nextbuf=0;
  579. static Boolean sFlag=true;
  580.  
  581. int init_sound (void)
  582. {    
  583.     if (SndNewChannel(&newChannel, sampledSynth, initMono, NULL)) 
  584.     return 0;
  585.     init_sound_table8 ();
  586.     smplcnt = 0;
  587.     bufpt = buffer0;
  588.     return 1;
  589. }
  590.  
  591. static void channel_reload (int c)
  592. {
  593.     audst[c] = 1;
  594.     audpt[c] = audlc[c];
  595.     audwper[c] = 0;
  596.     audwlen[c] = audlen[c];
  597.     audsnum[c] = 1;    
  598. }
  599.  
  600. void do_sound (void)
  601. {
  602.     unsigned char *bp;
  603.     
  604.     smplcnt -= 227;
  605.     while (smplcnt < 0) {
  606.     int i;
  607.     smplcnt += 80;
  608.     
  609.     for(i = 0; i < 4; i++) {
  610.         if (dmaen (1<<i)) {
  611.         if (audst[i] == 0) {        
  612.             /* DMA was turned on for this channel */
  613.             channel_reload (i);
  614.             continue;
  615.         }
  616.         
  617.         if (audwper[i] <= 0) {
  618.             audwper[i] += audper[i];
  619.             if (audst[i] == 1) {
  620.             /*  Starting a sample, cause interrupt */
  621.             put_word (0xDFF09C, 0x8000 | (0x80 << i));
  622.             audst[i] = 2;
  623.             }
  624.             audsnum[i] ^= 1;
  625.             if (audsnum[i] == 0) {
  626.             auddat[i] = get_word (audpt[i]);
  627.             audpt[i] += 2;
  628.             audwlen[i]--;
  629.             if (audwlen[i] == 0) {
  630.                 channel_reload (i);
  631.             }
  632.             }
  633.         }
  634.         if (adkcon & (0x11 << i)) {
  635.             snddata[i] = 0;
  636.             audsnum[i] ^= 2;
  637.             audsnum[i] |= 1;
  638.             if (i < 3) {
  639.             if (adkcon & (0x11 << i)) {
  640.                 if (audsnum[i] & 2)
  641.                 audvol[i+1] = auddat[i];
  642.                 else
  643.                 audper[i+1] = auddat[i];
  644.             } else if (adkcon & (1 << i)) {
  645.                 audvol[i+1] = auddat[i];
  646.             } else {
  647.                 audper[i+1] = auddat[i];
  648.             }
  649.             }
  650.         } else {
  651.             snddata[i] = audsnum[i] & 1 ? auddat[i] : auddat[i] >> 8;
  652.         }
  653.         audwper[i] -= 80;        
  654.         } else 
  655.             audst[i] = snddata[i] = 0;
  656.     }
  657.     
  658.     bp = (unsigned char *)bufpt;
  659.     *bp++ = (sound_table[snddata[0]][audvol[0]] 
  660.          + sound_table[snddata[1]][audvol[1]]
  661.          + sound_table[snddata[2]][audvol[2]] 
  662.          + sound_table[snddata[3]][audvol[3]] + 128);
  663.     bufpt = (UWORD *)bp;
  664.     
  665.     if (nextbuf == 0) {
  666.         if ((char *)bufpt - (char *)buffer0 >= sndbufsize) {
  667.         nextbuf++;
  668.         bufpt = buffer1;
  669.             
  670.         theSndBuffer.samplePtr = (Ptr)buffer0;
  671.         theSndBuffer.numChannels = 1;
  672.         theSndBuffer.sampleRate = 0xac440000;
  673.         theSndBuffer.encode = extSH;
  674.         theSndBuffer.numFrames = sndbufsize;
  675.         theSndBuffer.sampleSize = 8;
  676.         theCmd.param1 = 0;
  677.         theCmd.param2 = (long)&theSndBuffer;
  678.         theCmd.cmd = bufferCmd;
  679.         SndDoCommand(newChannel, &theCmd, false);    
  680.         }
  681.     } else {
  682.         if ((char *)bufpt - (char *)buffer1 >= sndbufsize) {    
  683.         nextbuf=0;
  684.             bufpt = buffer0;
  685.             
  686.             theSndBuffer.samplePtr = (Ptr)buffer1;
  687.             theSndBuffer.numChannels = 1;
  688.         theSndBuffer.sampleRate = 0xac440000;
  689.         theSndBuffer.encode = extSH;
  690.         theSndBuffer.numFrames = sndbufsize;
  691.         theSndBuffer.sampleSize = 8;
  692.         theCmd.param1 = 0;
  693.         theCmd.param2 = (long)&theSndBuffer;
  694.         theCmd.cmd = bufferCmd;
  695.         SndDoCommand(newChannel, &theCmd, false);    
  696.         }
  697.     }
  698.     }
  699. }
  700.  
  701. #else
  702.  
  703. int init_sound (void)
  704. {
  705.     return 1;
  706. }
  707.  
  708. void do_sound (void)
  709. {
  710. }
  711.  
  712. #endif
  713.