; SoundBlast routine ; 2-23-05 ; Destroys 'a' (sometimes), 'b', 'c', 'd', and 'e' ; Input: 'a' - Wavelength (higher the 'a', the lower the frequency), 'd' - Play duration ; Output: Sound! :) ; Anthony Loven #include "ti86asm.inc" .org _asm_exec_ram ProgStart: ; An example of how to use the to use SoundBlast ld a,200 ; The wavelength of the note is set to 200 ld d,20 ; The playlength is set to 20, about a second call SoundBlast; calls the SoundBlast routine :) ret ; Exits the program. ;****************** Routine begins ************************ SoundBlast: ; Takes 'a' value, 0-255, which determines wavelength ; Takes 'd' value, 0-255, which determines play length di ; Disable interrupts. This makes a pure sound. ld c,a ld a,%11000000 ; This value, when sent to port 7, turns on red and white wires. ld e,%00111100 ; When xor with a, it makes $11111100, which turns wires off. BigLoop: push af ld a,c cpl ld b,a pop af PlayLoop: push bc ; push the counter in stack, so frequency counter can be put in 'b'. ld b,c ; Makes a frequency counter Frequency: ; Holds time pauses djnz Frequency xor e ; Turns off/on wires out (7),a ; Sends value to link port pop bc ; Retrieve the 254 loop counter djnz PlayLoop ; Jump back; This counter depends on frequency dec d ; Decreases play counter jp nz,BigLoop ; If length counter = 0, go next line ei ; Enable interrupts. ret ; Exits the routine ;****************** Routine ends ************************ .end