Z80 Routines:Sound:Beep

From WikiTI
Revision as of 16:18, 18 July 2005 by AndyJ (Talk | contribs)

Jump to: navigation, search


By Joe Wingbermuehle (joewing@calc.org). This routine was written for the ZLib library for the SOS shell.

;---------= Make a sound =---------
; c=frequency, b=duration
beep:	di
	ld	e,INIT
beepl1:	ld	a,c
beepl2:	dec	a
	jr	nz,beepl2
	ld	a,e
	xor	%00000011
	ld	e,a
	out	(0),a
	djnz	beepl1
	ld	a,INIT	; you may be able to omit
	out	(0),a	; these two lines
	ei
        ret

Notes

  • On the TI-83, INIT = 0D0h. On the TI-83 Plus, INIT = 0.
  • You may omit the final output if you make sure to always pass an even value for B. Otherwise you risk leaving the link port active.
  • Remember that using port 0 also affects the memory mapping on the TI-83.
  • On the TI-83 Plus SE and TI-84 Plus, you may need to disable the hardware assist and slow the CPU clock as well.

See Also