mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-05-13 01:47:07 +00:00
keen: working on sound
This commit is contained in:
parent
4df133005d
commit
1be1d94080
@ -6,8 +6,8 @@ Based on dumped code by the "KeenFX" tool
|
|||||||
Note: 65535-value = note freq
|
Note: 65535-value = note freq
|
||||||
|
|
||||||
3) WLDENTERSND
|
3) WLDENTERSND
|
||||||
64155, 10
|
64155, 10 ; 1380Hz F6?
|
||||||
63495, 5
|
63495, 5 ;
|
||||||
0,16
|
0,16
|
||||||
62355,2
|
62355,2
|
||||||
62175,16
|
62175,16
|
||||||
|
@ -1,21 +1,40 @@
|
|||||||
; based on code from here
|
; this code was widely shared for playing tones on Apple II
|
||||||
|
; by POKEing the machine language and CALLing from BASIC
|
||||||
|
|
||||||
|
; it's originally by Paul Lutus, from the Apple II Red Book p45
|
||||||
|
|
||||||
|
|
||||||
|
; it's hard to find good info on this, but loading from $C030
|
||||||
|
; "toggles" the speaker. So toggling twice is esentially a square wave?
|
||||||
|
|
||||||
|
; using regular load/store/bit of $C030 is safe. Some of the more
|
||||||
|
; advanced addressing modes can double-toggle due to how some 6502
|
||||||
|
; implementations run the address bus
|
||||||
|
|
||||||
|
; these seem to have been calculated assuming a 1MHz clock
|
||||||
|
; but the Apple II actually runs at roughly 1.023MHz
|
||||||
|
|
||||||
|
; or a frequency of 1/(speaker_freq*20.46e-6)
|
||||||
|
|
||||||
|
; to go other way, speaker_freq=1/(freq*20.46e-6)
|
||||||
|
|
||||||
|
; this table of notes was from
|
||||||
; http://eightbitsoundandfury.ld8.org/programming.html
|
; http://eightbitsoundandfury.ld8.org/programming.html
|
||||||
|
; but seems off a bit and also assumes 1MHz clock
|
||||||
|
|
||||||
; A,X,Y trashed
|
; 1MHz 1.023MHz
|
||||||
; duration also trashed
|
NOTE_C3 = 255 ; G3=5217us = 192Hz (G3, 5218us = 196Hz 249)
|
||||||
|
NOTE_CSHARP3 = 241 ; 4931us = 203Hz (G#3, 4931us = 207Hz
|
||||||
NOTE_C3 = 255
|
NOTE_D3 = 227 ;
|
||||||
NOTE_CSHARP3 = 241
|
NOTE_DSHARP3 = 214
|
||||||
NOTE_D3 = 227
|
NOTE_E3 = 202
|
||||||
NOTE_DSHARP3 = 214
|
NOTE_F3 = 191
|
||||||
NOTE_E3 = 202
|
NOTE_FSHARP3 = 180
|
||||||
NOTE_F3 = 191
|
NOTE_G3 = 170
|
||||||
NOTE_FSHARP3 = 180
|
NOTE_GSHARP3 = 161
|
||||||
NOTE_G3 = 170
|
NOTE_A3 = 152
|
||||||
NOTE_GSHARP3 = 161
|
NOTE_ASHARP3 = 143
|
||||||
NOTE_A3 = 152
|
NOTE_B3 = 135 ; 1350us = 740Hz (F#5)
|
||||||
NOTE_ASHARP3 = 143
|
|
||||||
NOTE_B3 = 135
|
|
||||||
|
|
||||||
NOTE_C4 = 128
|
NOTE_C4 = 128
|
||||||
NOTE_CSHARP4 = 121
|
NOTE_CSHARP4 = 121
|
||||||
@ -43,20 +62,38 @@ NOTE_A5 = 38
|
|||||||
NOTE_ASHARP5 = 36
|
NOTE_ASHARP5 = 36
|
||||||
NOTE_B5 = 34
|
NOTE_B5 = 34
|
||||||
|
|
||||||
|
; B5 = 988 Hz, 1021us
|
||||||
|
|
||||||
|
|
||||||
|
;=====================================================
|
||||||
|
; speaker tone
|
||||||
|
;=====================================================
|
||||||
|
; A,X,Y trashed
|
||||||
|
; duration also trashed
|
||||||
|
|
||||||
|
; this was designed by basic to be poked into 770 ($302)
|
||||||
|
; on an Applesoft CALL, X=$9d, Y=$02 (A,Y = Address to call)
|
||||||
|
; it was originally designed for Integer BASIC where Y=0 on call
|
||||||
|
|
||||||
|
; the inner freq loop is roughly FREQ*10cycles
|
||||||
|
; so the square wave generated has a period of
|
||||||
|
; freq*20*1.023us
|
||||||
|
; or a frequency of 1/(freq*20.46e-6)
|
||||||
|
|
||||||
speaker_tone:
|
speaker_tone:
|
||||||
lda $C030 ; click speaker
|
ldy #0 ; 3
|
||||||
|
speaker_tone_loop:
|
||||||
|
lda $C030 ; click speaker ; 4
|
||||||
speaker_loop:
|
speaker_loop:
|
||||||
dey ; y never set?
|
dey ; ; 2
|
||||||
bne slabel1 ; duration roughly 256*?
|
bne freq_loop ; ; 2/3
|
||||||
dec speaker_duration ; (Duration)
|
dec speaker_duration ; (Duration) ; 6
|
||||||
beq done_tone
|
beq done_tone ; 2/3
|
||||||
slabel1:
|
freq_loop:
|
||||||
dex
|
dex ; 2
|
||||||
bne speaker_loop
|
bne speaker_loop ; 2/3
|
||||||
ldx speaker_frequency ; (Frequency)
|
ldx speaker_frequency ; (Frequency) ; 4
|
||||||
jmp speaker_tone
|
jmp speaker_tone_loop ; 3
|
||||||
done_tone:
|
done_tone:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user