aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-09-06 15:22:06 -0400
committerB. Watson <yalhcru@gmail.com>2016-09-06 15:22:06 -0400
commit89311623faea2da01481be7f96704a4c2b7ccc16 (patch)
tree4dc96d378581d7be46af15c146a8827266732982
parent400f7bd79c910b3d66c1f83c85cb48e6058fffcf (diff)
downloadjumpmanjr-89311623faea2da01481be7f96704a4c2b7ccc16.tar.gz
bit more work on the sound engine
-rw-r--r--jumpmanjr.dasm22
-rw-r--r--jumpmanjr.inc2
-rw-r--r--jumpmanjr.info4
-rw-r--r--main.info4
-rw-r--r--sound.txt56
5 files changed, 72 insertions, 16 deletions
diff --git a/jumpmanjr.dasm b/jumpmanjr.dasm
index 77b2963..dde3f36 100644
--- a/jumpmanjr.dasm
+++ b/jumpmanjr.dasm
@@ -1,5 +1,5 @@
; da65 V2.15 - Git 104f898
-; Created: 2016-09-05 19:01:23
+; Created: 2016-09-06 14:33:25
; Input file: jumpmanjr.rom
; Page: 1
@@ -71,7 +71,7 @@ sfx_ptr := $063C
sfx_slot_tempo := $063E ; tempo of this sfx
sfx_slot_timer := $063F
sfx_slot_duration:= $0646
-sfx_slot_freq := $0647
+sfx_slot_audc := $0647
sfx_slot_curpos := $064E ; address we've got to so far, playing this sfx
sfx_tempo_tmp := $0661 ; ??
num_tmp := $0665 ; temp used by print_number
@@ -218,7 +218,7 @@ GRACTL := $D01D
HITCLR := $D01E
CONSOL := $D01F
AUDF1_minus_two := $D1FE
-AUDF1_minus_one := $D1FF
+AUDC1_minus_two := $D1FF
AUDF1 := $D200
AUDC1 := $D201
AUDF2 := $D202
@@ -576,7 +576,7 @@ is_slot_active:
cmp sfx_slot_duration,x ; 8170 DD 46 06 .F.
bne next_sfx_slot ; 8173 D0 EA ..
lda #$00 ; 8175 A9 00 ..
- sta AUDF1_minus_one,x ; 8177 9D FF D1 ...
+ sta AUDC1_minus_two,x ; 8177 9D FF D1 ...
jmp next_sfx_slot ; 817A 4C 5F 81 L_.
; ----------------------------------------------------------------------------
@@ -590,7 +590,7 @@ sfx_next_note:
cmp #$04 ; 818B C9 04 ..
bcs sfx_play_note ; 818D B0 77 .w
cmp #$01 ; 818F C9 01 ..
- beq sfx_change_tempo ; 8191 F0 1B ..
+ beq sfx_set_audc ; 8191 F0 1B ..
cmp #$02 ; 8193 C9 02 ..
beq sfx_jump_opcode ; 8195 F0 31 .1
cmp #$03 ; 8197 C9 03 ..
@@ -601,7 +601,7 @@ sfx_next_note:
; y==0 on entry
sfx_play_rest:
tya ; 819E 98 .
- sta AUDF1_minus_one,x ; 819F 9D FF D1 ...
+ sta AUDC1_minus_two,x ; 819F 9D FF D1 ...
iny ; 81A2 C8 .
lda (zp_temp1),y ; 81A3 B1 CB ..
sta sfx_slot_timer,x ; 81A5 9D 3F 06 .?.
@@ -610,10 +610,10 @@ sfx_play_rest:
; ----------------------------------------------------------------------------
; y==0 on entry
-sfx_change_tempo:
+sfx_set_audc:
iny ; 81AE C8 .
lda (zp_temp1),y ; 81AF B1 CB ..
- sta sfx_slot_freq,x ; 81B1 9D 47 06 .G.
+ sta sfx_slot_audc,x ; 81B1 9D 47 06 .G.
iny ; 81B4 C8 .
lda (zp_temp1),y ; 81B5 B1 CB ..
sta sfx_slot_duration,x ; 81B7 9D 46 06 .F.
@@ -663,8 +663,8 @@ sfx_play_note:
iny ; 8209 C8 .
lda (zp_temp1),y ; 820A B1 CB ..
sta sfx_slot_timer,x ; 820C 9D 3F 06 .?.
- lda sfx_slot_freq,x ; 820F BD 47 06 .G.
- sta AUDF1_minus_one,x ; 8212 9D FF D1 ...
+ lda sfx_slot_audc,x ; 820F BD 47 06 .G.
+ sta AUDC1_minus_two,x ; 8212 9D FF D1 ...
clc ; 8215 18 .
lda sfx_slot_curpos,x ; 8216 BD 4E 06 .N.
adc #$02 ; 8219 69 02 i.
@@ -679,7 +679,7 @@ cpos_hi_ok:
sfx_finished:
lda #$00 ; 8226 A9 00 ..
sta sfx_slot_tempo,x ; 8228 9D 3E 06 .>.
- sta AUDF1_minus_one,x ; 822B 9D FF D1 ...
+ sta AUDC1_minus_two,x ; 822B 9D FF D1 ...
jmp next_sfx_slot ; 822E 4C 5F 81 L_.
; ----------------------------------------------------------------------------
diff --git a/jumpmanjr.inc b/jumpmanjr.inc
index 7341855..ba992fe 100644
--- a/jumpmanjr.inc
+++ b/jumpmanjr.inc
@@ -20,7 +20,7 @@ COLPF2 = $D018
HSCROL = $D404
COLBK = $D01A
AUDF1_minus_two = $D1FE
-AUDF1_minus_one = $D1FF
+AUDC1_minus_two = $D1FF
AUDF1 = $D200
AUDC1 = $D201
AUDF2 = $D202
diff --git a/jumpmanjr.info b/jumpmanjr.info
index ae933ef..d3f2e51 100644
--- a/jumpmanjr.info
+++ b/jumpmanjr.info
@@ -306,9 +306,9 @@ label { name "sfx_slot_timer"; addr $063F; size 1; };
label { name "sfx_slot_duration"; addr $0646; size 1; };
label { name "sfx_play_note"; addr $8206; size 1; comment "y==0, a>=4 on entry"; };
label { name "sfx_play_rest"; addr $819E; size 1; comment "y==0 on entry"; };
-label { name "sfx_change_tempo"; addr $81AE; size 1; comment "y==0 on entry"; };
+label { name "sfx_set_audc"; addr $81AE; size 1; comment "y==0 on entry"; };
label { name "sfx_jump_opcode"; addr $81C8; size 1; comment "I *think* this jumps to a different sfx address..."; };
-label { name "sfx_slot_freq"; addr $0647; size 1; };
+label { name "sfx_slot_audc"; addr $0647; size 1; };
range { name "sfx00"; start $BDF2; end $BE24; type bytetable; };
range { name "sfx01"; start $BE25; end $BE78; type bytetable; };
diff --git a/main.info b/main.info
index 8a49eef..9f987f2 100644
--- a/main.info
+++ b/main.info
@@ -304,9 +304,9 @@ label { name "sfx_slot_timer"; addr $063F; size 1; };
label { name "sfx_slot_duration"; addr $0646; size 1; };
label { name "sfx_play_note"; addr $8206; size 1; comment "y==0, a>=4 on entry"; };
label { name "sfx_play_rest"; addr $819E; size 1; comment "y==0 on entry"; };
-label { name "sfx_change_tempo"; addr $81AE; size 1; comment "y==0 on entry"; };
+label { name "sfx_set_audc"; addr $81AE; size 1; comment "y==0 on entry"; };
label { name "sfx_jump_opcode"; addr $81C8; size 1; comment "I *think* this jumps to a different sfx address..."; };
-label { name "sfx_slot_freq"; addr $0647; size 1; };
+label { name "sfx_slot_audc"; addr $0647; size 1; };
range { name "sfx00"; start $BDF2; end $BE24; type bytetable; };
range { name "sfx01"; start $BE25; end $BE78; type bytetable; };
diff --git a/sound.txt b/sound.txt
new file mode 100644
index 0000000..c9754e9
--- /dev/null
+++ b/sound.txt
@@ -0,0 +1,56 @@
+Most of the sounds in the game are played by a sound engine that
+runs 'in the background' (called every vblank). There are some
+exceptions:
+
+- The descending tones played as the letters materialize, on the
+ title screen (but, the music after that uses the engine).
+- The descending tone you hear as Jumpman materializes, at the
+ start of a level.
+- The sound you hear as the screen crumbles, after you lose your
+ last life.
+
+Everything else uses the engine, and is stored as a series of
+engine opcodes. I've labelled these sfx_* in the source.
+
+The engine has 2 entry points: cue_sfx and cue_sfx_lowprior. The
+difference is that the _lowprior entry point will abort, if another call
+to cue_sfx is in progress. Also the arguments are passed differently.
+Also there are _jv (jump vector) versions of both entry points, which
+are the ones most of the rest of the code uses.
+
+Example sound effect:
+
+sfx_jump:
+ .byte $01,$A5,$00,$79,$04,$60,$04,$51 ; BFBE 01 A5 00 79 04 60 04 51 ...y.`.Q
+ .byte $04,$3C,$04,$51,$04,$60,$04,$79 ; BFC6 04 3C 04 51 04 60 04 79 .<.Q.`.y
+ .byte $04,$00 ; BFCE 04 00 ..
+
+Sound opcodes:
+
+00 snd_end end of sound
+01 xx yy snd_audc set distortion and volume (AUDCx value) to xx,
+ play previous freq for yy frames.
+ yy looks to always be zero in actual use,
+ except the title screen music where it's $02.
+02 xx yy snd_jump jump to address yyxx. this is an unconditional
+ jump, meaning the sfx plays continuously until
+ preempted or silenced.
+03 xx snd_rest play a rest, xx frames (sets AUDCx to 0)
+[04-FF] xx snd_note play [opcode] frequency for xx frames
+
+so sfx_jump might look like this:
+
+sfx_jump:
+ snd_audc $A5,$00
+ snd_note $79,$04
+ snd_note $60,$04
+ snd_note $51,$04
+ snd_note $3C,$04
+ snd_note $51,$04
+ snd_note $60,$04
+ snd_note $79,$04
+ snd_end
+
+or in english: distortion $A (pure tone), volume 5. for 4 frames each,
+play 3 ascending notes, a higher note, then the same 3 notes in reverse
+order. the whole thing takes 28 frames to complete, or about 1/2 sec.