; Date:     Sun, 24 Mar 1996 10:00:35
; From:     Eric Linenberg  [ELinenberg@gnn.com]
; Subject:  LZ: SOUND routine

; This message comes from the List-ZShell mailing list:

; Do you want sound in your ZShell games
; THEN*USE*THIS*ROUTINE*

; reasons why you should use this:
; 1.sound is cool
; 2.takes up almost NO MEMORY
; 3.games are more fun
; 4.Breakout will KICK ASS

; reasons why you shouldn't use this:
; 1.if you want a song get my next routine
; 2.NONE

;Beep. asm
;ld de with length 1-65535
;ld hl with tone   1-65535
;then CALL_(beep)
;uses registers de,hl,bc,a
;EXAMPLE CALL
;	ld	de,10	;length
;   	ld	hl,25	;tone
;  	CALL_(beep)
;   	ret
;
#define   P_HI      %11000000        ;code to put port high
#define   P_LO      %11111100        ;code to put port low
#define   C_PORT    %00000111        ;addres of com port

beep:
   	push	af
  	push	bc
   	di	
set_low:
   	ld  	b,P_LO         
   	ld  	c,C_PORT      
   	out  	(c),b          
  	push 	hl
Delay16bit1:
   	dec  	hl
   	ld   	a,l
   	or	h
   	jr   	nz,Delay16bit1
   	pop	hl
set_high:
   	ld  	b,P_HI         
   	ld  	c,C_PORT       
   	out 	(c),b          
        push 	hl
Delay16bit2:
   	dec  	hl
    	ld   	a,l
    	or   	h
    	jr   	nz,Delay16bit2
    	pop	hl
	dec 	de
   	ld	a,d
   	cp	0
   	jr      nz,beep
   	ei
   	pop	bc
   	pop  	af
ret

