home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
msdos
/
sndbords
/
proaudio
/
pcmtlsrc
/
pcmtlsrc.arj
/
PCM.ARJ
/
_I94F92.INC
< prev
next >
Wrap
Text File
|
1992-09-18
|
13KB
|
579 lines
;$Author: BCRANE $
;$Date: 01 Sep 1992 13:35:00 $
;$Header: X:/sccs/sdkapp/_i94f92.inv 1.3 01 Sep 1992 13:35:00 BCRANE $
;$Log: X:/sccs/sdkapp/_i94f92.inv $
;
; Rev 1.3 01 Sep 1992 13:35:00 BCRANE
;not exactly sure
;
; Rev 1.2 31 Aug 1992 19:10:04 BCRANE
;added check for 16-bit silence
;
; Rev 1.1 31 Aug 1992 09:34:44 BCRANE
;added support for 16-bit
;
; Rev 1.0 29 Jul 1992 16:57:26 BCRANE
;Initial revision.
;$Logfile: X:/sccs/sdkapp/_i94f92.inv $
;$Modtimes$
;$Revision: 1.3 $
;$Workfile: _i94f92.inc $
;; shark functions
;; dx:ax can be used to return values
;; si can be trashed
;; no other precautions taken
if VERBOSE
align 256
db '_i94f92.inc: copyright Media Vision, Inc., 1992', 00h
endif
;; i94f92() - load a sound for later play through keyboard
;; es:bx points to an i94f92buf.
;; intr09() - our int 09 handler
i94f92buf struc
f92snum dw 0
f92xmsh dw 0
f92xmso dd 0
f92xmss dd 0
f92rate dd 0
f92chan dw 0
f92comp dw 0
f92dsiz dw 0
i94f92buf ends
MAXHANDLES equ 64
pd1buf i94f92buf 1 dup (<0,0,0,0,0>)
f92buf i94f92buf MAXHANDLES dup (<0,0,0,0,0>)
pd2buf i94f92buf 1 dup (<0,0,0,0,0>)
ourdmaoff dw 0
ourdmaseg dw 0B000h
ourdmasize dw 1024
ourdmadivs dw 64
ourdivsize dw 1024*16/64
looping db 0
_i94f92 proc near
pushall
mov ax, es ; ds:si has es:bx
mov ds, ax
mov si, bx
mov ax, cs ; es:di has cs:f92buf
mov es, ax
mov di, offset f92buf
mov cx, ds:[si].f92snum ; get sound number (1 through 8)
dec cx ; make 0 through 7
and cx, MAXHANDLES- 1 ; ensure not out of range
mov ax, type i94f92buf ; get size of structure
jcxz f92doneadding ; skip ahead if we want first structure
@@: add di, ax ; point into structure array
loop @B
f92doneadding:
cmp ds:[si].f92xmsh, 0 ; if handle is zero
jnz @F
mov ds:[si].f92snum, 0 ; then zero out the number (delete entry)
@@: mov cx, ax ; cx has size of structure
rep movsb ; store this guy
popall
ret
_i94f92 endp
int09_semaphore db -1
lastinptr dw 0
@kb_flag equ 017h
@buffer_head equ 01Ah
@buffer_tail equ 01Ch
@kb_buffer equ 01Eh
@kb_end equ @kb_buffer+(16*2)
routine1code dw 0203h ; scancode for '1' SHL 16 + (Left Shift| Right Shift)
routine2code dw 0303h ; scancode for '2' SHL 16 + (Left Shift| Right Shift)
routine3code dw 0403h ; scancode for '3' SHL 16 + (Left Shift| Right Shift)
routine4code dw 0503h ; scancode for '4' SHL 16 + (Left Shift| Right Shift)
routine5code dw 0603h ; scancode for '5' SHL 16 + (Left Shift| Right Shift)
routine6code dw 0703h ; scancode for '6' SHL 16 + (Left Shift| Right Shift)
routine7code dw 0803h ; scancode for '7' SHL 16 + (Left Shift| Right Shift)
routine8code dw 0903h ; scancode for '8' SHL 16 + (Left Shift| Right Shift)
routine1spec dw 0207h ; scancode for '1' SHL 16 + (Left Shift| Right Shift| Control)
intr09 proc far
assume ds:nothing
assume es:nothing
pushf
inc word ptr cs:id09.cnt
popf
pushf
sti
call dword ptr cs:id09.vold
push bx
push ds
mov bx, 40h
mov ds, bx
mov bx, ds:[@buffer_tail]
cmp bx, ds:[@buffer_head]
jnz @F
pop ds
pop bx
iret
@@:
sub bx, 2
cmp bx, @kb_buffer
jge @F
mov bx, @kb_end-2
@@:
push ax
push dx
mov ax, ds:[bx]
mov al, ds:[@kb_flag]
and al, 0Fh
lea dx, routine
cmp ax, cs:[routine1code]
jz ouin09_doit
cmp ax, cs:[routine2code]
jz ouin09_doit
cmp ax, cs:[routine3code]
jz ouin09_doit
cmp ax, cs:[routine4code]
jz ouin09_doit
cmp ax, cs:[routine5code]
jz ouin09_doit
cmp ax, cs:[routine6code]
jz ouin09_doit
cmp ax, cs:[routine7code]
jz ouin09_doit
cmp ax, cs:[routine8code]
jz ouin09_doit
cmp ax, cs:[routine1spec]
jnz ouin09_done
ouin09_doit:
mov ds:[@buffer_tail], bx
inc cs:[int09_semaphore]
jnz ouin09_almostdone
push cs
pop ds
assume ds:_text
sti
call dx
ouin09_almostdone:
dec cs:[int09_semaphore]
ouin09_done:
pop dx
pop ax
ouin09_exit:
pop ds
pop bx
iret
intr09 endp
xmsmovestruc struc
xmssize dd 0
xmssrch dw 0
xmssrco dd 0
xmstrgh dw 0
xmstrgo dd 0
xmsmovestruc ends
xmsm xmsmovestruc <0,0,0,0,0>
xmsdriver dd 0
ourf92buf dw 0
ourbyteleft dd 0
ourxmshandle dw 0
ourxmsoff dd 0
ourblockcount dw 0
ourblockoffset dw 0
align 32
db 'OURSTATFLAG:'
ourstatflag dw 0
oursemaphore dw -1
oursavedss dw 0
oursavedsp dw 0
ourstackstart label near
dw 100h dup (0)
ourstack label near
;; ax has scancode "010Ch, 020Ch ...", so (ah-2)* 2 is offset into xmshandles
routine proc
inc cs:oursemaphore ; no reentrancy
jz @F
jmp alreadyhere
@@: cli
mov cs:oursavedss, ss ; our stack
mov cs:oursavedsp, sp
mov sp, cs
mov ss, sp
mov sp, offset ourstack
sti
pushall ; save everything
push ds
push cs
pop ds ; ds= cs
cmp ourdmaseg, 0 ; do we have a current DMA buffer?
jnz @F ; yes, continue
jmp notloaded ; no, exit
@@: push ax ; save ax
call StopPCM ; in case we are playing
call RemovePCM
call InitPCM
xor ax, ax
mov word ptr ourbyteleft[0], ax ; initialize everything to zero
mov word ptr ourbyteleft[2], ax
mov ourxmshandle, ax
mov word ptr ourxmsoff[0], ax
mov word ptr ourxmsoff[2], ax
mov ourstatflag, ax
mov ourblockcount, ax
mov word ptr [xmsm].xmssize[0], ax
mov word ptr [xmsm].xmssize[2], ax
mov [xmsm].xmssrch, ax
mov word ptr [xmsm].xmssrco[0], ax
mov word ptr [xmsm].xmssrco[2], ax
mov [xmsm].xmstrgh, ax
mov word ptr [xmsm].xmstrgo[0], ax
mov word ptr [xmsm].xmstrgo[2], ax
pop ax ; ax has keystroke
mov looping, 0
test al, 04h ; control key also?
jz @F
mov looping, 1
@@:
mov al, ah ; al= scancode (2 through 9)
sub al, 2 ; al= 0 through 7
and al, 07h ; ensure
mov ah, type i94f92buf ; size of structure
mul ah ; al= offset into structure array
cbw ; ax= offset into structure array
mov bx, ax ; bx= offset into structure array
add bx, offset f92buf
mov ourf92buf, bx ; save pointer to structure
mov ax, [bx].f92xmsh ; xmshandle
or ax, ax ; set?
jnz @F ; yes, continue
jmp notloaded ; no, exit
@@: mov ourxmshandle, ax ; our xmshandle
mov ax, word ptr [bx].f92xmso[0] ; get xmsoffset
mov dx, word ptr [bx].f92xmso[2]
mov word ptr ourxmsoff[0], ax
mov word ptr ourxmsoff[2], dx
mov ax, word ptr [bx].f92xmss[0]; get size of sound
mov dx, word ptr [bx].f92xmss[2]
mov word ptr ourbyteleft[0], ax ; store in remaining counter
mov word ptr ourbyteleft[2], dx
mov ax, [bx].f92dsiz ; datasize
cmp ax, 8
jz @F
cmp ax, 16
jz @F
cmp ax, 12
jz @F
cmp ax, 24
jz @F
mov ax, 8
@@: push ax
mov ax, [bx].f92comp ; compression
cmp ax, 0
jz @F
cmp ax, 1
jz @F
cmp ax, 2
jz @F
xor ax, ax
@@: push ax
mov ax, [bx].f92chan ; get channel count
dec ax ; convert to mono/stero flag
push ax
mov ax, word ptr [bx].f92rate[2]; get samplerate
push ax
mov ax, word ptr [bx].f92rate[0]
push ax
call PCMInfo ; tell internals
add sp, 10 ; sp= -6
mov ax, ourdmadivs ; number of divisions in dma buffer
push ax
mov ax, ourdmasize ; size of dma buffer in paragraphs
shl ax, 1
shl ax, 1
shl ax, 1
shl ax, 1 ; converted to bytes
push ax
mov ax, ourdmaseg ; address of dma buffer
push ax
mov ax, ourdmaoff
push ax
call DMABuffer ; tell internals
add sp, 8
mov dx, word ptr ourbyteleft[2] ; get size of data to process
mov ax, word ptr ourbyteleft[0]
mov cx, ourdmasize ; size of dma buffer in paragraphs
shl cx, 1
shl cx, 1
shl cx, 1
shl cx, 1 ; converted to bytes
or cx, cx ; if cx is zero, 64K dma size
jnz f94sub ; no special subtraction
stc ; force borrow
jmp @F ; subtract from hiword
f94sub:
sub word ptr ourbyteleft[0], cx ; adjust amount remaining
@@: sbb word ptr ourbyteleft[2], 0 ;
jnc @F ; not negative, continue
mov word ptr ourbyteleft[0], 0 ; done with this buffer
mov word ptr ourbyteleft[2], 0 ; fix this (fill with silence)
mov bx, ourf92buf
mov cx, word ptr [bx].f92xmss[0]; get original size
@@: mov ax, cx ; ax= amount to be moved
or ax, ax ; if zero, dma size is 64K
jnz f94add
stc ; force carry
jmp @F
f94add:
add word ptr ourxmsoff[0], ax ; point into xms data for future
@@: adc word ptr ourxmsoff[2], 0
or ax, ax ; if ax is zero, 64K dma size
jnz f94inc
dec ax ; this is okay
f94inc:
@@: inc ourstatflag ; affect dma div counter
inc ourblockcount
sub ax, ourdivsize ; subtract out divsize of data
ja @B ; if not zero or negative, again
@@: mov word ptr [xmsm].xmssize[0], cx ; size to move from XMS
mov word ptr [xmsm].xmssize[2], 0
mov ax, ourxmshandle
mov [xmsm].xmssrch, ax ; XMS handle
mov word ptr [xmsm].xmssrco[2], 0 ; XMS offset is zero
mov word ptr [xmsm].xmssrco[0], 0
mov [xmsm].xmstrgh, 0 ; target is not XMS
mov dx, ourdmaseg ; target is DMA buffer
mov ax, ourdmaoff
mov word ptr [xmsm].xmstrgo[2], dx
mov word ptr [xmsm].xmstrgo[0], ax
mov ax, 4310h ; get address of handler
int 2Fh
mov word ptr [xmsdriver][0], bx
mov word ptr [xmsdriver][2], es
mov si, offset xmsm
mov ah, 0Bh
call dword ptr [xmsdriver] ; call xms handler
mov ax, offset newufroutine ; interrupt handler
push cs
push ax
call UserFunc
add sp, 4
call PCMPlay ; play it
notloaded:
pop ds ; exiting, restore
popall
cli
mov ss, cs:oursavedss ; restore stack
mov sp, cs:oursavedsp
sti
alreadyhere:
dec cs:oursemaphore ; we are done
ret
routine endp
ufroutine proc far
push ds
push cs
pop ds
inc ourblockcount
dec ourstatflag
jnz @F
call StopPCM
@@: pop ds
retf
ufroutine endp
newufroutine proc far
inc cs:oursemaphore ; no reentrancy
jz @F
dec cs:oursemaphore
retf
@@: cli
mov cs:oursavedss, ss ; set up our stack
mov cs:oursavedsp, sp
mov sp, cs
mov ss, sp
mov sp, offset ourstack
sti
push ax ; save dx:ax
push dx
pushall ; save everything else
push ds ; save in case
push cs
pop ds ; ds= cs
cmp looping, 0 ; looping?
jz @F ; no, continue
jmp ufdone ; yes, we are done
@@:
dec ourstatflag ; processed one
jnz @F ; continue if not too slow
call StopPCM ; we fell behind
jmp ufdone ; we are done
@@: mov ax, word ptr ourbyteleft[0] ; get remaining size
@@: mov dx, word ptr ourbyteleft[2]
or ax, ax
jnz @F ; continue if something left
or dx, dx
jnz @F
jmp ufdone ; nothing left, we are done
@@: mov cx, ourdivsize ; get size of a division
sub ax, cx ; subtract from remaining size
sbb dx, 0
jnb @F ; continue if not negative
xor ax, ax ; else zero it out
xor dx, dx
@@: mov word ptr ourbyteleft[0], ax ; store new remaining count
mov word ptr ourbyteleft[2], dx
mov ax, cx ; ax= size of division
mov word ptr [xmsm].xmssize[0], ax ; size of XMS move
mov word ptr [xmsm].xmssize[2], 0
mov ax, ourxmshandle
mov [xmsm].xmssrch, ax ; XMS handle
mov ax, word ptr ourxmsoff[0] ; offset into XMS memory
mov dx, word ptr ourxmsoff[2]
mov word ptr [xmsm].xmssrco[0], ax ; store in XMS move structure
mov word ptr [xmsm].xmssrco[2], dx
add ax, cx ; add this size to XMS offset
adc dx, 0
mov word ptr ourxmsoff[0], ax ; save offset into XMS for future
mov word ptr ourxmsoff[2], dx
mov [xmsm].xmstrgh, 0 ; target is not XMS
mov ax, ourblockcount ; count of divisions processed so far
mov bx, ourdmadivs ; get block count modulo divisions
xor dx, dx
or bx, bx
jnz @F
inc bx ; default two divisions
inc bx
@@: div bx ; blockcount/divcount
mov ax, dx ; ax= remainder
mov bx, ourdivsize ; get offset into dma buffer
mul bx
add ax, ourdmaoff ; add to address of dma buffer
mov dx, ourdmaseg
mov word ptr [xmsm].xmstrgo[0], ax ; offset into DMA buffer
mov word ptr [xmsm].xmstrgo[2], dx
mov di, ourf92buf
mov al, 80h
cmp [di].f92dsiz, 8
jz @F
xor al, al
@@: mov ah, al
mov di, ax
mov es, dx
shr cx, 1
rep stosw
mov ax, 4310h
int 2Fh
mov word ptr [xmsdriver][0], bx
mov word ptr [xmsdriver][2], es
mov si, offset xmsm
mov ah, 0Bh
call dword ptr [xmsdriver] ; move XMS to DMA
inc ourblockcount ; done this one
inc ourstatflag ; added another
ufdone: pop ds ; restore
popall ; restore the rest
pop dx ; restore dx:ax, too
pop ax
cli
mov ss, cs:oursavedss ; restore stack
mov sp, cs:oursavedsp
sti
dec cs:oursemaphore ; we are done
retf
newufroutine endp