SWORD MD_SampleLoad(SAMPLOAD* s, int type) { SWORD result; if(type==MD_MUSIC) type=(md_mode & DMODE_SOFT_MUSIC)?MD_SOFTWARE:MD_HARDWARE; else if(type==MD_SNDFX) type=(md_mode & DMODE_SOFT_SNDFX)?MD_SOFTWARE:MD_HARDWARE; SL_Init(s); result=md_driver->SampleLoad(s,type); SL_Exit(s); return result; }
SWORD MD_SampleLoad(SAMPLOAD *s, int type, VIRTUAL_FILE *fp) /* type - sample type .. MD_MUSIC or MD_SNDFX */ { SWORD result; if(type==MD_MUSIC) type = (md_mode & DMODE_SOFT_MUSIC) ? MD_SOFTWARE : MD_HARDWARE; else if(type==MD_SNDFX) type = (md_mode & DMODE_SOFT_SNDFX) ? MD_SOFTWARE : MD_HARDWARE; SL_Init(s); result = md_driver->SampleLoad(s, type, fp); SL_Exit(s); return result; }
SWORD UltraSampleLoad(FILE * fp, ULONG length, ULONG loopstart, ULONG loopend, UWORD flags) { struct SAMPLE_DATA *smp; char *p; long l; smp = &instrs[nr_instrs]; smp->length = length; smp->loopstart = loopstart; if (!loopend) /* by Perex */ smp->loopend = length - 1; else smp->loopend = loopend; smp->flags = flags; // SF_16BITS if ((smp->flags & SF_16BITS)) { length <<= 1; loopstart <<= 1; loopend <<= 1; } if ((smp->sample = (char *) malloc(length)) == NULL) { myerr = "not enough memory to load sample."; return -1; } SL_Init(fp, flags, flags | SF_SIGNED); // SF_16BITS l = length; p = smp->sample; while (l > 0) { static UBYTE buffer[8192]; long todo; todo = (l > 8192) ? 8192 : l; SL_Load(p, todo); p += todo; l -= todo; } smp->active = 1; return nr_instrs++; }
SWORD VC_SampleLoad(FILE *fp,ULONG length,ULONG reppos,ULONG repend,UWORD flags) { int handle; ULONG t; SL_Init(fp,flags,(flags|SF_SIGNED)&~SF_16BITS); /* Find empty slot to put sample address in */ for(handle=0;handle<MAXSAMPLEHANDLES;handle++){ if(Samples[handle]==NULL) break; } if(handle==MAXSAMPLEHANDLES){ myerr=ERROR_OUT_OF_HANDLES; return -1; } if((Samples[handle]=malloc(length+16))==NULL){ myerr=ERROR_SAMPLE_TOO_BIG; return -1; } /* read sample into buffer. */ LargeRead(Samples[handle],length); /* Unclick samples: */ if(flags & SF_LOOP){ if(flags & SF_BIDI) for(t=0;t<16;t++) Samples[handle][repend+t]=Samples[handle][(repend-t)-1]; else for(t=0;t<16;t++) Samples[handle][repend+t]=Samples[handle][t+reppos]; } else{ for(t=0;t<16;t++) Samples[handle][t+length]=0; } return handle; }
/* @doc OEM @func PVOID | CCSerInit | Initializes device identified by argument. * This routine sets information controlled by the user * such as Line control and baud rate. It can also initialize events and * interrupts, thereby indirectly managing initializing hardware buffers. * Exported only to driver, called only once per process. * @rdesc The return value is a PVOID to be passed back into the HW dependent layer when HW functions are called. */ static PVOID CCSerInit( ULONG Identifier, // @parm Device identifier. PVOID pMddHead, // @parm First argument to mdd callbacks. PHWOBJ pHWObj // @parm Pointer to our own HW OBJ for this device ) { PSER_INFO pHWHead; // Allocate for our main data structure and one of it's fields. pHWHead = (PSER_INFO)LocalAlloc( LMEM_ZEROINIT|LMEM_FIXED , sizeof(SER_INFO) ); if (!pHWHead) goto ALLOCFAILED; pHWHead->dwSysIntr = pHWObj->dwIntID; // Initial to default vaule; pHWHead->pHWObj = pHWObj; if ( ! Ser_GetRegistryData(pHWHead, (LPCTSTR)Identifier) ) { DEBUGMSG (ZONE_INIT|ZONE_ERROR, (TEXT("SerInit - Unable to read registry data. Failing Init !!! \r\n"))); goto ALLOCFAILED; } pHWObj->dwIntID = pHWHead->dwSysIntr; // This call will map the address space for the 16550 UART. pHWHead->pBaseAddress = CCSer_InternalMapRegisterAddresses( pHWHead->dwMemBase, 0x400); pHWHead->pMddHead = pMddHead; pHWHead->cOpenCount = 0; // Set up our Comm Properties data pHWHead->CommProp.wPacketLength = 0xffff; pHWHead->CommProp.wPacketVersion = 0xffff; pHWHead->CommProp.dwServiceMask = SP_SERIALCOMM; pHWHead->CommProp.dwReserved1 = 0; pHWHead->CommProp.dwMaxTxQueue = 16; pHWHead->CommProp.dwMaxRxQueue = 16; pHWHead->CommProp.dwMaxBaud = BAUD_115200; pHWHead->CommProp.dwProvSubType = PST_RS232; pHWHead->CommProp.dwProvCapabilities = PCF_DTRDSR | PCF_RLSD | PCF_RTSCTS | PCF_SETXCHAR | PCF_INTTIMEOUTS | PCF_PARITY_CHECK | PCF_SPECIALCHARS | PCF_TOTALTIMEOUTS | PCF_XONXOFF; pHWHead->CommProp.dwSettableBaud = BAUD_075 | BAUD_110 | BAUD_150 | BAUD_300 | BAUD_600 | BAUD_1200 | BAUD_1800 | BAUD_2400 | BAUD_4800 | BAUD_7200 | BAUD_9600 | BAUD_14400 | BAUD_19200 | BAUD_38400 | BAUD_56K | BAUD_128K | BAUD_115200 | BAUD_57600 | BAUD_USER; pHWHead->CommProp.dwSettableParams = SP_BAUD | SP_DATABITS | SP_HANDSHAKING | SP_PARITY | SP_PARITY_CHECK | SP_RLSD | SP_STOPBITS; pHWHead->CommProp.wSettableData = DATABITS_5 | DATABITS_6 | DATABITS_7 | DATABITS_8; pHWHead->CommProp.wSettableStopParity = STOPBITS_10 | STOPBITS_20 | PARITY_NONE | PARITY_ODD | PARITY_EVEN | PARITY_SPACE | PARITY_MARK; // Init 16550 info, register stride is 1 DEBUGMSG (ZONE_INIT, (TEXT("CCSerInit - Init 16550 data\r\n"))); SL_Init( pHWHead, pHWHead->pBaseAddress, CC_16550_REG_STRIDE, EvaluateEventFlag, pMddHead, (PLOOKUP_TBL)&BaudTable); DEBUGMSG (ZONE_INIT, (TEXT("CCSerInit - Disabling UART Power\r\n"))); pHWHead->fIRMode = FALSE; // Select wired by default CCSerSetOutputMode(pHWHead, FALSE, FALSE ); return pHWHead; ALLOCFAILED: if (pHWHead != NULL) { if (pHWHead->pBaseAddress) { VirtualFree(pHWHead->pBaseAddress, 0, MEM_RELEASE); } LocalFree(pHWHead); } return NULL; }