Difference between revisions of "Z80 Routines:Sound:Beep"
From WikiTI
Guillaumeh (Talk | contribs) |
m |
||
| (5 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| + | [[Category:Z80 Routines:Sound|Beep]] | ||
| + | [[Category:Z80 Routines|Beep]] | ||
By Joe Wingbermuehle (joewing@calc.org). This routine was written for the ZLib library for the SOS shell. | By Joe Wingbermuehle (joewing@calc.org). This routine was written for the ZLib library for the SOS shell. | ||
| Line 5: | Line 7: | ||
; c=frequency, b=duration | ; c=frequency, b=duration | ||
beep: di | beep: di | ||
| − | ld e, | + | ld e,INIT |
beepl1: ld a,c | beepl1: ld a,c | ||
beepl2: dec a | beepl2: dec a | ||
| Line 14: | Line 16: | ||
out (0),a | out (0),a | ||
djnz beepl1 | djnz beepl1 | ||
| + | ld a,INIT ; you may be able to omit | ||
| + | out (0),a ; these two lines | ||
ei | ei | ||
| − | + | ret</nowiki> | |
| + | |||
| + | == 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 [[83Plus:Ports:08|disable the hardware assist]] and [[83Plus:Ports:20|slow the CPU clock]] as well. | ||
| + | |||
| + | == See Also == | ||
| + | |||
| + | * [[83:Ports:00]] | ||
| + | * [[83Plus:Ports:00]] | ||
Latest revision as of 14:12, 26 October 2009
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.