keen: have sound working

This commit is contained in:
Vince Weaver 2024-04-03 00:54:32 -04:00
parent c766a3bdff
commit c36dfba91b
4 changed files with 79 additions and 26 deletions

View File

@ -89,8 +89,9 @@ int main(int argc, char **argv) {
}
i=14;
printf("Dump of %s\n",sound_info[i].name);
for(i=0;i<num_sounds;i++) {
printf("%s:\n",sound_info[i].name);
lseek(fd,sound_info[i].offset,SEEK_SET);
last=0xffff;
@ -130,6 +131,9 @@ int main(int argc, char **argv) {
if (sample==0xffff) break;
}
printf(".byte 255,255\n");
}
/* close */
close(fd);

View File

@ -22,7 +22,7 @@ HELLO: hello.bas
TEST_KEEN: test_keen.o
ld65 -o TEST_KEEN test_keen.o -C $(LINKER_SCRIPTS)apple2_c00.inc
test_keen.o: test_keen.s lvldone.inc redbook_sound.s
test_keen.o: test_keen.s longer_sound.s ck1_sounds.inc
ca65 -o test_keen.o test_keen.s -l test_keen.lst

View File

@ -0,0 +1,48 @@
; Based on redbook_sound.s
; it's originally by Paul Lutus, from the Apple II Red Book p45
; which can only do roughly 194Hz to 2000Hz+
; this makes things twice as long, which allows lower notes, but
; loses some precision on high notes
; also modified so "0" means no sound
;=====================================================
; speaker tone
;=====================================================
; A,X,Y trashed
; duration also trashed
; more exactly, it is (4+10F)+(13+10F) = 20F+17
speaker_tone:
ldy #0 ; 3
speaker_tone_loop:
lda $C030 ; click speaker ; 4
speaker_loop:
nop
nop
nop
nop
nop
dey ; ; 2
bne freq_loop ; ; 2/3
dec speaker_duration ; (Duration) ; 6
beq done_tone ; 2/3
freq_loop:
dex ; 2
bne speaker_loop ; 2/3
ldx speaker_frequency ; (Frequency) ; 4
beq speaker_loop ; play nothing if 0 ; 2/3
jmp speaker_tone_loop ; 3
done_tone:
rts
speaker_duration:
.byte $00
speaker_frequency:
.byte $00

View File

@ -27,14 +27,15 @@ play_loop:
ldy SOUND_OFFSET
lda (INL),Y
sta speaker_frequency
iny
lda (INL),Y
cmp #$FF
beq play_done
asl
clc
adc LVLDONESND,Y
; clc
; adc (INL),Y
sta speaker_duration
iny
@ -61,12 +62,12 @@ play_done:
.include "redbook_sound.s"
.include "longer_sound.s"
.include "ck1_sounds.inc"
sounds_low:
.byte <WLDWALKSND,<WLDBLOCKSND<WLDENTERSND,<KEENWALKSND
.byte <WLDWALKSND, <WLDBLOCKSND,<WLDENTERSND,<KEENWALKSND
.byte <KEENBLOKSND,<KEENJUMPSND,<KEENLANDSND,<KEENDIESND
.byte <GOTBONUSSND,<GOTITEMSND, <GOTPARTSND, <KEENFIRESND
.byte <KEENPOGOSND,<POGOJUMPSND,<LVLDONESND, <GAMEOVERSND
@ -79,7 +80,7 @@ sounds_low:
.byte <keensleft, <EARTHPOW, $FF
sounds_high:
.byte >WLDWALKSND,>WLDBLOCKSND>WLDENTERSND,>KEENWALKSND
.byte >WLDWALKSND, >WLDBLOCKSND,>WLDENTERSND,>KEENWALKSND
.byte >KEENBLOKSND,>KEENJUMPSND,>KEENLANDSND,>KEENDIESND
.byte >GOTBONUSSND,>GOTITEMSND, >GOTPARTSND, >KEENFIRESND
.byte >KEENPOGOSND,>POGOJUMPSND,>LVLDONESND, >GAMEOVERSND