home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
355
/
APDEVKIT.ZIP
/
AP
/
TEST.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-05-11
|
12KB
|
568 lines
Title Find the Audio Port
page 63,131
.286
; /*\
;---|*|----====< TEST.ASM >====----
;---|*|
;---|*| This program searches for the Audio Port
;---|*| across the parallel port addresses.
;---|*|
;---|*| Media Vision Audio Port Demonstration Program.
;---|*| Copyright (c) 1992, All Rights Reserved. Media Vision, Inc.
;---|*|
; \*/
include model.inc
.data
include parr.inc
Idledly equ <out dx,al>
extrn PortAddress :word ; AP base address...
extrn StartPCM :byte
extrn PCMLength :word
extrn RecPCMLength :word
Copyright db 0dh,0ah
db 'Media Vision Audio Port Demonstration Program.',0dh,0ah
db 'Copyright (c) 1992, All Rights Reserved. Media Vision, Inc.'
db 0dh,0ah,'$'
@nowhere db 'Audio Port not detected!',0dh,0ah,'$'
@378h db 'Audio Port detected at 378h!',0dh,0ah,'$'
@278h db 'Audio Port detected at 278h!',0dh,0ah,'$'
@3BCh db 'Audio Port detected at 3BCh!',0dh,0ah,'$'
fmdemo db 0dh,0ah,'FM demo...','$'
pcmdemo db 0dh,0ah,'PCM playback demo...','$'
recpcmdemo db 0dh,0ah,'PCM Record demo. Type a key to start...','$'
recording db 0dh,0ah,'Now recording...','$'
version db 'Audio Port, version ','$'
alldonemsg db 0dh,0ah,'All done'
cr_lf db 0dh,0ah,'$'
.code
extrn AP_Reset :near ; Audio Port Reset
extrn AP_MCW :near ; Micro Command Write
extrn AP_MDW :near ; Micro Data Write
extrn AP_FM_in :near ; read the FM status register
extrn AP_FM_out :near ; output index/data to the FM chip
extrn AP_MDR_wait :near ; wait for data to be available
extrn AP_MDR :near ; read the micro data byte
extrn AP_SRQ_stat :near ; wait for the service request
extrn AP_ADC_input :near ; record 256 bytes
extrn AP_DAC_output :near ; play 256 bytes
main proc far
;
; setup for small model
;
mov ax,@data ; setup small model...
mov ds,ax
mov es,ax
;
; Give the opening logo.
;
lea dx,Copyright
mov ah,09
int 21h
;
; find the Audio Port
;
call FindAudioPort
;
; get the Audio Port version #
;
call PrintVersion
;
; Make some FM sounds
;
call fmsounds
;
; Make some PCM sound...
;
call playpcmsounds
;
; Record some PCM sound...
;
call recordpcmsounds
;
; exit to DOS
;
mov ah,9 ; give the all done message
lea dx,alldonemsg
int 21h
mov ax,4c00h ; exit to dos
int 21h
main endp
;
;
;=====================
; Routine Section
; level 1
;=====================
;
;
; /*\
;---|*|----====< FindAudioPort >====----
;---|*|
;---|*| Find the Audio Port out on one of the parallel ports.
;---|*|
; \*/
;
FindAudioPort proc near
mov [PortAddress],378h ; try the 1st port
call AP_Reset ; reset & return the reset value
lea dx,@378h ; get the text message
cmp al,5Ah ; is it here?
jz found ; yes, go report it...
mov [PortAddress],278h ; try the 1st port
call AP_Reset ; reset & return the reset value
lea dx,@278h ; get the text message
cmp al,5Ah ; is it here?
jz found ; yes, go report it...
mov [PortAddress],3BCH ; try the 1st port
call AP_Reset ; reset & return the reset value
lea dx,@3BCh ; get the text message
cmp al,5Ah ; is it here?
jz found ; yes, go report it...
lea dx,@nowhere ; not found anywhere
mov ah,9 ; give the message
int 21h
mov ax,4c00h ; and exit to DOS
int 21h
;
found:
mov ah,9 ; give the message
int 21h
call timewait
ret
FindAudioPort endp
;
; /*\
;---|*|----====< fmsounds >====----
;---|*|
;---|*| make some sound out on the FM chip.
;---|*|
; \*/
;
;
; table of note frequencies and Octaves for the 3812
;
; each entry has the format of: 000bbbff:ffffffff
; ||||| ||||||||
; |||++-++++++++- 10 bit frequency
; |||
; +++------------ Octave
;
OCTAVE_1 equ (04h SHL 8)
OCTAVE_2 equ (08h SHL 8)
OCTAVE_3 equ (0ch SHL 8)
OCTAVE_4 equ (10h SHL 8)
OCTAVE_5 equ (14h SHL 8)
OCTAVE_6 equ (18h SHL 8)
OCTAVE_7 equ (1ch SHL 8)
noteC equ 0342
noteCSHARP equ 0363
noteD equ 0384
noteDSHARP equ 0407
noteE equ 0432
noteF equ 0457
noteFSHARP equ 0484
noteG equ 0513
noteGSHARP equ 0544
noteA equ 0576
noteASHARP equ 0611
noteB equ 0647
fmsounds proc near
;
; give the FM demo message
;
lea dx,fmdemo
mov ah,9
int 21h
;
; just read the status for the fun of it. We do this to
; test the routine only...
;
call AP_FM_in
;
; program one operator of the FM chip to do a simple tone
;
mov ax,OCTAVE_3+noteC
call loadfm
mov ax,OCTAVE_3+noteCSHARP
call loadfm
mov ax,OCTAVE_3+noteD
call loadfm
mov ax,OCTAVE_3+noteDSHARP
call loadfm
mov ax,OCTAVE_3+noteE
call loadfm
mov ax,OCTAVE_3+noteF
call loadfm
mov ax,OCTAVE_3+noteFSHARP
call loadfm
mov ax,OCTAVE_3+noteG
call loadfm
mov ax,OCTAVE_3+noteGSHARP
call loadfm
mov ax,OCTAVE_3+noteA
call loadfm
mov ax,OCTAVE_3+noteASHARP
call loadfm
mov ax,OCTAVE_3+noteB
call loadfm
ret
fmsounds endp
;
; /*\
;---|*|----====< playpcmsounds >====----
;---|*|
;---|*| PCM output to the device.
;---|*|
; \*/
;
playpcmsounds proc near
;
; give the PCM demo message
;
lea dx,pcmdemo
mov ah,9
int 21h
;
; send the PCM commands
;
mov al,042h ; send play command w/sample rate
call AP_MCW
mov al,05Ah ; send the sample rate for 11khz
call AP_MCW
;
; Setup the source/destination for the transfer
;
push es ; save ES
push ds ; ES:DI will point to the start
pop es ; of the PCM block.
lea di,startpcm
mov si,[PCMLength] ; si holds the length
;
; move all the data out to the FIFO in 256 byte blocks.
;
pcm05:
mov cx,256 ; get the 1/4 FIFO size
sub si,cx ; remove this from the block length
jnc @F ; jump if more data is available
add cx,si ; calc the true block length.
sub si,si ; says we are all done...
;
@@:
call AP_DAC_output ; move 256 bytes out to the FIFO
;
pcm15:
;
; wait till the service request line goes high, meaning, send another 256 bytes
;
call AP_SRQ_stat ; wait for the service request
jnc pcm15 ; status to go high
;
; if the length wrapped, we're done...
;
cmp cx,si ; check to see if we're done
jnz pcm05 ; not yet, continue till done
pop es
;
; we're done, tell the Audio Port to play the last of the queue, then stop
;
mov al,010h ; send the Idle command
call AP_MCW
ret
playpcmsounds endp
;
; /*\
;---|*|----====< PrintVersion >====----
;---|*|
;---|*| Read the Audio Port's version #, then print it...
;---|*|
; \*/
;
PrintVersion proc near
;
; print the opening line
;
lea dx,version
mov ah,9
int 21h
;
; give the version command
;
mov al,11H ; get version
call AP_MCW
call AP_MDR_wait ; wait for data to become available
call AP_MDR ; print the MSB of the version
call hexout
call AP_MDR_wait ; wait for data to become available
call AP_MDR ; print the LSB of the version
call hexout
lea dx,cr_lf
mov ah,09h
int 21h
ret
PrintVersion endp
;
; /*\
;---|*|----====< recordpcmsounds >====----
;---|*|
;---|*| Record one buffer, then play it back.
;---|*|
; \*/
;
recordpcmsounds proc near
;
; give the PCM demo message
;
lea dx,recpcmdemo ; print the "record demo" message
mov ah,9
int 21h
mov ah,0 ; wait for a key...
int 16h
lea dx,recording ; print the "now recording" message
mov ah,9
int 21h
;
; send the Record PCM commands
;
mov al,052h ; send record command w/sample rate
call AP_MCW
mov al,05Ah ; send the sample rate for 11khz
call AP_MCW
;
; Setup the source/destination for the transfer
;
push es ; always save segments...
push ds ; make ES:DI point to the start
pop es
lea di,startpcm ; get the start of the PCM block
mov si,[RecPCMLength] ; si holds the length
;
rcd05:
;
; load the FIFO quarter size for use with the SRQ handshaking.
;
mov cx,256 ; get the 1/4 FIFO size
sub si,cx ; remove this from the block length
jnc rcd10 ; jump if more data is available
add cx,si ; calc the true block length.
sub si,si ; all done...
;
rcd10:
;
; wait till the service request line goes high, meaning, read another 256 bytes
;
call AP_SRQ_stat ; wait for the service request
jnc rcd10 ; status to go high
;
; record up to 256 bytes into our buffer
;
call AP_ADC_input ; does up to 256 bytes
;
; if the length wrapped, we're done...
;
cmp cx,si ; check to see if we're done
jnz rcd05 ; not yet, continue till done
pop es
;
; we're done, tell the Audio Port to play the last of the queue, then stop
;
mov al,010h ; send the Idle command
call AP_MCW
;
; play it back for the user...
;
mov di,[RecPCMLength] ; modify the length to be the whole
mov [PCMLength],di ; buffer.
call playpcmsounds
;
; all done with the record demo
;
ret
recordpcmsounds endp
;
;
;=====================
; Routine Section
; Level 2
;=====================
;
;
; /*\
;---|*|----====< hexout >====----
;---|*|
;---|*| Load the FM with a note, and pluck it...
;---|*|
; \*/
;
public hexout
hexout proc near
mov cx,ax ; save a copy of the byte
and cl,00fh ; cl = high nibble
and al,0f0h
shr al,4 ; al = low nibble
add al,90h ; convert the low digit
daa
adc al,0
add al,40h
daa
mov ah,0Eh
sub bx,bx
int 10h
mov al,cl ; al = high nibble, bl = low nibble
add al,90h ; convert the high digit
daa
adc al,0
add al,40h
daa
mov ah,0Eh
int 10h
ret
hexout endp
;
; /*\
;---|*|----====< loadfm >====----
;---|*|
;---|*| Load the FM with a note, and pluck it...
;---|*|
; \*/
;
loadfm proc near
push bx
mov bx,ax
mov ax,02F20h ; index 20h
call AP_FM_out
mov ax,00040h ; index 40h
call AP_FM_out
mov ax,0F060h ; index 60h
call AP_FM_out
mov ax,00680h ; index 80h
call AP_FM_out
mov ah,bl ; place the data in ah
mov al,0A0h ; index A0h
call AP_FM_out
mov ax,001C0h ; index C0h
call AP_FM_out
mov ax,000E0h ; index E0h
call AP_FM_out
mov ah,bh ; place the data in ah
or ah,20h ; turn on the voice
mov al,0B0h ; index B0h
call AP_FM_out
mov ah,bh ; place the data in ah
mov al,0B0h ; index B0h
call AP_FM_out
call timewait
pop bx
ret
loadfm endp
;
; /*\
;---|*|----====< timewait >====----
;---|*|
;---|*| A slow loop. It can be sloppy in time, we
;---|*| just want to waist some time.
;---|*|
; \*/
;
timewait proc near
mov dx,[PortAddress]
mov ah,2
sub cx,cx
;
@@:
in al,dx ; 64k of SSLLOOWW in instructions
loop @B
dec ah
jnz @B
ret
timewait endp
end main