aboutsummaryrefslogtreecommitdiff
path: root/sound.txt
blob: c9754e953fa88e1d5522781d45f3d008f31c6ae2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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.