dhoelzer@gnu.ai.mit.edu (David S. Hoelzer) (05/19/91)
Submitted-by: David S. Hoelzer <dhoelzer@gnu.ai.mit.edu>
Posting-number: Volume 19, Issue 95
Archive-name: pvoc/part01
PVOC is assembler source code to play SoundBlaster VOC files on an
IBM PC with a SoundBlaster card using double buffering..
-------------------------------------------------------------------------------
dhoelzer@gnu.ai.mit.edu | If we shadows have offended, Think but this
paladin!dhoelzer@uunet.uu.net | and all is mended, That you have but slum-
| bered here Whilst these shadows did appear.
-------------------------------------------------------------------------------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then feed it
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: PVOC.EXE
# Wrapped by kent@sparky on Sat May 18 13:27:16 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive."'
if test -f 'PVOC.EXE' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'PVOC.EXE'\"
else
echo shar: Extracting \"'PVOC.EXE'\" \(11754 characters\)
sed "s/^X//" >'PVOC.EXE' <<'END_OF_FILE'
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X;
X; PVOC.EXE
X; Public Domain VOC file player
X;
X; Please feel free to distribute or use this code
X; according to the following restrictions:
X;
X; 1)This code must be distributed AS-IS. Do not remove or change
X; any part/parts of it. If you find a way to do something better, send
X; me a copy of what you've done and I'll release the update and you'll
X; get the credit. Otherwise there will be 180000 versions and no way
X; to support them.
X;
X; 2)You may modify this code or use any piece of it for your own
X; purposes, but you must inform the end user that this code is Public
X; Domain, who wrote it, and where to get it.
X;
X; 3)If you need a piece of this for a commercial or shareware something
X; that you are working on, drop me a message and we'll discuss it. There
X; wont be a charge, but I'd appreciate a mention and perhaps a copy of what
X; you write.
X;
X; 4)Go crazy.
X;
X; CopyRight (C) 1991, All Rights Reserved
X; David Hoelzer
X;
X; I can be reached at:
X; dhoelzer@gnu.ai.mit.edu
X; SnailMail:
X; Everest Systems
X; Suite 180, 16 Campus Plaza
X; Box 2000
X; Vestal, NY 13850
X; ATTN: D. Hoelzer
X;
X;
X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
X
X;As it is now:
X; Compile normally, but link with /CP:5000 (Works good for me) to allow
X; the program to allocate more memory.
X; Simply stick pvoc.exe in the path and ct-voice.drv in c:\
X; Now just type PVOC SOUNDFILE.VOC. Pathnames should work as well.
X;
X; The program now uses two 30k(~) buffers to output the file
X; continuously. I have had a few minor problems and unexplained crashes,
X; but I feel that they are caused by my unusual setup.
X;
X; NOTE: If your interrupt settings are not the factory defaults,
X; you must change them in ct-voice yourself with inst-drv(I think..)
X
X
X;Future Stuffs:
X;
X
X
X
XSTACKSEG SEGMENT PARA STACK
X DB 256 DUP (?)
XSTACKSEG ENDS
X
XDATA SEGMENT PUBLIC WORD 'Data'
X
XPARAMLENGTH EQU 80H
XPARAMSTART EQU 81H
X
XSOUNDDRIVER DW 0
XDRIVERSEGMENT DW ?
XVOICEFILESEG DW ?
XVOICEFILESEG2 DW ?
XVOICEOFFSET DW 0
XMEMERROR DB 'Memory Allocation Error.',13,10,'$'
XF_MESSAGE DB 'Error opening file: '
XFILENAME DB ' ',0,13,10
X DB 'Format: PVOC SOUNDFILE.VOC',13,10,'$'
XDRIVERFILE DB 'c:\CT-VOICE.DRV',0
XFILEHANDLE DW ?
XDRIVERFILEERR DB 'Voice Driver not found!',13,10,'$'
XD_MESSAGE DB 'Sound Card Initialization Error.',10,13,'$'
XCARDSTATUS DW 0FFFFh
XMORE DW 1
XSTARTUPMESSAGE DB 'Play Voc - Public Domain',13,10
X DB 'Version 1.1 -'
X DB ' Copyright (C) 1991, All Rights Reserved',13,10
X DB ' David Hoelzer',13,10,'$'
XDATA ENDS
X
XCODE SEGMENT PUBLIC BYTE 'Code'
X ASSUME CS:CODE, SS:STACKSEG, DS:DATA
X
XMAIN PROC FAR
X PUSH DS ;Set up for return
X XOR AX,AX
X PUSH AX
X MOV AX,DATA
X MOV DS,AX
X LEA DX,STARTUPMESSAGE
X MOV AH,9
X INT 21H
X MOV AH,81
X INT 21H
X MOV ES,BX
X XOR CX,CX
X MOV CL,ES:[PARAMLENGTH]
X JCXZ A1
X CALL GET_PARAMS
XA1: CALL ALLOCATEBUFFERS
X JC EXIT
X CALL LOADDRIVER
X JC EXIT
X CALL INITIALIZEDRIVER
X JC EXIT
X CALL OPENSOUNDFILE
X JC EXIT
X CALL PLAYSOUND
X CALL SHUTDOWNCARD
XEXIT: RETF
XMAIN ENDP
X
XSHUTDOWNCARD PROC NEAR
XWAITLOOP:
X MOV BX,CARDSTATUS
X CMP BX,0
X JNZ WAITLOOP
X MOV BX,8
X CALL DWORD PTR SOUNDDRIVER
X MOV BX,9
X CALL DWORD PTR SOUNDDRIVER
X RET
XSHUTDOWNCARD ENDP
X
XGET_PARAMS PROC NEAR
X MOV BX,PARAMSTART
X LEA DI,FILENAME
XL_1: MOV AH,ES:[BX]
X CMP AH,32
X JZ CONTINUELOOP
X MOV [DI],AH
X INC DI
XCONTINUELOOP:
X INC BX
X LOOP L_1
X RET
XGET_PARAMS ENDP
X
XALLOCATEBUFFERS PROC NEAR
X MOV AX,4800H
X MOV BX,0100H ;100h paragraphs
X INT 21H
X JC ERROR
X MOV DRIVERSEGMENT,AX
X MOV AH,48H
X MOV BX,0800H ;FAA pararaphs
X INT 21H
X JC ERROR
X MOV VOICEFILESEG,AX
X MOV AH,48H
X MOV BX,0800H ;FAA pararaphs
X INT 21H
X JC ERROR
X MOV VOICEFILESEG2,AX
X CLC
X RET
XERROR: LEA DX,MEMERROR
X MOV AH,9
X INT 21H
X STC
X RET
XALLOCATEBUFFERS ENDP
X
XINITIALIZEDRIVER PROC NEAR
X MOV BX,3
X CALL DWORD PTR SOUNDDRIVER ;Init Driver call
X CMP AX,0
X JNZ DRIVER_ERROR
X MOV BX,4 ;Turn on speaker
X MOV AL,1
X CALL DWORD PTR SOUNDDRIVER
X MOV AX,DS ;Set status word
X MOV ES,AX
X MOV DI, OFFSET CARDSTATUS
X MOV BX,5
X CALL DWORD PTR SOUNDDRIVER
X CLC
X RET
XDRIVER_ERROR:
X LEA DX,D_MESSAGE
X MOV AH,9
X INT 21H
X STC
X RET
XINITIALIZEDRIVER ENDP
X
XOPENSOUNDFILE PROC NEAR
X MOV AH,3DH ;Open File
X MOV AL,0
X LEA DX,FILENAME
X INT 21H
X JC FOPEN_ERROR
X MOV FILEHANDLE,AX
X MOV AH,3FH ;Read File
X MOV BX,FILEHANDLE
X MOV CX,1AH ;1A Bytes
X PUSH DS
X MOV DX,VOICEFILESEG
X MOV DS,DX
X MOV DX,0 ;To offset 0
X INT 21H ;Read them
X POP DS
X CLC
X RET
XFOPEN_ERROR:
X LEA DX,F_MESSAGE
X MOV AH,9
X INT 21H
X STC
X RET
XOPENSOUNDFILE ENDP
X
XLOADDRIVER PROC NEAR
X MOV AH,3DH ;Open File
X MOV AL,0
X LEA DX,DRIVERFILE
X INT 21H
X JC ERROR_D
X MOV FILEHANDLE,AX ;NOW ACTUALLY READ THE DRIVER
X MOV BX,FILEHANDLE
X MOV AX,DRIVERSEGMENT
X MOV CX,5000 ;5000 Bytes - This is larger
X MOV DX,0 ;than the file.
X PUSH DS
X MOV DS,AX
X MOV AH,3FH ;Read File Function
X INT 21H
X POP DS
X MOV AH,3EH ;Close File
X MOV BX,FILEHANDLE
X INT 21H
X CLC
X RET
XERROR_D:
X LEA DX,DRIVERFILEERR
X MOV AH,9
X INT 21H
X MOV AH,3EH
X MOV BX,FILEHANDLE
X INT 21H
X STC
X RET
XLOADDRIVER ENDP
X
XPLAYSOUND PROC NEAR
X MOV AX,VOICEFILESEG
X MOV ES,AX
X MOV AX,VOICEFILESEG2
X PUSH DS
X MOV DS,AX
X MOV CX,100 ;Clear 100 locations just
X XOR AX,AX ;to be safe
X MOV BX,30000 ;Offset after Voice data
XFILLBYTES:
X MOV ES:[BX],AX
X MOV DS:[BX],AX
X INC BX
X LOOP FILLBYTES
X POP DS
X MOV AH,3FH ;Read File
X MOV BX,FILEHANDLE
X MOV CX,6 ;6 bytes
X PUSH DS ;These are the block number,
X MOV DX,VOICEFILESEG ;file size, sampling rate and
X MOV DS,DX ;encoding method.
X MOV DX,0 ;Load to DS:0
X INT 21H
X POP DS
X MOV AX,VOICEFILESEG
X MOV BX,VOICEFILESEG2
X PUSH DS
X MOV DS,AX
X MOV ES,BX
X MOV CX,6
X MOV SI,0
X MOV DI,SI
X CLD
X REP MOVSB
X POP DS
X
XLOOP1: MOV CX,30000 ;30000 Bytes
X MOV BX,FILEHANDLE
X MOV AX,3F00H ;Read File
X MOV DX,VOICEFILESEG
X PUSH DS
X MOV DS,DX
X MOV DX,6 ;Load to DS:6
X INT 21H
X POP DS
X CMP AX,CX ;Check number of Bytes Read
X JZ CONT
X MOV DX,0 ;Set more to 0 at EOF
X MOV MORE,DX
XCONT: MOV BX,1 ;File Size location
X MOV CX,VOICEFILESEG
X MOV ES,CX
X MOV ES:[BX],AL ;File Size High byte
X INC BX
X MOV ES:[BX],AH ;File Size Low byte
X INC BX
X MOV CX,0
X MOV ES:[BX],CL ;File Size Last byte
X MOV DI,0 ;Offset of voice block
XALOOP2: MOV BX,CARDSTATUS ;Wait for voice to finish
X CMP BX,0 ;playing.
X JNZ ALOOP2
X MOV BX,6 ;Play Voice
X CALL DWORD PTR SOUNDDRIVER
X MOV AX,MORE
X CMP AX,1 ;Should we continue?
X JNZ FINISH
X JMP BLOOP1
X
XGOBACK: JMP LOOP1 ;A little kludge to jump back
X
XBLOOP1: MOV CX,30000 ;30000 Bytes
X MOV BX,FILEHANDLE
X MOV AX,3F00H ;Read File
X MOV DX,VOICEFILESEG2
X PUSH DS
X MOV DS,DX
X MOV DX,6 ;Load to DS:6
X INT 21H
X POP DS
X CMP AX,CX ;Check number of Bytes Read
X JZ BCONT
X MOV DX,0 ;Set more to 0 at EOF
X MOV MORE,DX
XBCONT: MOV BX,1 ;File Size location
X MOV CX,VOICEFILESEG2
X MOV ES,CX
X MOV ES:[BX],AL ;File Size High byte
X INC BX
X MOV ES:[BX],AH ;File Size Low byte
X INC BX
X MOV CX,0
X MOV ES:[BX],CL ;File Size Last byte
X MOV DI,0 ;Offset of voice block
XBLOOP2: MOV BX,CARDSTATUS ;Wait for voice to finish
X CMP BX,0 ;playing.
X JNZ BLOOP2
X MOV BX,6 ;Play Voice
X CALL DWORD PTR SOUNDDRIVER
X MOV AX,MORE
X CMP AX,1 ;Should we continue?
X JZ GOBACK
XFINISH: MOV AH,3EH ;Close File
X MOV BX,FILEHANDLE
X INT 21H
X RET
XPLAYSOUND ENDP
XCODE ENDS
X END MAIN
X
X
END_OF_FILE
if test 11754 -ne `wc -c <'PVOC.EXE'`; then
echo shar: \"'PVOC.EXE'\" unpacked with wrong size!
fi
# end of 'PVOC.EXE'
fi
echo shar: End of archive.
exit 0
--
Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.