Initial commit

This commit is contained in:
Gwen Gourevich
2021-10-27 10:34:18 +02:00
parent 43ad18eb04
commit c5f4f6ba25
199 changed files with 73169 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
.386p
jumps
.model SMALL, C
.data
extrn NoLanguage P_SinTab:WORD
.code
public NoLanguage Balance
Balance PROC uses ebx,\
bal:DWORD, vol:DWORD, volleft:DWORD, volright:DWORD
mov eax, bal
shl eax, 1
mov edx, vol
xor ecx, ecx
mov cx, word ptr[P_SinTab + eax]
imul ecx, edx
shr ecx, 14
mov ebx, volright
mov dword ptr[ebx], ecx
xor ecx, ecx
mov cx, word ptr[P_SinTab + 512 + eax]
imul ecx, edx
shr ecx, 14
mov ebx, volleft
mov dword ptr[ebx], ecx
ret
Balance ENDP
END

View File

@@ -0,0 +1,3 @@
/* balance between 0 and 256, volume between 0 and 128 */
void Balance( ULONG balance, ULONG volume, ULONG *vol_left, ULONG *vol_right ) ;

15
LIB386/LIB_SAMP/BUILD.BAT Normal file
View File

@@ -0,0 +1,15 @@
call watcom10
pkunzip -o obj >NUL
copy wr\ail32.obj
wmake
pkzip -m obj *.obj >NUL
call watcom9
pkunzip -o obj9 >NUL
copy wr\ail32.obj
wmake WATCOM9=yes
pkzip -m obj9 *.obj >NUL
call watcom10

View File

@@ -0,0 +1,3 @@
pkunzip -o obj >NUL
wmake /f wave_dll.mak
pkzip -m obj *.obj >NUL

View File

@@ -0,0 +1,378 @@
.DATA
Status EQU 08h ;DMAC status port (read) \ same port
Command EQU 08h ;DMAC command port (write) / (read/write)
Request EQU 09h ;DMAC channel request (write-only)
DMA_Mask EQU 0Ah ;DMAC DMA_Mask (write-only)
Mode EQU 0Bh ;DMAC mode (write)
byte_ptr EQU 0Ch ;byte pointer flip-flop
addr EQU 000h ; per-channel base address
count EQU 001h ; per-channel byte count
read_cmd EQU 058h ; autoinitialising read
write_cmd EQU 054h ; auto write
set_cmd EQU 000h ; DMA_Mask set (enable dma)
reset_cmd EQU 004h ; DMA_Mask reset (disable)
page_table DW 00087h ; channel 0
DW 00083h ; channel 1
DW 00081h ; channel 2
DW 00082h ; channel 3
DW 0FFFFh ; ch 4 (not used)
DW 0008Bh ; ch 5
DW 00089h ; ch 6
DW 0008Ah ; ch 7
dmac2 DB 0 ; Flag set to non-zero when using the 2nd DMA controller
.CODE
MACRO adjust reg ; Adjust register port for 2nd DMA cont
local no_adjust
cmp byte ptr[dmac2], 0
jz no_adjust
shl reg, 1
add reg, 0C0h
no_adjust:
ENDM adjust
;+---------------------------------------------------------------------------+
;| int dma_setup(int Channel, char far *Buffer, unsigned Length) |
;| ------------------------------------------------------------------------- |
;| Channel = 0-7 |
;| Buffer = Address of data to transfer |
;| Length = Length of data to transfer |
;| ------------------------------------------------------------------------- |
;| Returns: 0 if no errors (dma_errno == 0) |
;| -1 if errors occurred (dma_errno set to indicate error.) |
;+---------------------------------------------------------------------------+
dma_setup PROC USES EBX,\
Channel:DWORD, Buffer:DWORD, Len:DWORD
;Convert 20-bit physical address of buffer into page:offset
mov edi, Buffer
mov ecx, edi
shr ecx, 8
; ch:di == The physical buffer base.
; Adjust channel number
mov byte ptr[dmac2], 0
mov bx, Channel
cmp bx, 4
jb OkChannel
and bx, 3
mov byte ptr[dmac2], 1
OkChannel:
; BX contains the adjusted channel number
mov si, read_cmd
add si, bx
mov cl, set_cmd ;allow dma requests
add cl, bl
;si contains READ/WRITE command for DMA controller
;cl contains confirmation command for DMA controller
shl bx, 1
;bx == Port # Channel*2
;-------------------------------------------------------------------------
; Calculations have been done ahead of time to minimize time with
; interrupts disabled.
;
; edi (ch:di) == physical base address (must be on word boundary for 16 bits)
;
; cl == Confirmation command (Unmasks the channel)
;
; bx == I/O port Channel*2 (This is where the address is written)
;
; si == Mode command for DMA
;-------------------------------------------------------------------------
; Now we shift the address and word count right one bit if in 16 bit mode.
cmp [dmac2], 0
jz AddrOk
shr ch, 1
rcr di, 1
shl ch, 1
shr [Len], 1 ;Odd byte lengths are rounded down
AddrOk:
;The "byte pointer" is also known as the LSB/MSB flip flop.
;By writing any value to it, the DMA controller registers are prepared
;to accept the address and length values LSB first.
mov dx, byte_pt ;Reset byte pointer Flip/flop
adjust dx
out dx, al
mov dx, bx ;dx=DMAC Base Address port
adjust dx
mov ax, di ;ax=LSW of 20-bit address
out dx, al ;Store LSB
mov al, ah
out dx, al ;Store MSB
;Write length to port (Channel * 2 + 1)
inc dx ;dx=DMAC Count port
mov eax, Len
out dx, al ;Write LSB of Length
mov al, ah
out dx, al ;Write MSB
;Write page to port page_table[channel]
mov ebx, Channel
shl bx, 1
mov dx, word ptr[OFFSET page_table + bx]
mov al, ch ;al=Page number
out dx, al ;Store the page
;Write Readcmd for channel to Mode port
mov dx, Mode ;dx=DMAC mode register
adjust dx
mov ax, si ;Load pre-calculated mode
out dx, al ;Write it to the DSP
mov dx, DMA_Mask ;dx=DMAX DMA_Mask register
adjust dx
mov al, cl ;al=pre-calulated DMA_Mask value
out dx, al ;Write DMA_Mask (allow dma on this channel)
ret
dma_setup ENDP
;+---------------------------------------------------------------------------+
;| int prevent_dma(int Channel) |
;| ------------------------------------------------------------------------- |
;| Channel = 0-7 |
;| Prevents DMA requests from Channel by masking bit in DMA_C. |
;| ------------------------------------------------------------------------- |
;+---------------------------------------------------------------------------+
prevent_dma PROC ,\
Channel:DWORD
; Check channel number range
mov dx, DMA_Mask
mov eax, Channel
cmp al, 4
jb OkChannel
and al, 3
shl dx, 1
add dx, 0C0h
OkChannel:
add al, reset_cmd ; Add disable DMA requests
out dx, al
ret
prevent_dma ENDP
;+---------------------------------------------------------------------------+
;| int allow_dma(int Channel) |
;| ------------------------------------------------------------------------- |
;| Channel = 0-7 |
;| Unmasks DMA on the specified channel. |
;| ------------------------------------------------------------------------- |
;+---------------------------------------------------------------------------+
allow_dma PROC ,\
Channel:DWORD
; Check channel number range
mov dx, DMA_Mask
mov eax, Channel
cmp al, 4
jb OkChannel
and al, 3
shl dx, 1
add dx, 0C0h
OkChannel:
add al, set_cmd ; Add enable DMA requests
out dx, al
ret
allow_dma ENDP
;+---------------------------------------------------------------------------+
;| int dma_count(Channel) |
;| ------------------------------------------------------------------------- |
;| Channel = 0-7 |
;| ------------------------------------------------------------------------- |
;| Returns: -1 if DMA transaction completed |
;| else returns the number of bytes/words left to transfer |
;+---------------------------------------------------------------------------+
PROC dma_count ,\
Channel:DWORD
mov eax, Channel
mov dx, ax
and dx, 3
shl dx, 1
add dx, count
cmp al, 4
jb OkChannel
shl dx, 1
add dx, 0C0h
OkChannel:
xor eax, eax
cli
in al, dx
mov ah, al
in al, dx
sti
xchg al, ah
ret
dma_count ENDP
;+---------------------------------------------------------------------------+
;| unsigned dma_addr(Channel) |
;| ------------------------------------------------------------------------- |
;| Channel = 0-7 |
;| ------------------------------------------------------------------------- |
;| Returns: Current address word of that channel |
;| Value must be multiplied by 2 for a 16-bit channel. |
;| It is best to start at offset 0, ie on a 64K boundary |
;+---------------------------------------------------------------------------+
dma_addr PROC ,\
Channel:DWORD
mov eax, Channel
mov dx, ax
and dx, 3
shl dx, 1
cmp al, 4
jb OkChannel
shl dx, 1
add dx, 0C0h
OkChannel:
xor eax, eax
cli
in al, dx
mov ah, al
in al, dx
sti
xchg al, ah
ret
dma_addr ENDP
VOID *DMABuffer, *DMAAllocBuffer;
BYTE LockedDMARegion;
#define MAX_DMABUFFERATTEMPTS 10;
;+---------------------------------------------------------------------------+
;| BYTE *AlignOn4KBoundry( BYTE *Buf ) |
;| ------------------------------------------------------------------------- |
;| Align Buf to the nearest 4K page |
;+---------------------------------------------------------------------------+
#define AlignOn4KBoundry(Buf) ((Buf + 0x00000FFF) & 0xFFFFF000)
;+---------------------------------------------------------------------------+
;| BYTE *AllocateDMABuffer( WORD BufferSize ) |
;| ------------------------------------------------------------------------- |
;| BufferSize = 0-64K |
;| ------------------------------------------------------------------------- |
;| Returns: Buffer if successful |
;| NULL if error |
;+---------------------------------------------------------------------------+
BYTE *AllocateDMABuffer( WORD BufferSize )
{
VOID *Tried[ MAX_DMABUFFERATTEMPTS ] ;
VOID *Buf, *DMAAddr ;
int Tries, Error ;
for (Tries = 0; Tries < MAX_DMABUFFERATTEMPTS; Tries++)
Tried[ Tries ] = NULL ;
Tries = 0;
LockedDMARegion = FALSE;
do
{
// printf( "DMA buffer allocation attempt: %d\n", Tries + 1 ) ;
if ((DMAAllocBuffer = (VOID *)DosMalloc( BufferSize + 0xFFF)) != NULL)
{
DMABuffer = AlignOn4KBoundry(DMAAllocBuffer);
if ( ((LONG)DMABuffer & 0xF0000) !=
(((LONG)DMABuffer + BufferSize) & 0xF0000) )
{
Tried[ Tries ] = DMAAllocBuffer ;
DMAAllocBuffer = NULL ;
DMABuffer = NULL ;
}
}
Tries++ ;
DMAAllocBuf = Buf;
DMABuffer = DMAAddr ;
}
while ((DMAAllocBuf == NULL) && (Tries < MAX_DMABUFFERATTEMPTS)) ;
for (wTries = 0; wTries < MAX_DMABUFFERATTEMPTS; wTries++)
{
if (alpTried[ wTries ])
free( alpTried[ wTries ] ) ;
else
break ;
}
return( DMABuffer ) ;
;+---------------------------------------------------------------------------+
;| VOID FreeDMABuffer( VOID ) |
;| ------------------------------------------------------------------------- |
;| Free the DMA buffer |
;+---------------------------------------------------------------------------+
VOID FreeDMABuffer( VOID )
{
if (LockedDMARegion)
UnlockDMARegion( &gDDS, 0 ) ;
if (DMAAllocBuf)
{
free( glpDMAAllocBuf ) ;
DMAAllocBuf = NULL ;
}
}

1
LIB386/LIB_SAMP/GUS.BAT Normal file
View File

@@ -0,0 +1 @@
@nmake /f gus.mak gusdig32.obj

87
LIB386/LIB_SAMP/GUS.C Normal file
View File

@@ -0,0 +1,87 @@
#include "\projet\lib386\lib_sys\adeline.h"
#include "\projet\lib386\lib_sys\lib_sys.h"
#pragma library ("\gussdk21\libs\ultra0wc.lib");
#include "forte.h"
#include "gf1proto.h"
#include "extern.h"
#include "ultraerr.h"
extern void NewIRQ(void);
extern void *BUFFER_DMA;
extern ULONG R_BUFFER_CARD;
extern ULONG MID_R_BUFFER_CARD;
extern ULONG CURRENT_R_BUFFER_CARD;
extern ULONG L_BUFFER_CARD;
extern ULONG MID_L_BUFFER_CARD;
extern ULONG CURRENT_L_BUFFER_CARD;
extern LONG BUFFER_SIZE;
extern UWORD PlayRate;
void ResetCard(void)
{
ULTRA_CFG config;
UBYTE RMode, LMode;
/* Get the ULTRASND environment string parameters */
UltraGetCfg(&config);
/* Open the card with 14 voices (44 Khz) */
UltraOpen(&config, 14);
/* Get a chunk of memory on the card */
UltraMemAlloc(BUFFER_SIZE << 1, &R_BUFFER_CARD);
MID_R_BUFFER_CARD = R_BUFFER_CARD + BUFFER_SIZE;
CURRENT_R_BUFFER_CARD = MID_R_BUFFER_CARD;
/* Reset memory on the card to 0 */
UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, R_BUFFER_CARD, BUFFER_SIZE, TRUE);
UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, MID_R_BUFFER_CARD, BUFFER_SIZE, TRUE);
/* Get a chunk of memory on the card */
UltraMemAlloc(BUFFER_SIZE << 1, &L_BUFFER_CARD);
MID_L_BUFFER_CARD = L_BUFFER_CARD + BUFFER_SIZE;
CURRENT_L_BUFFER_CARD = MID_L_BUFFER_CARD;
/* Reset memory on the card to 0 */
UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, L_BUFFER_CARD, BUFFER_SIZE, TRUE);
UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, MID_L_BUFFER_CARD, BUFFER_SIZE, TRUE);
/* set Balance for each voice */
UltraSetBalance(0, 7);
UltraSetBalance(1, 7);
/* Set Frequency for each voice to PlayRate */
UltraSetFrequency(0, PlayRate);
UltraSetFrequency(1, PlayRate);
/* set Volume for each voice */
UltraSetVolume(0, 511);
UltraSetVolume(1, 511);
/* get voices ready... */
RMode = UltraPrimeVoice(0, R_BUFFER_CARD, R_BUFFER_CARD,
R_BUFFER_CARD + (BUFFER_SIZE << 1), 0x20 | 0x08 | 0x04);
LMode = UltraPrimeVoice(1, L_BUFFER_CARD, MID_L_BUFFER_CARD,
L_BUFFER_CARD + (BUFFER_SIZE << 1), 0x20 | 0x08 | 0x04);
/* Plug in our IRQ handler for wave events */
UltraWaveHandler(NewIRQ);
/*set, go ! */
UltraGoVoice(0, RMode);
UltraGoVoice(1, LMode);
}
void StartDMACard(void)
{
UltraDownload(BUFFER_DMA, DMA_8|DMA_CVT_2, CURRENT_R_BUFFER_CARD, BUFFER_SIZE, FALSE);
}

25
LIB386/LIB_SAMP/GUS.INC Normal file
View File

@@ -0,0 +1,25 @@
;*--------------------------------------------------------------------------*
BUFFER_SIZE equ 1024 ; number of samples
; in half-buffer
LIST_SIZE equ 50
STRUCT_SIZE equ 40
SNAP_SIZE equ 8
SHIFT_SAMPLE equ 3 ; max number of
; samples mixed
;*--------------------------------------------------------------------------*
EXTERN SYSCALL playrate:WORD
EXTERN SYSCALL bufferhalf:DWORD
EXTERN SYSCALL buffer_dma:DWORD
EXTERN SYSCALL current_buffer:DWORD
EXTERN SYSCALL DoUpdate:WORD
EXTERN SYSCALL Critical:WORD
;*--------------------------------------------------------------------------*
UpdateBuffer PROTO SYSCALL
;*--------------------------------------------------------------------------*

206
LIB386/LIB_SAMP/LIB_WAVE.H Normal file
View File

@@ -0,0 +1,206 @@
#ifdef WATCOM9
#pragma library ("f:\projet\lib386\lib_samp\lb9_wave.lib");
#else
#pragma library ("f:\projet\lib386\lib_samp\lib_wave.lib");
#endif
typedef struct
{
ULONG LongHandle;
ULONG Info0;
ULONG Position;
}
T_WAVE;
extern char Wave_Driver[];
extern char Wave_Driver_Name[];
extern LONG Wave_Driver_Enable;
/*----------------------------------------------------------------------*/
/* WaveInitDLL : Load and connect the DLL to the program */
/* */
/* dlldriver : Pathname of the DLL */
/* */
/* Returns : TRUE if ok, FALSE if problems */
/*----------------------------------------------------------------------*/
LONG WaveInitDLL( char *dlldriver ) ;
/*----------------------------------------------------------------------*/
/* WaveAskVars : Get the list of variables needed by the DLL */
/* */
/* listidentifier : pointer to an array of string*/
/* pointers, each string */
/* contains the name of the var */
/* to initialise for the DLL */
/* ptrvars : pointer to an array of DWORD to */
/* store the value of each var in */
/* listidentifier */
/* */
/* Returns : TRUE if ok, FALSE if problems */
/*----------------------------------------------------------------------*/
void WaveAskVars( char ***listidentifier, LONG **ptrvars ) ;
/*----------------------------------------------------------------------*/
/* InitWave : Init the library */
/* */
/* Returns : TRUE if ok, FALSE if problems */
/*----------------------------------------------------------------------*/
ULONG InitWave( void );
/*----------------------------------------------------------------------*/
/* ClearWave : Close the library */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void ClearWave( void );
/*----------------------------------------------------------------------*/
/* WavePlay : Play a Sample */
/* */
/* Handle : a number identifying the sample */
/* Pitchbend : 4096 is no bend */
/* Repeat : number of times to play the sample */
/* Follow : if TRUE, this sample will play after */
/* the previous one */
/* VolLeft : Volume for Left channel (128 max) */
/* VolRight : Volume for Right channel (128 max) */
/* Buffer : Pointer to the sample in mem */
/* */
/* Returns : the lib internal handle */
/*----------------------------------------------------------------------*/
ULONG WavePlay( UWORD Handle,
UWORD Pitchbend,
UWORD Repeat,
UBYTE Follow,
UWORD VolLeft,
UWORD VolRight,
void *Buffer );
/*----------------------------------------------------------------------*/
/* WaveGiveInfo0 : Fill the user Info0 field */
/* */
/* LongHandle : Lib internal handle */
/* Info0 : the info to be stored (up to you) */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveGiveInfo0( ULONG LongHandle,
ULONG Info0 );
/*----------------------------------------------------------------------*/
/* WaveStop : Stop all samples, clear all internal vars */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveStop( void );
/*----------------------------------------------------------------------*/
/* WaveStopOne : Stop one sample */
/* */
/* Handle : Your Handle */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveStopOne( UWORD Handle );
/*----------------------------------------------------------------------*/
/* WaveStopOneLong : Stop one sample */
/* */
/* LongHandle : Lib internal handle */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveStopOneLong( ULONG LongHandle );
/*----------------------------------------------------------------------*/
/* WaveInList : Test if one sample is currently used by */
/* the lib */
/* */
/* Handle : Your Handle */
/* */
/* Returns : TRUE if used */
/*----------------------------------------------------------------------*/
int WaveInList( UWORD handle );
/*----------------------------------------------------------------------*/
/* WaveGetSnap : Take a snapshot of all Internal handles and */
/* Info0 for currently playing samples in array */
/* ListSnapSample */
/* */
/* Buffer : A pointer that will be filled with */
/* the address of the buffer */
/* */
/* Returns : The number of samples currently used by the */
/* lib */
/*----------------------------------------------------------------------*/
int WaveGetSnap( void **Buffer );
/*----------------------------------------------------------------------*/
/* WavePause : Pause all the playing samples */
/* */
/* Returns : TRUE if paused */
/*----------------------------------------------------------------------*/
int WavePause( void );
/*----------------------------------------------------------------------*/
/* WaveContinue : Continue all the playing samples */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveContinue( void );
/*----------------------------------------------------------------------*/
/* WaveSaveState : Save the internal state of the lib and */
/* get ready to play somme other samples */
/* */
/* Remark : Can be called only once */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveSaveState( void );
/*----------------------------------------------------------------------*/
/* WaveRestoreState: Restore the internal state of the lib */
/* and resume playback */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveRestoreState( void );
/*----------------------------------------------------------------------*/
/* WaveChangeVolume: Change the volume of a sample */
/* */
/* LongHandle : Lib internal handle */
/* VolLeft : New Left volume (128 max) */
/* VolRight : New Right volume (128 max) */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveChangeVolume( ULONG longhandle,
ULONG VolGauche,
ULONG VolDroit );
/*----------------------------------------------------------------------*/
/* WaveMove : Tell the driver to move the samples from */
/* SrcAddr to DestAddr. Size given by Size */
/* */
/* DestAddr : Dest */
/* SrcAddr : Source */
/* Size : number of bytes to move */
/* */
/* Returns : nothing */
/*----------------------------------------------------------------------*/
void WaveMove( void *DestAddr,
void *SrcAddr,
ULONG Size );
/*----------------------------------------------------------------------*/
/* WaveGetAddr : Return a pointer to the current playing */
/* sample data */
/* */
/* Returns : a pointer (FLAT) */
/*----------------------------------------------------------------------*/
void *WaveGetAddr( void );

54
LIB386/LIB_SAMP/MAKEFILE Normal file
View File

@@ -0,0 +1,54 @@
# name the compiler
!ifdef %HOME
!ifeq WATCOM9 yes
CC = c:\compil\watcom\bin\wcc386p
WL = c:\compil\watcom\binb\wlib
!else
CC = c:\compil\watcom10\binb\wcc386
WL = c:\compil\watcom10\binb\wlib
!endif
!else
!ifeq WATCOM9 yes
CC = f:\compil\watcom\bin\wcc386p
WL = f:\compil\watcom\binb\wlib
!else
CC = f:\compil\watcom10\binb\wcc386
WL = f:\compil\watcom10\binb\wlib
!endif
!endif
ASM = ml
!ifeq WATCOM9 yes
CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9
!else
CFLAGS = /oeaxt /zp2 /5s /zq /s
!endif
LFLAGS = /c /q /b /n
#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS
AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=;
.SILENT
OBJETS1 = wave.obj wave_i.obj
!ifeq WATCOM9 yes
LIB = LB9_WAVE
!else
LIB = LIB_WAVE
!endif
$(LIB).LIB: $(OBJETS1)
@echo $(OBJETS1) > clibmak.rsp
@$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp
@del clibmak.rsp
@prntitre M "$(LIB) OK"
.asm.obj:
@PRNTITRE M "$*.ASM"
@$(ASM) $(AFLAGS) $*.ASM
.c.obj:
@PRNTITRE M "$*.C"
@$(CC) $(CFLAGS) $*

3436
LIB386/LIB_SAMP/N_WAVE.ASM Normal file

File diff suppressed because it is too large Load Diff

141
LIB386/LIB_SAMP/PATCH.INC Normal file
View File

@@ -0,0 +1,141 @@
ENVELOPES equ 6
HEADER_SIZE equ 12
ID_SIZE equ 10
DESC_SIZE equ 60
RESERVED_SIZE equ 40
PATCH_HEADER_RESERVED_SIZE equ 36
LAYER_RESERVED_SIZE equ 40
PATCH_DATA_RESERVED_SIZE equ 36
PatchHeader STRUC
;PatchHeader
header db HEADER_SIZE dup (?)
gravis_id db ID_SIZE dup (?)
description db DESC_SIZE dup (?)
instruments db ?
voices db ?
channels db ?
wave_forms dw ?
master_volume dw ?
data_size dd ?
reserved_h db PATCH_HEADER_RESERVED_SIZE dup (?)
;InstrumentData
instrument dw ?
instrument_name db 16 dup (?)
instrument_size dd ?
layers db ?
reserved_i db RESERVED_SIZE dup (?)
;LayerData
layer_duplicate db ?
layer db ?
layer_size dd ?
samples db ?
reserved_l db LAYER_RESERVED_SIZE dup (?)
PatchHeader ENDS
PatchData STRUC
wave_name db 7 dup (?)
fractions db ?
wave_size dd ?
start_loop dd ?
end_loop dd ?
sample_rate dw ?
low_frequency dd ?
high_frequency dd ?
root_frequency dd ?
tune dw ?
balance db ?
envelope_rate db ENVELOPES dup (?)
envelope_offset db ENVELOPES dup (?)
tremolo_sweep db ?
tremolo_rate db ?
tremolo_depth db ?
vibrato_sweep db ?
vibrato_rate db ?
vibrato_depth db ?
modes db ?
scale_frequency dw ?
scale_factor dw ?
reserved_w db PATCH_DATA_RESERVED_SIZE dup (?)
PatchData ENDS
CommonData STRUC
Control db ?
NumbSamples db ?
DataOffset dw ?
CommonData ENDS
;SampleData STRUC
;
;_wave_start dd ?
;_wave_end dd ?
;_start_loop dd ?
;_end_loop dd ?
;_sample_rate dw ?
;_low_frequency dd ?
;_high_frequency dd ?
;_root_frequency dd ?
;_balance db ?
;_envelope_rate db ENVELOPES dup (?)
;_envelope_offset db ENVELOPES dup (?)
;_tremolo_sweep db ?
;_tremolo_rate db ?
;_tremolo_depth db ?
;_vibrato_sweep db ?
;_vibrato_rate db ?
;_vibrato_depth db ?
;_modes db ?
;_scale_frequency dw ?
;_scale_factor dw ?
;
;SampleData ENDS
wave_struct STRUC
_start_loop dd ?
_end_loop dd ?
_low_frequency dd ?
_high_frequency dd ?
_root_frequency dd ?
_mem dd ?
_scale_frequency dw ?
_sample_rate dw ?
_scale_factor dw ?
_start_acc_low dw ?
_start_acc_high dw ?
_start_low dw ?
_start_high dw ?
_end_low dw ?
_end_high dw ?
_end_acc_low dw ?
_end_acc_high dw ?
_sample_ratio dw ?
_wave_size dd ?
_fractions db ?
_balance db ?
_envelope_rate db ENVELOPES dup (?)
_envelope_offset db ENVELOPES dup (?)
_tremolo_sweep db ?
_tremolo_rate db ?
_tremolo_depth db ?
_vibrato_sweep db ?
_vibrato_rate db ?
_vibrato_depth db ?
_modes db ?
wave_struct ENDS

30
LIB386/LIB_SAMP/README.md Normal file
View File

@@ -0,0 +1,30 @@
# LIB_SAMP
In order to build LIB_SAMP, following third party SDK is required:
- Miles Sound System AIL32 v1.0
- Gravis Ultra Sound SDK v2.1 (gussdk21)
AIL32 v1.0 is licensed under "Copyright (C) 1991, 1992 Miles Design, Inc."
terms and is not delivered in this package.
Gravis Ultra Sound SDK is licensed under
"Copyright (C): 1993,1994 by Advanced Gravis Computer Technology" terms and is
not delivered in this package. It's included in the AIL32 SDK.
Following files from AIL32 SDK are expected to be in LIB_SAMP folder:
```
+---LIB_SAMP
| 386.MAC
| AIL32.INC
| AIL32PAT.EXE
| GF1NEW.INC
| GF1PROTO.INC
| GF1_OSPM.LIB
| GUS.BAT
| GUS.MAK
| GUSDIG32.ASM
| GUSMID32.INC
| PMINIT.ASM
| PMINIT.INC
```

26
LIB386/LIB_SAMP/REAL.ASM Normal file
View File

@@ -0,0 +1,26 @@
.386
;-----------------------------------------------------------------------------
_TEXT16 SEGMENT BYTE PUBLIC USE16 'CODE'
ASSUME CS:_TEXT16
ASSUME DS:_TEXT16
PUBLIC RealInt
;-----------------------------------------------------------------------------
RealInt:
db 0EAh, 78h, 56h, 34h, 12h ; jmp far 1234h:5678h
;-----------------------------------------------------------------------------
_TEXT16 ENDS
;-----------------------------------------------------------------------------
;
; The
End

10
LIB386/LIB_SAMP/TEST.C Normal file
View File

@@ -0,0 +1,10 @@
//#include <stdlib.h>
void InitWave()
{
int i;
void *bad_handle[10];
for(i=0; i<10; i++)
bad_handle[i]=NULL;
}

26
LIB386/LIB_SAMP/VOL.INC Normal file
View File

@@ -0,0 +1,26 @@
gf1_volumes dw 00000h, 009ffh, 00a80h, 00affh
dw 00b40h, 00b80h, 00bc0h, 00bffh, 00c20h
dw 00c40h, 00c60h, 00c80h, 00ca0h, 00cc0h
dw 00ce0h, 00cffh, 00d10h, 00d20h, 00d30h
dw 00d40h, 00d50h, 00d60h, 00d70h, 00d80h
dw 00d90h, 00da0h, 00db0h, 00dc0h, 00dd0h
dw 00de0h, 00df0h, 00dffh, 00e08h, 00e10h
dw 00e18h, 00e20h, 00e28h, 00e30h, 00e38h
dw 00e40h, 00e48h, 00e50h, 00e58h, 00e60h
dw 00e68h, 00e70h, 00e78h, 00e80h, 00e88h
dw 00e90h, 00e98h, 00ea0h, 00ea8h, 00eb0h
dw 00eb8h, 00ec0h, 00ec8h, 00ed0h, 00ed8h
dw 00ee0h, 00ee8h, 00ef0h, 00ef8h, 00effh
dw 00f04h, 00f08h, 00f0ch, 00f10h, 00f14h
dw 00f18h, 00f1ch, 00f20h, 00f24h, 00f28h
dw 00f2ch, 00f30h, 00f34h, 00f38h, 00f3ch
dw 00f40h, 00f44h, 00f48h, 00f4ch, 00f50h
dw 00f54h, 00f58h, 00f5ch, 00f60h, 00f64h
dw 00f68h, 00f6ch, 00f70h, 00f74h, 00f78h
dw 00f7ch, 00f80h, 00f84h, 00f88h, 00f8ch
dw 00f90h, 00f94h, 00f98h, 00f9ch, 00fa0h
dw 00fa4h, 00fa8h, 00fach, 00fb0h, 00fb4h
dw 00fb8h, 00fbch, 00fc0h, 00fc4h, 00fc8h
dw 00fcch, 00fd0h, 00fd4h, 00fd8h, 00fdch
dw 00fe0h, 00fe4h, 00fe8h, 00fech, 00ff0h
dw 00ff4h, 00ff8h, 00ffch, 00fffh

123
LIB386/LIB_SAMP/WAVE.C Normal file
View File

@@ -0,0 +1,123 @@
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
SAMP.C 386
(c) Adeline 1993
*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
#include "\projet\lib386\lib_sys\adeline.h"
#include "\projet\lib386\lib_sys\lib_sys.h"
#include "\projet\lib386\lib_samp\lib_wave.h"
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <i86.h>
char *WaveError = "Error WaveDriver:";
extern void *Wave_listfcts;
extern LONG Wave_Driver_Enable;
ULONG _InitCard( void *Buffer );
void _ClearCard( void );
ULONG _GetBufferSize( void );
void *BUFFER_DMA;
void *END_BUFFER_DMA;
/*-------------------------------------------------------------------------*/
LONG WaveInitDLL(char *driverpathname)
{
char *dll, *drvr;
//
// Load driver file
//
dll = FILE_read( driverpathname, NULL);
if (dll==NULL)
{
printf("%s Could not load driver '%s'.\n", WaveError, driverpathname );
return FALSE ;
}
drvr=DLL_load(dll,DLLMEM_ALLOC | DLLSRC_MEM,NULL);
if (drvr==NULL)
{
printf("%s Invalid DLL image.\n", WaveError );
return FALSE ;
}
Free(dll);
Wave_listfcts = *(void **)drvr;
printf("%s", drvr+4);
return (Wave_Driver_Enable = TRUE);
}
/*-------------------------------------------------------------------------*/
ULONG InitWave()
{
union REGS r;
struct SREGS sr;
void far *fh;
int i;
int IRQ_number;
int kilo_buffer;
ULONG bad_handle[10];
kilo_buffer = _GetBufferSize();
/*- Reserve some space for a sound buffer that doesn't cross a 64K page -*/
// for(i=0; i<10; i++)
// bad_handle[i]=NULL;
i = 0;
do
{
if (!(BUFFER_DMA = DosMalloc( kilo_buffer, &bad_handle[i] )))
{
BUFFER_DMA = NULL;
i+=2;
break;
}
END_BUFFER_DMA = (void *)((ULONG)BUFFER_DMA + kilo_buffer - 1);
if (((LONG)BUFFER_DMA & 0xFFFF0000) != ((LONG)END_BUFFER_DMA & 0xFFFF0000))
{
BUFFER_DMA = NULL;
}
i++;
} while ((BUFFER_DMA == NULL) && (i<=10));
// for(i-=2; i>=0; i--)
// DosFree( bad_handle[i] );
if (BUFFER_DMA == NULL)
{
printf("%s Couldn't allocate a contiguous buffer in DOS memory.\n", WaveError);
return 0;
}
/*----- Init Sound Card (and IRQ controller) ---*/
Wave_Driver_Enable = _InitCard(BUFFER_DMA);
if (!Wave_Driver_Enable)
{
printf("%s Sound card not found.\n", WaveError);
}
return Wave_Driver_Enable;
}
void ClearWave()
{
union REGS r;
struct SREGS sr;
if (!Wave_Driver_Enable)
return;
/*----- Reset Sound Card (and IRQ controller) ---*/
_ClearCard();
}
/*-------------------------------------------------------------------------*/

114
LIB386/LIB_SAMP/WAVE.INC Normal file
View File

@@ -0,0 +1,114 @@
;*--------------------------------------------------------------------------*
;DEBUG equ 1
VOICE_HANDLE equ 1234h
IFDEF SB16
SBLASTER equ 1 ; it is also a SBLASTER !
ENDIF
IFDEF SBPRO
SBLASTER equ 1 ; it is also a SBLASTER !
STEREO equ 1
ENDIF
IFDEF SBLASTER1
SBLASTER equ 1 ; it is also a SBLASTER !
SINGLE_DMA equ 1 ; use DMA (no auto-reinit on the SB ver 1.00-1.99)
ELSEIFDEF SBLASTER
AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner)
ENDIF
IFDEF MWSS
SAMPLE16BIT equ 1
STEREO equ 1
AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner)
ENDIF
IFDEF GOLD
SAMPLE16BIT equ 1
STEREO equ 1
SINGLE_DMA equ 1 ; use DMA (no counter on the card)
ENDIF
IFDEF GUS
AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner)
SAMPLE16BIT equ 1
STEREO equ 1
NOIRQ equ 1
ENDIF
IFDEF PAS16
PAS equ 1
SAMPLE16BIT equ 1
ENDIF
IFDEF PAS
STEREO equ 1
AUTO_DMA equ 1 ; use auto_reinit DMA (faster and cleaner)
BI_OUTPUTMIXER equ 00h ; PAS equates
BI_L_PCM equ 06h
BI_R_PCM equ 0dh
INTRCTLRST equ 0b89h
AUDIOFILT equ 0b8ah
INTRCTLR equ 0b8bh
PCMDATA equ 0f88h
CROSSCHANNEL equ 0f8ah
TMRCTLR equ 138bh
SAMPLERATE equ 1388h
SAMPLECNT equ 1389h
SYSCONF equ 8389h
ENDIF
;*--------------------------------------------------------------------------*
IFDEF SAMPLE16BIT
IFDEF STEREO
SLONG equ 1
SSIZE equ 4
ELSE
SUWORD equ 1
SSIZE equ 2
ENDIF
ELSE
IFDEF STEREO
SUWORD equ 1
SSIZE equ 2
ELSE
SCHAR equ 1
SSIZE equ 1
ENDIF
ENDIF
;*--------------------------------------------------------------------------*
BUFFER_SIZE equ 1024 ; number of samples
; in half-buffer
LIST_SIZE equ 50
STRUCT_SIZE equ 44
SNAP_SIZE equ 8
SHIFT_SAMPLE equ 3 ; max number of
; samples mixed
;*--------------------------------------------------------------------------*

3769
LIB386/LIB_SAMP/WAVE_A.ASM Normal file

File diff suppressed because it is too large Load Diff

6190
LIB386/LIB_SAMP/WAVE_A.LST Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
ASM = ml
#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS
AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=;
LINKDIR = format os2 lx dll
dll: w_pas16.dll w_pas.dll w_gus.dll w_mwss.dll w_sb.dll w_sb2.dll w_sbpro.dll w_sb16.dll w_gold.dll
#
# Wave driver: GF1, Gravis UltraSound
#
w_gus.dll: wave_a.asm gusdig32.obj
$(ASM) $(AFLAGS) /DGUS wave_a.asm
wlink n w_gus.dll f wave_a,gusdig32,pminit_d l gf1_ospm.lib $(LINKDIR)
#
# Wave driver: PAS16
#
w_pas16.dll: wave_a.asm
$(ASM) $(AFLAGS) /DPAS16 wave_a.asm
wlink n w_pas16.dll f wave_a $(LINKDIR)
#
# Wave driver: PAS
#
w_pas.dll: wave_a.asm
$(ASM) $(AFLAGS) /DPAS wave_a.asm
wlink n w_pas.dll f wave_a $(LINKDIR)
#
# Wave driver: AD1848 SoundPort, Microsoft Windows Sound System
#
w_mwss.dll: wave_a.asm
$(ASM) $(AFLAGS) /DMWSS wave_a.asm
wlink n w_mwss.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster
#
w_sb.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSBLASTER1 wave_a.asm
wlink n w_sb.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster 2
#
w_sb2.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSBLASTER wave_a.asm
wlink n w_sb2.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster Pro
#
w_sbpro.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSBPRO wave_a.asm
wlink n w_sbpro.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster 16, STEREO, 16 BIT
#
w_sb16.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSB16 /DSTEREO /DSAMPLE16BIT wave_a.asm
wlink n w_sb16.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster 16, STEREO, 16 BIT, SURROUND
#
w_sb16_s.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSB16 /DSTEREO /DSAMPLE16BIT /DSURROUND wave_a.asm
wlink n w_sb16_s.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster 16, STEREO, 8 BIT
#
w_sb16_8.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSB16 /DSTEREO wave_a.asm
wlink n w_sb16_8.dll f wave_a $(LINKDIR)
#
# Wave driver: Sound Blaster 16, MONO, 16 BIT
#
w_sb16_m.dll: wave_a.asm
$(ASM) $(AFLAGS) /DSB16 /DSAMPLE16BIT wave_a.asm
wlink n w_sb16_m.dll f wave_a $(LINKDIR)
#
# Wave driver: Yamaha Gold, Adlib Gold
#
w_gold.dll: wave_a.asm
$(ASM) $(AFLAGS) /DGOLD wave_a.asm
wlink n w_gold.dll f wave_a $(LINKDIR)

227
LIB386/LIB_SAMP/WAVE_I.ASM Normal file
View File

@@ -0,0 +1,227 @@
;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
; SAMP_A.ASM 386
; (c) Adeline 1993
;*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
;*--------------------------------------------------------------------------*
.386
jumps
.model SMALL, SYSCALL
.DATA
PUBLIC NoLanguage Wave_listfcts
PUBLIC NoLanguage Wave_Driver_Enable
Wave_listfcts dd 0
Wave_Driver_Enable dd 0
.CODE
PUBLIC NoLanguage _InitCard
PUBLIC NoLanguage _ClearCard
PUBLIC NoLanguage WaveAskVars
PUBLIC NoLanguage WavePlay
PUBLIC NoLanguage WaveGiveInfo0
PUBLIC NoLanguage WaveStop
PUBLIC NoLanguage WaveStopOne
PUBLIC NoLanguage WaveInList
PUBLIC NoLanguage WaveGetSnap
PUBLIC NoLanguage WavePause
PUBLIC NoLanguage WaveContinue
PUBLIC NoLanguage WaveSaveState
PUBLIC NoLanguage WaveRestoreState
PUBLIC NoLanguage WaveChangeVolume
PUBLIC NoLanguage WaveGetAddr
PUBLIC NoLanguage _GetBufferSize
PUBLIC NoLanguage WaveChangeVolume
PUBLIC NoLanguage WaveMove
PUBLIC NoLanguage WaveStopOneLong
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
WaveCallFuncs PROC
cmp byte ptr[Wave_Driver_Enable], 0
je return
shl eax, 2
add eax, dword ptr[Wave_listfcts]
jmp dword ptr[eax]
return:
xor eax, eax ; FALSE, NULL or 0
ret
WaveCallFuncs ENDP
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
_InitCard PROC
mov eax, 0
jmp WaveCallFuncs
_InitCard ENDP
;----------------------------------------------------------------------------
_ClearCard PROC
mov eax, 1
jmp WaveCallFuncs
_ClearCard ENDP
;----------------------------------------------------------------------------
WaveAskVars PROC
mov eax, 2
jmp WaveCallFuncs
WaveAskVars ENDP
;*--------------------------------------------------------------------------*
WavePlay PROC
mov eax, 3
jmp WaveCallFuncs
WavePlay ENDP
;----------------------------------------------------------------------------
WaveGiveInfo0 PROC
mov eax, 4
jmp WaveCallFuncs
WaveGiveInfo0 ENDP
;*--------------------------------------------------------------------------*
WaveStop PROC
mov eax, 5
jmp WaveCallFuncs
WaveStop ENDP
;*--------------------------------------------------------------------------*
WaveStopOne PROC
mov eax, 6
jmp WaveCallFuncs
WaveStopOne ENDP
;*--------------------------------------------------------------------------*
WaveInList PROC
mov eax, 7
jmp WaveCallFuncs
WaveInList ENDP
;----------------------------------------------------------------------------
WaveGetSnap PROC
mov eax, 8
jmp WaveCallFuncs
WaveGetSnap ENDP
;*--------------------------------------------------------------------------*
WavePause PROC
mov eax, 9
jmp WaveCallFuncs
WavePause ENDP
;*--------------------------------------------------------------------------*
WaveContinue PROC
mov eax, 10
jmp WaveCallFuncs
WaveContinue ENDP
;----------------------------------------------------------------------------
WaveSaveState PROC
mov eax, 11
jmp WaveCallFuncs
WaveSaveState ENDP
;----------------------------------------------------------------------------
WaveRestoreState PROC
mov eax, 12
jmp WaveCallFuncs
WaveRestoreState ENDP
;----------------------------------------------------------------------------
WaveGetAddr PROC
mov eax, 13
jmp WaveCallFuncs
WaveGetAddr ENDP
;----------------------------------------------------------------------------
_GetBufferSize PROC
mov eax, 14
jmp WaveCallFuncs
_GetBufferSize ENDP
;----------------------------------------------------------------------------
WaveChangeVolume PROC
mov eax, 15
jmp WaveCallFuncs
WaveChangeVolume ENDP
;----------------------------------------------------------------------------
WaveMove PROC
mov eax, 16
jmp WaveCallFuncs
WaveMove ENDP
;----------------------------------------------------------------------------
WaveStopOneLong PROC
mov eax, 17
jmp WaveCallFuncs
WaveStopOneLong ENDP
;----------------------------------------------------------------------------
END