peasant: move audio over to redbook

had to pitch some of the sounds up, not sure if this was the best idea
This commit is contained in:
Vince Weaver 2024-10-09 23:33:11 -04:00
parent ea011a495a
commit 958608cde0
15 changed files with 268 additions and 47 deletions

View File

@ -252,11 +252,12 @@ qload.inc: generate_common QLOAD
./generate_common -a 0xb00 -s score_points qload.lst >> qload.inc
./generate_common -a 0xb00 -s print_score qload.lst >> qload.inc
./generate_common -a 0xb00 -s update_score qload.lst >> qload.inc
./generate_common -a 0xb00 -s speaker_beep qload.lst >> qload.inc
./generate_common -a 0xb00 -s speaker_tone qload.lst >> qload.inc
./generate_common -a 0xb00 -s speaker_duration qload.lst >> qload.inc
./generate_common -a 0xb00 -s speaker_frequency qload.lst >> qload.inc
echo "hposn_high = \$$BA00" >> qload.inc
echo "hposn_low = \$$BB00" >> qload.inc
# ./generate_common -a 0xb00 -s speaker_beep qload.lst >> qload.inc
# echo "driveoff = \$$A22" >> qload.inc
# echo "driveon = \$$A9D" >> qload.inc

View File

@ -146,43 +146,43 @@ boat_loop:
beq bloop
click:
lda #NOTE_C3
lda #NOTE_C4
sta speaker_frequency
lda #6
sta speaker_duration
jsr speaker_beep
jsr speaker_tone
jmp no_sound
bloop:
lda #10
sta speaker_duration
lda #NOTE_C4
lda #NOTE_C5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #10
sta speaker_duration
lda #NOTE_D4
lda #NOTE_D5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #10
sta speaker_duration
lda #NOTE_E4
lda #NOTE_E5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #10
sta speaker_duration
lda #NOTE_D4
lda #NOTE_D5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #10
sta speaker_duration
lda #NOTE_C4
lda #NOTE_C5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
jmp no_sound
@ -572,7 +572,7 @@ stuck_forever:
.include "../wait.s"
.include "../wait_a_bit.s"
.include "../speaker_beeps.inc"
.include "../redbook_sound.inc"
.include "graphics_end/ending_graphics.inc"

View File

@ -13,7 +13,7 @@ game_over.o: game_over.s \
../hardware.inc ../zp.inc ../qload.inc \
graphics_over/game_over_graphics.inc \
graphics_over/game_over_animation.inc \
../hgr_sprite.s ../speaker_beeps.s \
../hgr_sprite.s \
../wait_a_bit.s ../wait.s
ca65 -o game_over.o game_over.s -l game_over.lst

View File

@ -96,7 +96,8 @@ make_beep:
sta speaker_frequency
lda animation_note_lens,X
sta speaker_duration
jsr speaker_beep
; jsr speaker_beep
jsr speaker_tone
ldx FRAME
lda animation_pause_lens,X
@ -155,7 +156,8 @@ done_beep:
; jmp forever
.include "../hgr_sprite.s"
.include "../speaker_beeps.inc"
;.include "../speaker_beeps.inc"
.include "../redbook_sound.inc"
.include "../wait_a_bit.s"
.include "../wait.s"
@ -208,6 +210,61 @@ animation_steps_h:
.byte >over_anim10 ; skull mostly
.byte >over_anim11 ; skull down
animation_notes:
.byte NOTE_G5 ; 0
.byte NOTE_F5 ; 1
.byte NOTE_F5 ; 2
.byte NOTE_E5 ; 3
.byte NOTE_E5 ; 4
.byte NOTE_D5 ; 5
.byte NOTE_C5 ; 6
.byte 0 ; 7
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 9
.byte NOTE_C4 ; 10
.byte 0 ; 11
animation_note_lens:
.byte 150 ; NOTE_G5 ; 0
.byte 50 ; NOTE_F5 ; 1
.byte 100 ; NOTE_F5 ; 2
.byte 50 ; NOTE_E5 ; 3
.byte 100 ; NOTE_E5 ; 4
.byte 50 ; NOTE_D5 ; 5
.byte 150 ; NOTE_C5 ; 6
.byte 0 ; 7
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 9
.byte 150 ; NOTE_C4 ; 10
.byte 0 ; 11
animation_pause_lens:
.byte 1 ; NOTE_G5 ; 0
.byte 1 ; NOTE_F5 ; 1
.byte 1 ; NOTE_F5 ; 2
.byte 1 ; NOTE_E5 ; 3
.byte 1 ; NOTE_E5 ; 4
.byte 1 ; NOTE_D5 ; 5
.byte 1 ; NOTE_C5 ; 6
.byte 0 ; 7
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 8
.byte 0 ; 9
.byte 1 ; NOTE_C4 ; 10
.byte 0 ; 11
.if 0
animation_notes:
.byte NOTE_G4 ; 0
.byte NOTE_F4 ; 1
@ -259,3 +316,5 @@ animation_pause_lens:
.byte 1 ; NOTE_C3 ; 10
.byte 0 ; 11
.endif

View File

@ -6,7 +6,7 @@
; if dead on this screen
; if dead not on this screen
.include "speaker_beeps.inc"
.include "redbook_sound.inc"
;=======================
;=======================
@ -275,27 +275,27 @@ kerrek_row4:
kerrek_warning_music:
lda #96
sta speaker_duration
lda #NOTE_G3
lda #NOTE_G4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #48
sta speaker_duration
lda #NOTE_F3
lda #NOTE_F4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #48
sta speaker_duration
lda #NOTE_E3
lda #NOTE_E4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #192
sta speaker_duration
lda #NOTE_C3
lda #NOTE_C4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
rts
@ -662,9 +662,9 @@ kerrek_got_ya:
; bonk sound effect
lda #96
sta speaker_duration
lda #NOTE_C3
lda #NOTE_C4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
; wait a bit

View File

@ -102,7 +102,8 @@ load_file:
.include "wait_keypress.s"
.include "random16.s"
.include "score.s"
.include "speaker_beeps.s"
;.include "speaker_beeps.s"
.include "redbook_sound.s"
peasant_text:
.byte 25,2,"Peasant's Quest",0

View File

@ -0,0 +1,48 @@
;NOTE_C3 = 376 ; 129.7 (130.8)
;NOTE_CSHARP3 = 355 ; 137.4 (138.6)
;NOTE_D3 = 335 ; 145.6 (146.8)
;NOTE_DSHARP3 = 316 ; 154.3 (155.6)
;NOTE_E3 = 298 ; 163.5 (164.8)
;NOTE_F3 = 281 ; 173.2 (174.6)
;NOTE_FSHARP3 = 265 ; 183.6 (185.0)
NOTE_G3 = 250 ; 194.5 (196.0)
NOTE_GSHARP3 = 236 ; 206.1 (207.7)
NOTE_A3 = 223 ; 218.3 (220.0)
NOTE_ASHARP3 = 210 ; 231.3 (233.1)
NOTE_B3 = 199 ; 245.0 (246.9)
NOTE_C4 = 187 ; 259.6 (261.6)
NOTE_CSHARP4 = 177 ; 275.0 (277.2)
NOTE_D4 = 167 ; 291.4 (293.7)
NOTE_DSHARP4 = 158 ; 308.6 (311.1)
NOTE_E4 = 149 ; 326.9 (329.6)
NOTE_F4 = 140 ; 346.3 (349.2)
NOTE_FSHARP4 = 132 ; 366.8 (370.0)
NOTE_G4 = 125 ; 388.5 (392.0)
NOTE_GSHARP4 = 118 ; 411.5 (415.3)
NOTE_A4 = 111 ; 435.8 (440.0)
NOTE_ASHARP4 = 105 ; 461.6 (466.2)
NOTE_B4 = 99 ; 488.9 (493.9)
NOTE_C5 = 94 ; 517.7 (523.3)
NOTE_CSHARP5 = 88 ; 548.3 (554.4)
NOTE_D5 = 83 ; 580.5 (587.3)
NOTE_DSHARP5 = 79 ; 614.8 (622.3)
NOTE_E5 = 74 ; 651.0 (659.3)
NOTE_F5 = 70 ; 689.3 (698.5)
NOTE_FSHARP5 = 66 ; 729.8 (740.0)
NOTE_G5 = 62 ; 772.6 (784.0)
NOTE_GSHARP5 = 59 ; 817.9 (830.6)
NOTE_A5 = 56 ; 865.9 (880.0)
NOTE_ASHARP5 = 52 ; 916.6 (932.3)
NOTE_B5 = 50 ; 970.3 (987.8)
NOTE_C6 = 47 ; 1027.5 (1047.0)
NOTE_CSHARP6 = 44 ; 1087.2 (1109.0)
NOTE_D6 = 42 ; 1150.7 (1175.0)
NOTE_DSHARP6 = 39 ; 1217.8 (1245.0)
NOTE_E6 = 37 ; 1288.6 (1319.0)
NOTE_F6 = 35 ; 1363.1 (1397.0)
NOTE_FSHARP6 = 33 ; 1442.1 (1480.0)
NOTE_G6 = 31 ; 1525.6 (1568.0)
NOTE_GSHARP6 = 29 ; 1613.6 (1661.0)
NOTE_A6 = 28 ; 1706.9 (1760.0)
NOTE_ASHARP6 = 26 ; 1805.6 (1865.0)
NOTE_B6 = 25 ; 1909.6 (1976.0)

View File

@ -0,0 +1,111 @@
; 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)
;NOTE_C3 = 376 ; 129.7 (130.8)
;NOTE_CSHARP3 = 355 ; 137.4 (138.6)
;NOTE_D3 = 335 ; 145.6 (146.8)
;NOTE_DSHARP3 = 316 ; 154.3 (155.6)
;NOTE_E3 = 298 ; 163.5 (164.8)
;NOTE_F3 = 281 ; 173.2 (174.6)
;NOTE_FSHARP3 = 265 ; 183.6 (185.0)
NOTE_G3 = 250 ; 194.5 (196.0)
NOTE_GSHARP3 = 236 ; 206.1 (207.7)
NOTE_A3 = 223 ; 218.3 (220.0)
NOTE_ASHARP3 = 210 ; 231.3 (233.1)
NOTE_B3 = 199 ; 245.0 (246.9)
NOTE_C4 = 187 ; 259.6 (261.6)
NOTE_CSHARP4 = 177 ; 275.0 (277.2)
NOTE_D4 = 167 ; 291.4 (293.7)
NOTE_DSHARP4 = 158 ; 308.6 (311.1)
NOTE_E4 = 149 ; 326.9 (329.6)
NOTE_F4 = 140 ; 346.3 (349.2)
NOTE_FSHARP4 = 132 ; 366.8 (370.0)
NOTE_G4 = 125 ; 388.5 (392.0)
NOTE_GSHARP4 = 118 ; 411.5 (415.3)
NOTE_A4 = 111 ; 435.8 (440.0)
NOTE_ASHARP4 = 105 ; 461.6 (466.2)
NOTE_B4 = 99 ; 488.9 (493.9)
NOTE_C5 = 94 ; 517.7 (523.3)
NOTE_CSHARP5 = 88 ; 548.3 (554.4)
NOTE_D5 = 83 ; 580.5 (587.3)
NOTE_DSHARP5 = 79 ; 614.8 (622.3)
NOTE_E5 = 74 ; 651.0 (659.3)
NOTE_F5 = 70 ; 689.3 (698.5)
NOTE_FSHARP5 = 66 ; 729.8 (740.0)
NOTE_G5 = 62 ; 772.6 (784.0)
NOTE_GSHARP5 = 59 ; 817.9 (830.6)
NOTE_A5 = 56 ; 865.9 (880.0)
NOTE_ASHARP5 = 52 ; 916.6 (932.3)
NOTE_B5 = 50 ; 970.3 (987.8)
NOTE_C6 = 47 ; 1027.5 (1047.0)
NOTE_CSHARP6 = 44 ; 1087.2 (1109.0)
NOTE_D6 = 42 ; 1150.7 (1175.0)
NOTE_DSHARP6 = 39 ; 1217.8 (1245.0)
NOTE_E6 = 37 ; 1288.6 (1319.0)
NOTE_F6 = 35 ; 1363.1 (1397.0)
NOTE_FSHARP6 = 33 ; 1442.1 (1480.0)
NOTE_G6 = 31 ; 1525.6 (1568.0)
NOTE_GSHARP6 = 29 ; 1613.6 (1661.0)
NOTE_A6 = 28 ; 1706.9 (1760.0)
NOTE_ASHARP6 = 26 ; 1805.6 (1865.0)
NOTE_B6 = 25 ; 1909.6 (1976.0)
;=====================================================
; 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
; and it was poked to $00 (zero page)
; 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)
; 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:
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
jmp speaker_tone_loop ; 3
done_tone:
rts
speaker_duration:
.byte $00
speaker_frequency:
.byte $00

View File

@ -125,19 +125,19 @@ clear_top:
lda #32
sta speaker_duration
lda #NOTE_E4
lda #NOTE_E5
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
lda #64
sta speaker_duration
lda #NOTE_F5
sta speaker_frequency
jsr speaker_tone
lda #128
sta speaker_duration
lda #NOTE_F4
sta speaker_frequency
jsr speaker_beep
lda #128
sta speaker_duration
lda #NOTE_F3
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
rts

View File

@ -310,7 +310,7 @@ draw_sprite_h:
.include "../version.inc"
.include "../speaker_beeps.inc"
.include "../redbook_sound.inc"
.include "../hgr_sprite.s"

View File

@ -349,17 +349,17 @@ burninate_loop:
lda #16
sta speaker_duration
lda #NOTE_C3
lda #NOTE_C4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
bit PAGE2
lda #16
sta speaker_duration
lda #NOTE_D3
lda #NOTE_D4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
dec BABY_COUNT
bne burninate_loop
@ -413,9 +413,9 @@ dashing_loop:
lda #64
sta speaker_duration
lda #NOTE_C3
lda #NOTE_C4
sta speaker_frequency
jsr speaker_beep
jsr speaker_tone
no_boom:

View File

@ -11,7 +11,7 @@ VID_LOGO: vid_logo.o
ld65 -o VID_LOGO vid_logo.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
vid_logo.o: vid_logo.s ../qload.inc \
../hgr_overlay.s ../speaker_beeps.s \
../hgr_overlay.s ../redbook_sound.s \
../init_vars.s \
graphics_vid/vid_graphics.inc
ca65 -o vid_logo.o vid_logo.s -l vid_logo.lst

View File

@ -364,7 +364,7 @@ done_page:
lda #50
sta speaker_duration
jsr speaker_beep
jsr speaker_tone
no_note:
pla ; restore Y
@ -501,7 +501,8 @@ delays:
.include "../hgr_overlay.s"
.include "../speaker_beeps.inc"
;.include "../speaker_beeps.inc"
.include "../redbook_sound.inc"
.include "../text_print.s"
.include "../gr_offsets.s"