From 96376339964b3d8cc40ed99dd4609811c4e43939 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 21 Mar 2024 01:08:46 -0400 Subject: [PATCH] keen: add entry/exit music not quite right sadly, but reasonably close --- games/keen/Makefile | 1 + games/keen/keen_mars.s | 4 ++ games/keen/loader.s | 1 - games/keen/sound_effects.s | 93 ++++++++++++++++++++++++++++++++++++++ games/keen/zp.inc | 2 +- 5 files changed, 99 insertions(+), 2 deletions(-) diff --git a/games/keen/Makefile b/games/keen/Makefile index 8c134e9f..fd46c660 100644 --- a/games/keen/Makefile +++ b/games/keen/Makefile @@ -51,6 +51,7 @@ KEEN_MARS: keen_mars.o ld65 -o KEEN_MARS keen_mars.o -C ../../linker_scripts/apple2_2000.inc keen_mars.o: keen_mars.s zp.inc hardware.inc \ + sound_effects.s speaker_tone.s \ maps/mars_map.gr.zx02 graphics/parts.gr.zx02 ca65 -o keen_mars.o keen_mars.s -l keen_mars.lst diff --git a/games/keen/keen_mars.s b/games/keen/keen_mars.s index ae2670f6..7719d6cb 100644 --- a/games/keen/keen_mars.s +++ b/games/keen/keen_mars.s @@ -129,6 +129,10 @@ do_keen_loop: done_with_keen: bit KEYRESET ; clear keypress + ; sound effect + + jsr entry_music +; jsr exit_music lda #LOAD_KEEN1 sta WHICH_LOAD diff --git a/games/keen/loader.s b/games/keen/loader.s index bf56fb1b..ff9bbe63 100644 --- a/games/keen/loader.s +++ b/games/keen/loader.s @@ -705,7 +705,6 @@ sectbl: .byte $00,$0d,$0b,$09,$07,$05,$03,$01,$0e,$0c,$0a,$08,$06,$04,$02,$0f ;dataend = filbuf+4 - .include "init_vars.s" loader_end: diff --git a/games/keen/sound_effects.s b/games/keen/sound_effects.s index fb1c0acd..6ea9ba12 100644 --- a/games/keen/sound_effects.s +++ b/games/keen/sound_effects.s @@ -1,3 +1,96 @@ + ;===================== + ; entry music +entry_music: + lda SOUND_STATUS + bmi done_entry_music + + ; music from _mr_m_ on Commander Keen Forum, Jun 5 2009 + ; 4* D5 32 + ; 4* A4 32 + ; D5 A4 D5 G5 (all 8th) + + lda #0 + sta MUSIC_PTR +entry_music_loop: + ldx MUSIC_PTR + lda entry_music_freq,X + beq done_entry_music + sta speaker_frequency + lda entry_music_len,X + sta speaker_duration + jsr speaker_tone + + lda #100 + jsr WAIT ; FIXME: won't work if language card active + + inc MUSIC_PTR + jmp entry_music_loop + +done_entry_music: + rts + + +entry_music_freq: + .byte NOTE_D5,NOTE_D5,NOTE_D5,NOTE_D5 + .byte NOTE_A4,NOTE_A4,NOTE_A4,NOTE_A4 + .byte NOTE_D5,NOTE_A4,NOTE_D5,NOTE_G5 + .byte 0 + +entry_music_len: + .byte 16,16,16,16 + .byte 16,16,16,16 + .byte 64,64,64,64 + + + + + ;===================== + ; exit music +exit_music: + lda SOUND_STATUS + bmi done_exit_music + + ; all 16 notes + ; F#4 A#4 C5 D5 D#5 F5 + ; G4 G4 G4 + + lda #0 + sta MUSIC_PTR +exit_music_loop: + ldx MUSIC_PTR + lda exit_music_freq,X + beq done_exit_music + sta speaker_frequency + lda exit_music_len,X + sta speaker_duration + jsr speaker_tone + + lda #100 + jsr WAIT ; FIXME: won't work if language card active + + inc MUSIC_PTR + jmp exit_music_loop + +done_exit_music: + rts + + ; all 16 notes + ; F#4 A#4 C5 D5 D#5 F5 + ; G4 G4 G4 + +exit_music_freq: + .byte NOTE_FSHARP4,NOTE_ASHARP4,NOTE_C5,NOTE_D5 + .byte NOTE_DSHARP5,NOTE_F5,NOTE_G4,NOTE_G4 + .byte NOTE_G4 + .byte 0 + +exit_music_len: + .byte 48,48,48,48 + .byte 48,48,48,48 + .byte 48 + + + ;====================== ; noise when jump jump_noise: diff --git a/games/keen/zp.inc b/games/keen/zp.inc index 4cd1a3b4..5966c174 100644 --- a/games/keen/zp.inc +++ b/games/keen/zp.inc @@ -186,7 +186,7 @@ SAMPLE_H = $F3 - +MUSIC_PTR = $F7 LEADING_ZERO = $F8 TEMP_STATUS = $F9 TEMP = $FA