home *** CD-ROM | disk | FTP | other *** search
- ;[]------------------------------------------------------------------------[]
- ;| |
- ;| (c) 1993,1994 by Marc van Shaney , aka Kaya Memisoglu |
- ;| |
- ;| Dieser Assembler-Source-Code unterliegt dem Urheberrecht von Kaya |
- ;| Memisoglu und darf auch nur mit seiner schriftlichen Genehmigung |
- ;| in kommerziellen Programmen verwendet werden. |
- ;| Ich übernehme keinerlei Verantwortung für eventuelle Schäden,die dieses |
- ;| Programm verursacht. |
- ;| |
- ;| |
- ;| |
- ;| 18.1.1994 Kaya Memisoglu |
- ;| |
- ;[]------------------------------------------------------------------------[]
-
- ; !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
- ; !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
- ;
- ; I DO NOT SAVE THE REGISTER VARIABLES SI AND DI IN THIS CODE AND IN SOME
- ; OTHER MODULES. SO MAKE SURE BEFORE COMPILING THIS CODE THAT THE REGISTER
- ; VARIABLES IN BORLAND C ARE SET TO *NONE*.
- ; BUT IF YOU STILL WANT TO USE THEM, YOU HAVE TO SAVE THEM BY CHANGING THIS
- ; CODE !!!
- ;
- ; !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
- ; !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
-
- ;The Sound_Block structure:
- ; word Sample_rate
- ; word Sample_Size
- ; byte Bits_per_Sample
- ; byte Channels
- ; 10 bytes resreved
- ;
- ;The following external MACROS can be defined
- ; EXTERNAL_ROUTINES
- ; DRV_NAME - Only if you want to link the driver !!!
- ; DRV_INIT
- ; DRV_EXIT
- ; DRV_TEXT
- ; DRV_VERSION
- ; VOICE_INIT
- ; VOICE_STOP
- ; VOICE_START
- ; VOICE_OUT
-
-
-
- P386
- LOCALS
-
- MAJOR_VERSION equ 3
- SAMPLE_RATE equ 0
- SAMPLE_SIZE equ 2
- TRUE equ 1
- FALSE equ -1
-
- SOUND_CAN_PLAY equ 1
- SOUND_CAN_RECORD equ 2
- SOUND_CAN_STEREO equ 4
- SOUND_CAN_MONO equ 8
- SOUND_CAN_8BIT equ 16
- SOUND_CAN_16BIT equ 32
- SOUND_USES_TIMER equ 64
-
- SOUND_READY equ 2
- SOUND_PLAYING equ 1
- SOUND_RECORDING equ 4
-
- ifndef DRV_NAME
- .MODEL USE16 TINY
- .Code
-
- ORG 0004h ;Bei einem MALLOC ist der Offset immer 4 ! (Hoffentlich !!!)
- PUBLIC C DISPATCH
- DISPATCH PROC FAR
- DB 'Cyberdyne Driver',0,' ' ; 32 Bytes
- DB 'SOUND',0,' ' ;16 Bytes
- DB DRV_TEXT ; 32 Bytes
- DW 256*MAJOR_VERSION+DRV_VERSION ;Version
- DW 9 ;Anzahl der Funktionen (und damit
- ; Segmentpräfixe !!!)
- DW Config_Info
- DW ?
-
- DW Init_Driver
- DW ?
- DW Exit_Driver
- DW ?
- DW Play_Voice
- DW ?
- DW Stop_Voice
- DW ?
- DW Record_Voice
- DW ?
- DW Set_Play_Handler
- DW ?
- DW Set_Record_Handler
- DW ?
- DW Set_Next_Block
- DW ?
- DD SOUND_CAN_PLAY or SOUND_CAN_MONO or SOUND_CAN_8BIT or SOUND_USES_TIMER
- DW 0
- DW 44000
-
-
- Status DW ?
- Data_Adress DD ?
- Data_Size DW ?
-
- IntOffset DW ?
- IntSegment DW ?
-
- Play_Handler DD 0
- Record_Handler DD 0
- Voice_Rate DW ?
- Timer_Constant DW ?
-
- Next_Block DD 0
- Busy db ?
- DISPATCH ENDP
-
-
- else
-
-
- .MODEL USE16 LARGE
- .Data
- DRV_NAME
-
-
- .Code
- DISPATCH PROC FAR
- DB 'Cyberdyne Driver',0,' ' ; 32 Bytes
- DB 'SOUND',0,' ' ;16 Bytes
- DB DRV_TEXT ; 32 Bytes
- DW 256*MAJOR_VERSION+DRV_VERSION ;Version
- DW 9 ;Anzahl der Funktionen (und damit
- ; Segmentpräfixe !!!)
- DW Config_Info
- DW SEG Config_Info
-
- DW Init_Driver
- DW SEG Config_Info
- DW Exit_Driver
- DW SEG Config_Info
- DW Play_Voice
- DW SEG Config_Info
- DW Stop_Voice
- DW SEG Config_Info
- DW Record_Voice
- DW SEG Config_Info
- DW Set_Play_Handler
- DW SEG Config_Info
- DW Set_Record_Handler
- DW SEG Config_Info
- DW Set_Next_Block
- DW SEG Config_Info
-
- DD SOUND_CAN_PLAY or SOUND_CAN_MONO or SOUND_CAN_8BIT or SOUND_USES_TIMER
- DW 0
- DW 44000
-
-
- Status DW ?
- Data_Adress DD ?
- Data_Size DW ?
-
- IntOffset DW ?
- IntSegment DW ?
-
- Play_Handler DD 0
- Record_Handler DD 0
- Voice_Rate DW ?
- Timer_Constant DW ?
-
- Next_Block DD 0
- Busy db ?
- DISPATCH ENDP
- endif
-
-
- ifdef EXTERNAL_ROUTINES
- EXTERNAL_ROUTINES
- endif
-
-
-
- Init_Driver PROC FAR
- cli
- mov ah,35h
- mov al,8 ;Timer-Interrupt
- int 21h ;Alten Vector ermitteln
- sti
- mov cs:[IntOffset],bx
- mov cs:[IntSegment],es
- mov cs:[Play_Handler],0
- mov cs:[Record_Handler],0
- mov cs:[Status],0
-
- ifdef DRV_INIT
- DRV_INIT
- endif
-
- mov ax,TRUE
- retf
- Init_Driver ENDP
-
-
-
-
-
- Exit_Driver PROC FAR
- cli
- mov ah,25h
- mov al,8
- push ds
- mov ds,cs:[IntSegment]
- mov dx,cs:[IntOffset]
- int 21h ;Vector setzen
- pop ds
- mov al,36h
- out 43h,al
- mov dx,40h
- mov al,0ffh
- out dx,al
- out dx,al
- sti
- ifdef DRV_EXIT
- DRV_EXIT
- endif
- mov ax,TRUE
- retf
- Exit_Driver ENDP
-
-
-
-
-
-
-
- Play_Voice PROC FAR
- ARG Data:dword
- push bp
- mov bp,sp
- cli
-
- les si,[Data]
- mov bx,es:[si+SAMPLE_RATE]
- mov cs:[Voice_Rate],bx
- mov dx,12h
- mov ax,3333h
- div bx
- mov cs:[Timer_Constant],ax
- mov ax,es:[si+SAMPLE_SIZE]
- mov cs:[Data_Size],ax
- mov eax,[Data]
- add eax,16
- mov word ptr cs:[DOffset-2],ax
- mov cs:[Data_Adress],eax
- mov cs:[Next_Block],0
-
- ifdef VOICE_INIT
- VOICE_INIT
- endif
-
- mov ah,25h
- mov al,8
- push ds
- push cs
- pop ds
- mov dx,OFFSET Play_Interrupt
- int 21h ;Vector setzen
- pop ds
-
- mov cs:[Busy],0
- mov cs:[Status],SOUND_READY or SOUND_PLAYING
-
- mov al,36h
- out 43h,al
- mov ax,cs:[Timer_Constant]
- out 40h,al
- shr ax,8
- out 40h,al ;Geschwindigkeit setzen
-
- ifdef VOICE_START
- VOICE_START
- endif
-
- pop bp
- sti
- retf
- Play_Voice ENDP
-
-
-
-
-
-
- Stop_Voice PROC FAR
- cli
- mov al,36h
- out 43h,al
- mov al,0ffh
- out 40h,al
- out 40h,al
- mov ah,25h
- mov al,8
- push ds
- mov ds,cs:[IntSegment]
- mov dx,cs:[IntOffset]
- int 21h ;Vector setzen
- pop ds
-
- and cs:[Status],0ffffh-SOUND_PLAYING-SOUND_RECORDING
- mov cs:[Data_Size],0
- mov cs:[Data_Adress],0ffffffffh
-
- ifdef VOICE_STOP
- VOICE_STOP
- endif
-
- sti
- retf
- Stop_Voice ENDP
-
-
-
-
-
-
- Record_Voice PROC FAR
- retf
- Record_Voice ENDP
-
-
-
-
- Record_Interrupt PROC FAR
- iret
- Record_Interrupt ENDP
-
-
-
-
- Play_Interrupt PROC FAR
- push eax
- push ds
-
- mov ds,word ptr cs:[Data_Adress+2]
- mov al,ds:[1234h]
- DOffset:
- inc word ptr cs:[DOffset-2]
-
- VOICE_OUT
-
- mov al,20h
- out 20h,al
-
- dec cs:[Data_Size]
- jz short EndeDMA
-
- pop ds
- pop eax
- iret
-
-
- EndeDMA:
- cmp cs:[Next_Block],0
- je No_Second_Block
- push bx
- lds bx,cs:[Next_Block]
- mov ax,ds:[bx+SAMPLE_SIZE]
- mov cs:[Data_Size],ax
- mov eax,cs:[Next_Block]
- add eax,16
- mov word ptr cs:[DOffset-2],ax
- mov cs:[Data_Adress],eax
- sti
- pop bx
- mov cs:[Next_Block],0
- cmp cs:[Play_Handler],0
- jne short Call_User
- pop ds
- pop eax
- iret
-
- No_Second_Block:
- pushad
- push es
- call Stop_Voice
- cmp cs:[Play_Handler],0
- je short Cont_Output
- cmp cs:[Busy],1
- je short @@1
- mov cs:[Busy],1
- call cs:[Play_Handler]
- mov cs:[Busy],0
- @@1:
- pop es
- popad
- pop ds
- pop eax
- iret
-
- Call_User:
- pushad
- push es
- cmp cs:[Busy],1
- je short @@2
- mov cs:[Busy],1
- call cs:[Play_Handler]
- mov cs:[Busy],0
- cmp ax,0
- jge short Cont_Output
- call Stop_Voice
-
- Cont_Output:
- @@2: pop es
- popad
- pop ds
- pop eax
- iret
- Play_Interrupt ENDP
-
-
-
-
- Set_Play_Handler PROC FAR
- ARG handler:dword
- push bp
- mov bp,sp
-
- mov eax,[handler]
- mov cs:[Play_Handler],eax
-
- pop bp
- retf
- Set_Play_Handler ENDP
-
-
-
-
-
- Set_Record_Handler PROC FAR
- ARG handler:dword
- push bp
- mov bp,sp
-
- mov eax,[handler]
- mov cs:[Play_Handler],eax
-
- pop bp
- retf
- Set_Record_Handler ENDP
-
-
-
-
-
-
- Set_Next_Block PROC FAR
- ARG Data:dword
- push bp
- mov bp,sp
-
- mov eax,[Data]
- mov cs:[Next_Block],eax
-
- pop bp
- retf
- Set_Next_Block ENDP
-