home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Classic / MultimediaClassic.mdf / utility / xmm120.arj / MIKMOD43.ARJ / ULTRAEXT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-17  |  1.9 KB  |  107 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "mytypes.h"
  4. #include "forte.h"
  5. #include "gf1proto.h"
  6. #include "extern.h"
  7. #include "ultraerr.h"
  8. #include "ultraext.h"
  9.  
  10. ULTRA_CFG config;
  11.  
  12.  
  13. int UltraGetCfg(ULTRA_CFG *config)
  14. {
  15.     char *ptr;
  16.  
  17.     config->base_port = 0x220;
  18.     config->dram_dma_chan = 1;
  19.     config->adc_dma_chan = 1;
  20.     config->gf1_irq_num = 11;
  21.     config->midi_irq_num = 5;
  22.  
  23.     if((ptr=getenv("ULTRASND"))==NULL) return FALSE;
  24.  
  25.     if(sscanf(ptr,"%x,%d,%d,%d,%d"
  26.                 ,&config->base_port,
  27.                 &config->dram_dma_chan,
  28.                 &config->adc_dma_chan,
  29.                 &config->gf1_irq_num,
  30.                 &config->midi_irq_num)!=5) return FALSE;
  31.  
  32.     return(TRUE);
  33. }
  34.  
  35.  
  36.  
  37.  
  38. void UltraDownloadX(UBYTE *data_ptr,UBYTE control,ULONG dram_loc,UWORD len,int wait)
  39. /*
  40.     Identical to UltraDownLoad() except this one handles
  41.     dram_loc's that    aren't on a 32-byte boundary.
  42. */
  43. {
  44.     /* Dram location not on a 32 byte boundary ? */
  45.  
  46.     while(len>0 && (dram_loc&31)){
  47.  
  48.         /* Slowly 'poke' the odd
  49.            samples into gus dram */
  50.  
  51.         UltraPokeData(config.base_port,dram_loc,*data_ptr);
  52.  
  53.         data_ptr++;
  54.         dram_loc++;
  55.         len--;
  56.     }
  57.  
  58.     // The rest goes fast...
  59.  
  60.     if(len>0) UltraDownload(data_ptr,control,dram_loc,len,wait);
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67. ULONG UltraFileload(FILE *fp,UBYTE control,ULONG dram_loc,ULONG size)
  68. /*
  69.     This function directly loads data from a file into gus dram.
  70.     returns the number of bytes actually loaded.
  71. */
  72. {
  73.     ULONG todo,total=0,done;
  74.     char *buffer;
  75.  
  76.     if((buffer=malloc(8000))==NULL) return 0;
  77.  
  78.     do{
  79.         todo=(size>8000)?8000:size;
  80.  
  81.         done=fread(buffer,1,todo,fp);
  82.  
  83.         UltraDownloadX(buffer,control,dram_loc,done,TRUE);
  84.  
  85.         total+=done;
  86.         dram_loc+=done;
  87.         size-=done;
  88.  
  89.     } while( size>0 && (done==todo) );
  90.  
  91.     free(buffer);
  92.  
  93.     return total;
  94. }
  95.  
  96.  
  97. UBYTE UltraPeek(ULONG address)
  98. {
  99.     return(UltraPeekData(config.base_port,address));
  100. }
  101.  
  102.  
  103. void UltraPoke(ULONG address,UBYTE val)
  104. {
  105.     UltraPokeData(config.base_port,address,val);
  106. }
  107.