home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
SOUNDS.ARC
/
SRECORD.MAC
< prev
Wrap
Text File
|
1987-10-31
|
6KB
|
332 lines
.radix 0ah
.z80
aseg
title Multilength sound recorder
org 100h
begin: jp start
our_fcb: defs 36
;-----------------------------------------
; EQUATES
sys_rst equ 0
rd_con equ 1
wr_con equ 2
rd_rdr equ 3
wr_pun equ 4
wr_lst equ 5
direct_con equ 6
get_io_stat equ 7
put_io_stat equ 8
print_buf equ 9
rd_buf equ 10
con_rdy equ 11
version equ 12
init_bdos equ 13
log_disk equ 14
open_fil equ 15
close_fil equ 16
search_fil equ 17
search_next equ 18
del_fil equ 19
rd_seq equ 20
wr_seq equ 21
make_fil equ 22
rename_fcb equ 23
log_code equ 24
drive_no equ 25
set_dma equ 26
get_alloc equ 27
wrt_prot equ 28
get_ro equ 29
set_attrib equ 30
get_disk_parms equ 31
set_usr equ 32
rd_rand equ 33
wr_rand equ 34
file_size equ 35
set_rand equ 36
;bdos: equ 5
cr equ 13
lf equ 10
esc equ 27
stop_bit equ 0
start_bit equ 1
default_fcb equ 05ch
;---------------------------------
; Text messages
start_msg:
db 'MultiLength sound recorder',cr,lf
db '$'
instrs:
db 'Press start button to commence recording',cr,lf
db 'stop button to stop recording',cr,lf
db '<ESC> before recording to quit...',cr,lf
db '$'
recording: db 'Recording....',cr,lf
db '$'
length_record: db 'Sound recorded occupies $'
length_record2: db ' bytes in memory',cr,lf,'$'
no_room_mesg: db 'No room on disk- file not saved',cr,lf,'$'
;----------------------------------
; subroutines
bdos: push hl
push de
push bc
call 5
pop bc
pop de
pop hl
ret
;
; DECIMAL PRINT ROUTINE
; NUMBER TO PRINT IN HL REGISTER
;
ODEC: PUSH AF ; SAVE
PUSH BC ;
PUSH DE ;
LD IX,TENS ; POINTER TO POWERS OF TEN
LD B,5 ; FIVE DIGITS
LD C,'0' ; use C as leading zero flag
;
LOOP: LD A,2FH ; ASCII ZERO - 1
LD E,(IX+0) ; GET LOW BYTE
LD D,(IX+1) ; GET HIGH BYTE
LOOP1: AND A ; CHEAR CARRY
SBC HL,DE ; SUBTRACT DECADE
INC A ; INCREASE DIGIT
JR NC,LOOP1 ; NOT NEGATIVE YET
ADD HL,DE ; OK, RESTORE NO
CP '0' ; IS IT A ZERO ?
JR Z,ZERO ; YES DO LEADING ZERO TEST
LD C,A ; NO REMOVE SUPRESSION
ODEC1: PUSH BC ; SAVE COUNT
LD B,A ; print needs it in B
CALL VDU ; PRINT
POP BC ; RESTORE COUNT
INC IX ; POINT TO NEXT
INC IX ; DECADE VALUE
DJNZ LOOP ; DO IT 5 TIMES
POP DE ; RESTORE REGISTERS
POP BC ;
POP AF ;
RET ; FINISHED
;
ZERO: CP C ; If A = '0' AND C = '0'
JR NZ,ODEC1 ; IF NOT PRINT ZERO
LD A,B ; TEST COUNTER
CP 1 ; TO SEE IF LAST DIGIT
LD A,'0' ; RESTORE A
JR Z,ODEC1 ; LAST DIGIT,PRINT '0'
LD A,' ' ; IF TRUE PRINT SPACE
JR ODEC1;
; Table for conversion to decimal
;
TENS: DEFW 10000
DEFW 1000
DEFW 100
DEFW 10
DEFW 1
;
; Carriage Return Line Feed Routine
; called CRLF.
; no registers are changed.
;
CRLF: PUSH BC ; Save BC.
LD B,0DH ; CR
CALL VDU ; do it
LD B,0AH ; LF
CALL VDU ; do it
POP BC ; Restore BC
RET ; Thats All !!
vdu: push de
ld e,b
ld c,wr_con
call bdos
pop de
ret
;--------------------------------
; program code
start: ld de,start_msg
ld c,print_buf
call bdos
ld de,instrs
call bdos
;init_pio:
ld a,11001111b ;set up port for control
out (1),a
ld a,00000011b ;bits 0,1 inputs, rest outputs
out (1),a
wait_esc:
ld c,direct_con
ld e,0ffh
call bdos
cp esc ;escape code?
jp z,done
in a,(0) ;which bit?
bit start_bit,a
jr nz,wait_esc ;pulled low to begin.
ld de,recording
ld c,print_buf
call bdos
ld hl,record+2 ;length goes in record buffer start.
main_record:
ld b,7 ;count bits thru cass.
ld c,0 ;start with clean accumulator
record_loop:
in a,(2) ;sample cassette line
rra ;cassette bit into carry
rl c ;and from carry to storage
ld a,c
add a,a
add a,a
add a,a
add a,a
add a,a
add a,a
out (2),a ;echo to speaker
ld a,7 ;waste some time
here: dec a
jr nz,here
ld a,i
ld a,i
nop
nop
nop ;waste some more time
ld a,0
djnz record_loop
in a,(2)
rra
rl c ;repeat for last bit
ld (hl),c ;store it
ld a,c
add a,a
add a,a
add a,a
add a,a
add a,a
add a,a
out (2),a ;echo to speaker
inc hl ;test for end of memory
ld a,h
cp 0c0h ;reached top address yet?
jr z,nquit ;yep!
in a,(0)
bit stop_bit,a ;stop switch pressed?
jr z,nquit ;absolutely!
ld a,4
here2: dec a
jr nz,here2
ld a,i ;waste yet more time
ld a,i
ld a,i
jr main_record
nquit: ld de,-(record+2) ;negate for addition
add hl,de
ld (record),hl ;store this length
ld de,length_record
ld c,print_buf
call bdos
push hl ;retain the length
call odec
ld de,length_record2
ld c,print_buf
call bdos
pop hl
save_sound:
ld a,l
cp 80h ;work out how many sectors to
jr c,save_sound2 ;save to disk
ld de,80h
add hl,de
save_sound2:
ld a,l ;into djnz count
and 80h
ld l,a
ld b,7
div128: xor a
rr h
rr l
djnz div128
ld b,h
ld c,l
push bc
ld hl,default_fcb
ld de,our_fcb
ld bc,12
ldir
ld hl,our_fcb+12
ld de,our_fcb+13
ld (hl),0
ld bc,24
ldir
ld de,our_fcb ;now make our output file
ld c,del_fil
call bdos
ld c,make_fil
call bdos
pop bc
cp 255 ;room on disk?
jr z,no_room
ld de,record
write_on_disk:
push bc
ld c,set_dma
call bdos
push de ;save dma address
ld de,our_fcb
ld c,wr_seq
call bdos
pop de
pop bc
or a
jr nz,no_room
ex de,hl
ld de,128
add hl,de ;update record pointer
ex de,hl
dec bc
ld a,b
or c
jr nz,write_on_disk
ld de,our_fcb
ld c,close_fil
call bdos
jr done
no_room:
ld de,our_fcb
ld c,close_fil
call bdos
ld c,del_fil
call bdos
ld de,no_room_mesg
ld c,print_buf
call bdos
done: ld a,00001111b ;reset pio to output
out (1),a
jp sys_rst ;program done
record equ $
end