Difference between revisions of "Z80 Routines:Sound:Beep"

From WikiTI
Jump to: navigation, search
(capitals in category sorts)
m (Reverted edit of AndyJ, changed back to last version by FloppusMaximus)
Line 1: Line 1:
[[Category:Z80 Routines:Sound|Beep]]
+
[[Category:Z80 Routines:Sound|beep]]
[[Category:Z80 Routines|Beep]]
+
[[Category:Z80 Routines|beep]]
  
 
By Joe Wingbermuehle (joewing@calc.org). This routine was written for the ZLib library for the SOS  
 
By Joe Wingbermuehle (joewing@calc.org). This routine was written for the ZLib library for the SOS  

Revision as of 15:18, 18 July 2005


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