home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / memory / dma / dmabsp.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-07-28  |  2.0 KB  |  68 lines

  1. {
  2.  Example of use of "DMA" unit.
  3. }
  4.  
  5.  
  6. [ ... ]
  7.  
  8.  
  9. procedure Games_Sb16(dsize : word;p : pointer);
  10. {
  11.  When using the DMA unit ....
  12. }
  13. var li : word;
  14. begin;
  15.   DMA_Init_Transfer(dma_ch,Blockmode,p,dsize-1);
  16.  
  17.   if sb16_outputlength <> dsize then begin;
  18.     wr_dsp_sb16($C6);                   { DSP command 8-bit via DMA  }
  19.     if stereo then                      { for SB16 Only for starting ! }
  20.       wr_dsp_sb16($20)
  21.     else
  22.       wr_dsp_sb16($00);
  23.     wr_dsp_sb16(Lo(dsize-1));           { size of block to       }
  24.     wr_dsp_sb16(Hi(dsize-1));           { DSP                    }
  25.     sb16_outputlength := dsize;
  26.   end else begin;
  27.     wr_dsp_sb16($45);                   { DMA Continue SB16 8-Bit    }
  28.   end;
  29. end;
  30.  
  31. [ ... ]
  32.  
  33. procedure Games_Sb16(Segm,Offs,dsize : word);
  34. {
  35.   Ohne die Unit DMA ....
  36. }
  37. var li : word;
  38. begin;
  39.   port[$0A] := dma_ch+4;                { lock DMA channel         }
  40.   Port[$0c] := 0;                       { buffer address (blk)  }
  41.   Port[$0B] := $49;                     { for sound output           }
  42.   {
  43.    Error in source of the book !!!!!!!!!!!!!!
  44.    should read 
  45.      Port[$0B] := $48 + dma_ch;
  46.    !!!!!!!!!!!!!!!!!!!!
  47.   }
  48.   Port[dma_addr[dma_ch]] := Lo(offs);    { to DMA-Controller          }
  49.   Port[dma_addr[dma_ch]] := Hi(offs);
  50.   Port[dma_wc[dma_ch]] := Lo(dsize-1);  { size of block (block size)  }
  51.   Port[dma_wc[dma_ch]] := Hi(dsize-1);  { to DMA controller }
  52.   Port[dma_page[dma_ch]] := Segm;
  53.   if sb16_outputlength <> dsize then begin;
  54.     wr_dsp_sb16($C6);                   { DSP command 8-Bit via DMA  }
  55.     if stereo then                      { for SB16 Only for starting ! }
  56.       wr_dsp_sb16($20)
  57.     else
  58.       wr_dsp_sb16($00);
  59.     wr_dsp_sb16(Lo(dsize-1));           { Size of block        }
  60.     wr_dsp_sb16(Hi(dsize-1));           { to DSP                    }
  61.     sb16_outputlength := dsize;
  62.   end else begin;
  63.     wr_dsp_sb16($45);                   { DMA continue SB16 8-Bit    }
  64.   end;
  65.   Port[$0A] := dma_ch;                  { free DMA channel        }
  66. end;
  67.  
  68.