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
/
SPLAY.MAC
< prev
next >
Wrap
Text File
|
1987-10-31
|
4KB
|
228 lines
.radix 0ah
aseg
.z80
title MultiLength Sound replayer
org 100h
jp start
our_fcb: ds 36 ;room for fcb.
include EQUATES.MAC
;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 replayer',cr,lf
db '$'
playing: db 'Playing....',cr,lf
db '$'
length_record: db 'Sound recorded occupies $'
length_record2: db ' bytes in memory',cr,lf,'$'
disk_err: db 'Disk Error- file not loaded',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
;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
ld hl,default_fcb
ld de,our_fcb
ld bc,12
ldir ;copy the fcb
ld hl,our_fcb+12
ld de,our_fcb+13
ld (hl),0
ld bc,23
ldir
ld de,our_fcb ;now try to open the relevant file
ld c,open_fil
call bdos
cp 255 ;disk stuff_up?
jr z,no_file
ld de,play
load_sound:
ld c,set_dma
call bdos ;set write address
push de
ld de,our_fcb
ld c,rd_seq
call bdos
pop de
ld hl,80h
add hl,de
ex de,hl ;inc dma address to next sector
or a
jr z,load_sound
ld de,our_fcb
ld c,close_fil
call bdos
ld de,length_record ;how long is it?
ld c,print_buf
call bdos
ld hl,(play)
call odec
ld de,length_record2
ld c,print_buf
call bdos
ld de,playing
ld c,print_buf
call bdos
ld hl,(play) ;length goes in record buffer start.
ld b,h
ld c,l ;length to bc.
ld hl,play+2
main_play:
push bc
ld b,7 ;count bits thru cass.
ld c,(hl) ;start with clean accumulator
play_loop:
rl c ;get bit out
rra
rra ;into speaker bit
out (2),a
ld a,11
here: dec a
jr nz,here
ld a,0
djnz play_loop
rl c
rra
rra
out (2),a
pop bc ;restore loop count before quitting
ld a,8
here2: dec a
jr nz,here2
inc hl
inc de
dec bc ;count down length
ld a,b
or c
jr nz,main_play
jr done
no_file:
ld de,our_fcb
ld c,close_fil
call bdos
ld c,del_fil
call bdos
ld de,disk_err
ld c,print_buf
call bdos
done: ld a,00001111b ;reset pio to output
out (1),a
jp sys_rst ;program done
play equ $
end