keen: more work on sound

This commit is contained in:
Vince Weaver 2024-04-02 23:48:33 -04:00
parent 686ee1bf51
commit 97ca5079af
5 changed files with 133 additions and 11 deletions

View File

@ -15,7 +15,8 @@ int main(int argc, char **argv) {
unsigned char header[16],info[16],temp_sample[2];
int fd,result,i,j;
int file_size,num_sounds,sample,last,count;
int file_size,num_sounds,sample,last,count,final;
double frequency;
char *filename;
@ -106,7 +107,21 @@ int main(int argc, char **argv) {
if (last!=sample) {
if (last!=0xffff) {
printf("%d,%d\n",last,count);
if (last==0) {
frequency=0;
final=0;
}
else {
frequency=1193181.0/last;
final=(int)(1.0/(
(20.0*(1.023e-6)*frequency)-
17*1.023e-6));
}
printf(".byte %d,%d\t; %.1lf\n",
final/2,count,frequency);
}
count=0;
last=sample;

View File

@ -2,17 +2,28 @@ include ../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
LINKER_SCRIPTS = ../../linker_scripts/
EMPTY_DISK = ../../empty_disk/empty.dsk
all: generate_frequencies
all: generate_frequencies redbook_sound.dsk
#still_alive.dsk: SA_COMPRESSED STILL_ALIVE TITLE.BAS ENDING
# $(DOS33) -y still_alive.dsk BSAVE -a 0x5900 SA_COMPRESSED
# $(DOS33) -y still_alive.dsk BSAVE -a 0x0800 STILL_ALIVE
# $(DOS33) -y still_alive.dsk BSAVE -a 0x1800 ENDING
# $(DOS33) -y still_alive.dsk SAVE A TITLE.BAS
redbook_sound.dsk: HELLO TEST_KEEN
cp $(EMPTY_DISK) redbook_sound.dsk
$(DOS33) -y redbook_sound.dsk SAVE A HELLO
$(DOS33) -y redbook_sound.dsk BSAVE -a 0xc00 TEST_KEEN
STILL_ALIVE: still_alive.o
ld65 -o STILL_ALIVE still_alive.o -C ../../linker_scripts/apple2_800.inc
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
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
ca65 -o test_keen.o test_keen.s -l test_keen.lst
###
@ -26,5 +37,5 @@ generate_frequencies.o:
###
clean:
rm -f *~ *.o generate_frequencies
rm -f *~ *.o generate_frequencies TEST_KEEN

View File

@ -0,0 +1,2 @@
5 HOME
130 PRINT CHR$(4);"CATALOG"

View File

@ -0,0 +1,49 @@
LVLDONESND:
.byte 36,4 ; 662.9
.byte 0,9 ; 0.0
.byte 36,6 ; 662.9
.byte 0,8 ; 0.0
.byte 36,6 ; 662.9
.byte 0,15 ; 0.0
.byte 93,2 ; 261.7
.byte 94,5 ; 258.3
.byte 0,10 ; 0.0
.byte 82,12 ; 296.8
.byte 83,1 ; 292.4
.byte 0,7 ; 0.0
.byte 149,1 ; 164.3
.byte 139,10 ; 176.0
.byte 140,1 ; 174.4
.byte 139,1 ; 176.0
.byte 0,6 ; 0.0
.byte 183,1 ; 134.4
.byte 181,1 ; 135.3
.byte 0,4 ; 0.0
.byte 184,6 ; 133.5
.byte 0,7 ; 0.0
.byte 170,1 ; 144.1
.byte 169,1 ; 145.2
.byte 0,2 ; 0.0
.byte 171,3 ; 143.1
.byte 170,3 ; 144.1
.byte 169,1 ; 145.2
.byte 0,9 ; 0.0
.byte 156,1 ; 156.6
.byte 158,1 ; 155.4
.byte 0,3 ; 0.0
.byte 159,3 ; 154.2
.byte 158,4 ; 155.4
.byte 0,11 ; 0.0
.byte 135,1 ; 180.8
.byte 137,1 ; 179.2
.byte 0,3 ; 0.0
.byte 134,28 ; 182.4
.byte 0,12 ; 0.0
.byte 206,4 ; 119.1
.byte 205,5 ; 119.8
.byte 206,1 ; 119.1
.byte 205,4 ; 119.8
.byte 0,11 ; 0.0
.byte 12,5 ; 1988.6
.byte 255,255

View File

@ -0,0 +1,45 @@
SOUND_OFFSET = $F0
KEYPRESS = $C000
KEYRESET = $C010
test_keen:
ldy #0
sty SOUND_OFFSET
play_loop:
ldy SOUND_OFFSET
lda LVLDONESND,Y
sta speaker_frequency
iny
lda LVLDONESND,Y
cmp #$FF
beq play_done
asl
clc
adc LVLDONESND,Y
sta speaker_duration
iny
sty SOUND_OFFSET
jsr speaker_tone
jmp play_loop
play_done:
lda KEYPRESS
bpl play_done
bit KEYRESET
jmp test_keen
.include "redbook_sound.s"
.include "lvldone.inc"