Skip to content

Instantly share code, notes, and snippets.

@jturcotte
Last active October 20, 2024 17:41
Show Gist options
  • Save jturcotte/206548ec74b77ed97adb3f4326ebe10c to your computer and use it in GitHub Desktop.
Save jturcotte/206548ec74b77ed97adb3f4326ebe10c to your computer and use it in GitHub Desktop.
Kirby's Dream Land 2 (GB) - Big Forest - #chiptrack

Kirby's Dream Land 2 (GB) - Big Forest - #chiptrack

Play this song

  • In the Chiptrack Web Player.
  • In the desktop version from a command line prompt:
    chiptrack https://gist.github.com/jturcotte/206548ec74b77ed97adb3f4326ebe10c

What is this?

This gist is a Chiptrack song encoded in Markdown. It contains the following files:

  • This file: Chiptrack looks for the first .ct.md file in the gist and parses its "Song" and "Pattern [N]" and "Settings" sections.
  • instruments.wat: Contains the compiled instruments as a WebAssembly Text file. The name must be referred from the .ct.md file's Settings section.
  • instruments.zig (Optional): This is the source code for the instruments. This is attached to the gist to allow modifying and recompiling them.
  • build.zig (Optional): A zig build file that instructs the Zig compiler how to produce instruments.wat out of instruments.zig.

Other songs?

Try the GitHub Gist search.

Song

Pattern 1

S2 T2 W2 W3 N1 N4
- G-5.0/0 C-2 0/0 - F-4.7/0 -
- E-5.0/0 - - - -
E-5.0/0 C-5.0/0 - . C-3.0/0 D-4.7/0 -
E-5.0/0 G-4.0/0 - - D-4.4/0 -
- G-5.0/0 C-2.0/0 - - G-4.13/0
- E-5.0/0 - - C#4.8/0 -
E-5.0/0 C-5.0/0 - C-3.0/0 D-4.8/0 -
E-5.0/0 G-4.0/0 - - C#4.8/0 -
- G-5.0/0 C-2.0/0 - F-4.7/0 -
- E-5.0/0 - - - -
E-5.0/0 C-5.0/0 - C-3.0/0 D-4.7/0 -
E-5.0/0 G-4.0/0 - - D-4.4/0 -
- G-5.0/0 C-2.0/0 - - G-4.13/0
- E-5.0/0 - - C#4.8/0 -
E-5.0/0 C-5.0/0 - C-3.0/0 D-4.8/0 -
E-5.0/0 G-4.0/0 - - C#4.8/0 -

Pattern 2

S2 T2 W2 W3 N1 N4
- G-5.0/0 D-2.0/0 - F-4.7/0 -
- F-5.0/0 - - - -
F-5.0/0 C-5.0/0 - D-3.0/0 D-4.7/0 -
F-5.0/0 A-4.0/0 - - D-4.4/0 -
- G-5.0/0 D-2.0/0 - - G-4.13/0
- F-5.0/0 - - C#4.8/0 -
F-5.0/0 C-5.0/0 - D-3.0/0 D-4.8/0 -
F-5.0/0 A-4.0/0 - - C#4.8/0 -
- G-5.0/0 E-2.0/0 - F-4.7/0 -
- F-5.0/0 - - - -
G-5.0/0 C-5.0/0 - E-3.0/0 D-4.7/0 -
G-5.0/0 A-4.0/0 - - D-4.4/0 -
- G-5.0/0 E-2.0/0 - - G-4.13/0
- F-5.0/0 - - C#4.8/0 -
G-5.0/0 C-5.0/0 - E-3.0/0 D-4.8/0 -
G-5.0/0 A-4.0/0 - - C#4.8/0 -

Pattern 3

S2 T2 W2 W3 N1 N4
- G-5.0/0 F-2.0/0 - F-4.7/0 -
- F-5.0/0 - - - -
A-5.0/0 C-5.0/0 - F-3.0/0 D-4.7/0 -
A-5.0/0 A-4.0/0 - - D-4.4/0 -
- G-5.0/0 F-2.0/0 - - G-4.13/0
- F-5.0/0 - - C#4.8/0 -
A-5.0/0 C-5.0/0 - F-3.0/0 D-4.8/0 -
A-5.0/0 A-4.0/0 - - C#4.8/0 -
- A-5.0/0 F#2.0/0 - F-4.7/0 -
- F#5.0/0 - - - -
A-5.0/0 C-4.0/0 - F#3.0/0 D-4.7/0 -
A-5.0/0 A-4.0/0 - - D-4.4/0 -
- A-5.0/0 F#2.0/0 - - G-4.13/0
- F#5.0/0 - - C#4.8/0 -
A-5.0/0 C-4.0/0 - F#3.0/0 D-4.8/0 -
A-5.0/0 A-4.0/0 - - C#4.8/0 -

Pattern 4

S2 T2 W2 W3 W4 N1 N4 N9
- G-5.0/0 G-2.0/0 - - F-4.7/0 - -
- F-5.0/0 - - - - - -
G-5.0/0 C-5.0/0 - G-3.0/0 - D-4.7/0 - -
G-5.0/0 A-4.0/0 - - - D-4.4/0 - -
- G-5.0/0 G-2.0/0 - - - G-4.13/0 -
- F-5.0/0 - - - C#4.8/0 - -
G-5.0/0 C-5.0/0 - G-3.0/0 - D-4.8/0 - -
G-5.0/0 A-4.0/0 - - - C#4.8/0 - -
- G-5.0/0 G-2.0/0 - - - G-4.11/0 -
- F-5.0/0 - - - - - -
- D-5.0/0 - G-3.0/0 - - G-4.11/0 -
- B-4.0/0 - - - - - -
- G-5.0/0 G-2.0/0 - - - G-4.11/0 -
- F-5.0/0 - - - - G-4.11/0 -
- D-5.0/0 - - F#3.0/0 - - C-4 0/0
- B-4.0/0 - - G-3.0/0 - - - .

Pattern 5

S3 T2 W2 W3 N1
G-5.4/0 E-5.0/0 C-2.0/0 - F-4.7/0
- C-5.0/0 - - -
E-5.1/0 C-6.0/0 - C-3.0/0 D-4.7/0
C-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 C-2.0/0 - F-4.7/0
G-4.4/0 C-5.0/0 - - -
- C-6.0/0 - C-3.0/0 D-4.7/0
G-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 C-2.0/0 - F-4.7/0
G-5.1/0 C-5.0/0 - - -
E-5.4/0 C-6.0/0 - C-3.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0
C-5.4/0 E-5.0/0 C-2.0/0 - F-4.7/0
- C-5.0/0 - - -
G-4.4/0 C-6.0/0 - C-3.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0

Pattern 6

S3 T2 W2 W3 N1
G-5.4/0 F-5.0/0 D-2.0/0 - F-4.7/0
- D-5.0/0 - - -
F-5.1/0 C-6.0/0 - D-3.0/0 D-4.7/0
D-5.4/0 D-5.0/0 - - D-4.4/0
- F-5.0/0 D-2.0/0 - F-4.7/0
A-4.4/0 D-5.0/0 - - -
- C-6.0/0 - D-3.0/0 D-4.7/0
G-5.4/0 D-5.0/0 - - D-4.4/0
- F-5.0/0 D-2.0/0 - F-4.7/0
G-5.1/0 D-5.0/0 - - -
F-5.4/0 C-6.0/0 - D-3.0/0 D-4.7/0
- D-5.0/0 - - D-4.4/0
D-5.4/0 F-5.0/0 D-2.0/0 - F-4.7/0
- D-5.0/0 - - -
A-4.4/0 C-6.0/0 - D-3.0/0 D-4.7/0
- D-5.0/0 - - D-4.4/0

Pattern 7

S3 T2 W2 W3 N1
F-5.4/0 E-5.0/0 A-1.0/0 - F-4.7/0
- C-5.0/0 - - -
E-5.1/0 A-5.0/0 - A-2.0/0 D-4.7/0
C-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 A-1.0/0 - F-4.7/0
G-4.4/0 C-5.0/0 - - -
- A-5.0/0 - A-2.0/0 D-4.7/0
F-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 A-1.0/0 - F-4.7/0
F-5.1/0 C-5.0/0 - - -
E-5.4/0 A-5.0/0 - A-2.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0
C-5.3/0 E-5.0/0 A-1.0/0 - F-4.7/0
E-4.3/0 C-5.0/0 - - -
A-4.3/0 A-5.0/0 - A-2.0/0 D-4.7/0
G-4.3/0 C-5.0/0 - - D-4.4/0

Pattern 8

S3 S9 S10 T2 W2 W3 N1
F#4 15/0 - - F#5.0/0 D-1.0/0 - F-4.7/0
- - - D-5.0/0 - - -
- . - - C-6.0/0 - D-2.0/0 D-4.7/0
- - - D-5.0/0 - - D-4.4/0
- D#5.0/0 - F#5.0/0 D-1.0/0 - F-4.7/0
- - E-5.0/0 D-5.0/0 - - -
- - - C-6.0/0 - D-2.0/0 D-4.7/0
D-5 10/0 - - D-5.0/0 - - D-4.4/0
- . - - A-5.0/0 G-1.0/0 - F-4.7/0
- - - D-5.0/0 - - -
- - - C-6.0/0 - G-2.0/0 D-4.7/0
- - - D-5.0/0 - - D-4.4/0
D-5.1/0 - - B-5.0/0 G-1.0/0 - F-4.7/0
E-5.1/0 - - G-5.0/0 - - -
F-5 7/0 - - D-6.0/0 - G-2.0/0 D-4.7/0
- . - - G-5.0/0 - - D-4.4/0

Pattern 9

S16 S26 T2 W2 W3 N1
- G-5 13/0 E-5.0/0 C-2.0/0 - F-4.7/0
- - C-5.0/0 - - -
- - . C-6.0/0 - C-3.0/0 D-4.7/0
- - C-5.0/0 - - D-4.4/0
- - E-5.0/0 C-2.0/0 - F-4.7/0
- E-5.3/0 C-5.0/0 - - -
- F-5.3/0 C-6.0/0 - C-3.0/0 D-4.7/0
- G-5.3/0 C-5.0/0 - - D-4.4/0
- C-6 8/0 E-5.0/0 C-2.0/0 - F-4.7/0
- - . C-5.0/0 - - -
- G-5.3/0 C-6.0/0 - C-3.0/0 D-4.7/0
- F-5 8/0 C-5.0/0 - - D-4.4/0
- - . E-5.0/0 C-2.0/0 - F-4.7/0
E-5.0/0 - C-5.0/0 - - -
- - C-6.0/0 - C-3.0/0 D-4.7/0
- - C-5.0/0 - - D-4.4/0

Pattern 10

S26 T2 W2 W3 N1
E-5 8/0 F-5.0/0 D-2.0/0 - F-4.7/0
- . C-5.0/0 - - -
F-5.3/0 C-6.0/0 - D-3.0/0 D-4.7/0
A-4.3/0 C-5.0/0 - - D-4.4/0
- F-5.0/0 D-2.0/0 - F-4.7/0
A-4.3/0 C-5.0/0 - - -
B-4.3/0 C-6.0/0 - D-3.0/0 D-4.7/0
C-5.3/0 C-5.0/0 - - D-4.4/0
G-5 9/0 F-5.0/0 D-2.0/0 - F-4.7/0
- . C-5.0/0 - - -
F-5.5/0 C-6.0/0 - D-3.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0
E-5.3/0 F-5.0/0 D-2.0/0 - F-4.7/0
F-5 14/0 C-5.0/0 - - -
- C-6.0/0 - D-3.0/0 D-4.7/0
- . C-5.0/0 - - D-4.4/0

Pattern 11

S26 T2 T3 T4 W4 W5 W6 N1
E-5 17/0 F-5.0/0 - - - G-1 0/0 - F-4.7/0
- C-5.0/0 - - - - . - -
- C-6.0/0 - - - G-2 0/0 - D-4.7/0
- . C-5.0/0 - - - - . - D-4.4/0
D-5 18/0 F-5.0/0 - - - G-1 0/0 - F-4.7/0
- C-5.0/0 - - - - . - -
- C-6.0/0 - - - G-2 0/0 - D-4.7/0
- . C-5.0/0 - - - - . - D-4.4/0
C-5 18/0 - A-5.0/0 - - A-1 0/0 - F-4.7/0
- - A-5.0/0 - - - . - -
- - - G-5.0/0 - - A-2.0/0 D-4.7/0
- . - - - - - - D-4.4/0
C#5.3/0 - - F-5.0/0 - B-1 0/0 - F-4.7/0
D-5 9/0 - - - - - . - -
- . - - G-5.0/0 G-2.0/0 - - D-4.7/0
C-5 45/0 - - - G-1.0/0 - - D-4.4/0

Pattern 12

S26 S27 T5 W2 W5 N1 N15
- - G#5.0/0 - G#1 0/0 F-4.7/0 -
- - D#5.0/0 - - . - -
- - G#5.0/0 - G#2 0/0 D-4.7/0 -
- - C-6.0/0 - - . D-4.4/0 -
- - A#5.0/0 - A#1 0/0 F-4.7/0 -
- - F-5.0/0 - - . - -
- - A#5.0/0 - A#2 0/0 D-4.7/0 -
- . - D-6.0/0 - - . D-4.4/0 -
- C-4.0/0 E-6.0/0 C-2.0/0 - C-4.4/7 -
- C-4.0/0 G-5.0/0 - - C#4.12/0 -
- - G-6.0/0 - C-3 0/0 C-4.12/7 -
- C-4.0/0 C-7.0/0 - - . D-4.7/0 -
- - - - - - -
- - - - - C#4.10/0 -
- - - - - - C-4 0/0
- - - - - - - .

Pattern 13

S3 T2 W2 W3 N1
G-5.4/0 E-5.0/0 C-2.0/0 - F-4.7/0
- C-5.0/0 - - -
E-5.1/0 C-6.0/0 - C-3.0/0 D-4.7/0
C-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 C-2.0/0 - F-4.7/0
G-4.4/0 C-5.0/0 - - -
- C-6.0/0 - C-3.0/0 D-4.7/0
G-5.4/0 C-5.0/0 - - D-4.4/0
- E-5.0/0 C-2.0/0 - F-4.7/0
G-5.1/0 C-5.0/0 - - -
E-5.4/0 C-6.0/0 - C-3.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0
C-5.4/0 E-5.0/0 C-2.0/0 - F-4.7/0
- C-5.0/0 - - -
G-4.4/0 C-6.0/0 - C-3.0/0 D-4.7/0
- C-5.0/0 - - D-4.4/0

Pattern 14

S26 S27 T5 W2 W5 N1
- - G#5.0/0 - G#1 0/0 F-4.7/0
- - D#5.0/0 - - . -
- - G#5.0/0 - G#2 0/0 D-4.7/0
- - C-6.0/0 - - . D-4.4/0
- - A#5.0/0 - A#1 0/0 F-4.7/0
- - F-5.0/0 - - . -
- - A#5.0/0 - A#2 0/0 D-4.7/0
- . - D-6.0/0 - - . D-4.4/0
- C-4.0/0 E-6.0/0 C-2.0/0 - C-4.4/7
- C-4.0/0 G-5.0/0 - - C#4.12/0
- - G-6.0/0 - C-3 0/0 C-4.12/7
- C-4.0/0 C-7.0/0 - - . D-4.7/0
- - - - - -
- - - - - -
- - - - - -
- - - - - -

Pattern 15

S43 S48 T9 W9 W11 W12 N1
G#5 0/0 - G-4.0/0 - - G#2.0/0 C-4.11/7
- - C-4.0/0 - - - -
- - D#4.0/0 C-3.0/0 - - D-4.11/0
- - C-4.0/0 - - - C#4.11/0
- - G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - C-4.0/0 - - - C#4.11/0
- - G-4.0/0 G#3.0/0 - - C-4.11/7
G#5.0/1 - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - C-4.0/0 - - - C#4.11/0
- A#5.5/0 G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- C-6.5/0 D#4.0/0 - G#2 0/0 - D-4.11/0
- - C-4.0/0 - - - C#4.11/0

Pattern 16

S43 S48 T9 W9 W11 W12 N1
- D#6 20/0 G-4.0/0 - - . G#2 0/0 C-4.11/7
- - C-4.0/0 - - - -
- - D#4.0/0 C-3.0/0 - - . D-4.11/0
- - . C-4.0/0 - - - C#4.11/0
- D-6 20/0 G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - . C-4.0/0 - - - C#4.11/0
- C-6 20/0 G-4.0/0 G#3.0/0 - - C-4.11/7
- - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - . C-4.0/0 - - - C#4.11/0
D-6 3/1 - G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- . - D#4.0/0 - G#2.0/0 - D-4.11/0
- - C-4.0/0 - - - C#4.11/0

Pattern 17

S35 S43 S48 T9 W9 W11 W12 N1
- D-6 3/0 - F-4.0/0 - - D#2.0/0 C-4.11/7
- - . - A#3.0/0 - - - -
- - - D-4.0/0 G-2.0/0 - - D-4.11/0
- - F-6.5/0 A#3.0/0 - - - C#4.11/0
- - - F-4.0/0 A#2.0/0 - - D#4.11/0
- - - A#3.0/0 - - - -
- - D#6 11/0 D-4.0/0 D-3.0/0 - - D-4.11/0
- - - . A#3.0/0 - - - C#4.11/0
A#5 0/0 - - F-4.0/0 D#3.0/0 - - C-4.11/7
- - - A#3.0/0 - - - -
- - - D-4.0/0 D-3.0/0 - - D-4.11/0
- - - A#3.0/0 - - - C#4.11/0
- - - F-4.0/0 A#2.0/0 - - D#4.11/0
- - - A#3.0/0 - - - -
- - - D-4.0/0 - D#2 0/0 - D-4.11/0
- - - A#3.0/0 - - - C#4.11/0

Pattern 18

S35 T9 W9 W11 W12 N1 N20
- F-4.0/0 - - . D#2 0/0 C-4.11/7 -
- A#3.0/0 - - - - -
- D-4.0/0 G-2.0/0 - - . D-4.11/0 -
- A#3.0/0 - - - C#4.11/0 -
- F-4.0/0 A#2.0/0 - - D#4.11/0 -
- A#3.0/0 - - - - -
- D-4.0/0 D-3.0/0 - - D-4.11/0 -
- A#3.0/0 - - - C#4.11/0 -
- F-4.0/0 D#3.0/0 - - C-4.11/7 -
- A#3.0/0 - - - - -
- D-4.0/0 D-3.0/0 - - D-4.11/0 -
- A#3.0/0 - - - C#4.11/0 -
- F-4.0/0 A#2.0/0 - - - C-4 0/0
- A#3.0/0 - - - - - .
- D-4.0/0 - D#2.0/0 - D-4.12/0 -
- . A#3.0/0 - - - C#4.12/0 -

Pattern 19

S43 S48 T9 W9 W11 W12 N1
F-5 3/1 - D#4.0/0 - - G#2.0/0 C-4.11/7
- - A#3.0/0 - - - -
- - C-4.0/0 C-3.0/0 - - D-4.11/0
- - G#3.0/0 - - - C#4.11/0
- - D#4.0/0 D#3.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- - C-4.0/0 G-3.0/0 - - D-4.11/0
- - G#3.0/0 - - - C#4.11/0
- . - D#4.0/0 G#3.0/0 - - C-4.11/7
- - A#3.0/0 - - - -
F-5.1/1 - C-4.0/0 G-3.0/0 - - D-4.11/0
- - G#3.0/0 - - - C#4.11/0
- G-5.5/0 D#4.0/0 D#3.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- G#5.5/0 C-4.0/0 - G#2 0/0 - D-4.11/0
- - G#3.0/0 - - - C#4.11/0

Pattern 20

S43 S48 T9 W9 W11 W12 N1
- C-6 20/0 D#4.0/0 - - . G#2 0/0 C-4.11/7
- - A#3.0/0 - - - -
- - C-4.0/0 C-3.0/0 - - . D-4.11/0
- - . G#3.0/0 - - - C#4.11/0
- A#5 20/0 D#4.0/0 D#3.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- - C-4.0/0 G-3.0/0 - - D-4.11/0
- - . G#3.0/0 - - - C#4.11/0
- G#5 20/0 D#4.0/0 G#3.0/0 - - C-4.11/7
- - A#3.0/0 - - - -
- - C-4.0/0 G-3.0/0 - - D-4.11/0
- - . G#3.0/0 - - - C#4.11/0
A#5 3/1 - D#4.0/0 D#3.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- . - C-4.0/0 - G#2.0/0 - D-4.11/0
- - G#3.0/0 - - - C#4.11/0

Pattern 21

S35 S48 T9 W9 W11 W12 N1
- G#5 14/0 F-4.0/0 - - D#2.0/0 C-4.11/7
- - A#3.0/0 - - - -
- - . D-4.0/0 G-2.0/0 - - D-4.11/0
- G-5.5/0 G-3.0/0 - - - C#4.11/0
- - F-4.0/0 A#2.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- F-5 12/0 D-4.0/0 D-3.0/0 - - D-4.11/0
- - G-3.0/0 - - - C#4.11/0
- G#5 18/0 F-4.0/0 D#3.0/0 - - C-4.11/7
- - A#3.0/0 - - - -
- - D-4.0/0 D-3.0/0 - - D-4.11/0
- - . G-3.0/0 - - - C#4.11/0
G-5 0/0 - F-4.0/0 A#2.0/0 - - D#4.11/0
- - A#3.0/0 - - - -
- - D-4.0/0 - D#2 0/0 - D-4.11/0
- - G-3.0/0 - - - C#4.11/0

Pattern 22

S35 T9 W9 W11 W12 N1 N20
- F-4.0/0 - - . D#2 0/0 C-4.11/7 -
- A#3.0/0 - - - - -
- D-4.0/0 G-2.0/0 - - . D-4.11/0 -
- G-3.0/0 - - - C#4.11/0 -
- F-4.0/0 A#2.0/0 - - D#4.11/0 -
- A#3.0/0 - - - - -
- D-4.0/0 D-3.0/0 - - D-4.11/0 -
- G-3.0/0 - - - C#4.11/0 -
- F-4.0/0 D#3.0/0 - - C-4.11/7 -
- A#3.0/0 - - - - -
- D-4.0/0 D-3.0/0 - - D-4.11/0 -
- G-3.0/0 - - - C#4.11/0 -
- F-4.0/0 A#2.0/0 - - - C-4 0/0
- A#3.0/0 - - - - - .
- D-4.0/0 - D#2.0/0 - D-4.12/0 -
- . G-3.0/0 - - - C#4.12/0 -

Pattern 23

S43 S48 T9 W9 W11 W12 N1
C-6 4/8 - G-4.0/0 - - G#2.0/0 C-4.11/7
- - C-4.0/0 - - - -
- - D#4.0/0 C-3.0/0 - - D-4.11/0
- - A#3.0/0 - - - C#4.11/0
- - G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - A#3.0/0 - - - C#4.11/0
- . - G-4.0/0 G#3.0/0 - - C-4.11/7
- - C-4.0/0 - - - -
- - D#4.0/0 G-3.0/0 - - D-4.11/0
- - A#3.0/0 - - - C#4.11/0
- D-6.5/0 G-4.0/0 D#3.0/0 - - D#4.11/0
- - C-4.0/0 - - - -
- D#6.5/0 D#4.0/0 - G#2 0/0 - D-4.11/0
- - A#3.0/0 - - - C#4.11/0

Pattern 24

S43 T9 W9 W11 W12 N1
G-6 3/1 G-4.0/0 - - . G#2 0/0 C-4.11/7
- C-4.0/0 - - - -
- . D#4.0/0 C-3.0/0 - - . D-4.11/0
- A#3.0/0 - - - C#4.11/0
F-6 3/1 G-4.0/0 D#3.0/0 - - D#4.11/0
- C-4.0/0 - - - -
- . D#4.0/0 G-3.0/0 - - D-4.11/0
- A#3.0/0 - - - C#4.11/0
D#6 3/1 G-4.0/0 G#3.0/0 - - C-4.11/7
- C-4.0/0 - - - -
- . D#4.0/0 G-3.0/0 - - D-4.11/0
- A#3.0/0 - - - C#4.11/0
F-6 3/1 G-4.0/0 D#3.0/0 - - D#4.11/0
- C-4.0/0 - - - -
- . D#4.0/0 - G#2.0/0 - D-4.11/0
- A#3.0/0 - - - C#4.11/0

Pattern 25

S43 T9 W9 W11 W12 N1
G-6 3/8 G-4.0/0 - - G-2.0/0 C-4.11/7
- D-4.0/0 - - - -
- A#4.0/0 A#2.0/0 - - D-4.11/0
- F-4.0/0 - - - C#4.11/0
- G-4.0/0 D-3.0/0 - - D#4.11/0
- D-4.0/0 - - - -
- . A#4.0/0 F-3.0/0 - - D-4.11/0
- F-4.0/0 - - - C#4.11/0
D-6 2/8 G-4.0/0 G-3.0/0 - - C-4.11/7
- . D-4.0/0 - - - -
- A#4.0/0 F-3.0/0 - - D-4.11/0
G-6 2/8 F-4.0/0 - - - C#4.11/0
- . G-4.0/0 D-3.0/0 - - D#4.11/0
- D-4.0/0 - - - -
D-6 2/8 A#4.0/0 - G-2 0/0 - D-4.11/0
- . F-4.0/0 - - - C#4.11/0

Pattern 26

S43 T9 W9 W11 W12 N1 N20
F-6 3/8 G-4.0/0 - - . G-2 0/0 C-4.11/7 -
- D-4.0/0 - - - - -
- A#4.0/0 A#2.0/0 - - . D-4.11/0 -
- F-4.0/0 - - - C#4.11/0 -
- G-4.0/0 D-3.0/0 - - D#4.11/0 -
- D-4.0/0 - - - - -
- . A#4.0/0 F-3.0/0 - - D-4.11/0 -
- F-4.0/0 - - - C#4.11/0 -
D#6 3/8 G-4.0/0 G-3.0/0 - - C-4.11/7 -
- D-4.0/0 - - - - -
- A#4.0/0 F-3.0/0 - - D-4.11/0 -
- F-4.0/0 - - - C#4.11/0 -
- G-4.0/0 D-3.0/0 - - - C-4 0/0
- D-4.0/0 - - - - - .
- . A#4.0/0 - G-2.0/0 - D-4.12/0 -
- F-4.0/0 - - - C#4.12/0 -

Pattern 27

S43 T12 W2 W5 N1
C-6 3/8 D#5.0/0 G#1.0/0 - F-4.7/0
- C-5.0/0 - - -
- G#4.0/0 - G#2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
- D#5.0/0 G#1.0/0 - F-4.7/0
- C-5.0/0 - - -
- . G#4.0/0 - G#2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
C-6 2/8 D#5.0/0 G#1.0/0 - F-4.7/0
- . C-5.0/0 - - -
- G#4.0/0 - G#2 0/0 D-4.7/0
D-6 2/8 C-5.0/0 - - . D-4.4/0
- . D#5.0/0 G#1.0/0 - F-4.7/0
- C-5.0/0 - - -
D#6 2/8 G#4.0/0 - G#2 0/0 D-4.7/0
- . C-5.0/0 - - . D-4.4/0

Pattern 28

S43 T12 W2 W5 N1
G-6 3/1 D#5.0/0 F-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- . G#4.0/0 - F-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
F-6 3/1 D#5.0/0 F-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- . G#4.0/0 - F-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
D#6 3/1 D#5.0/0 F-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- . G#4.0/0 - F-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
F-6 3/1 D#5.0/0 F-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- . G#4.0/0 - F-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0

Pattern 29

S48 T12 W2 W5 N1
G-6 -98/0 F-5.0/0 G-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- A-4.0/0 - G-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- A-4.0/0 - G-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- A-4.0/0 - G-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - F-4.7/0
- C-5.0/0 - - -
- A-4.0/0 - G-2 0/0 D-4.7/0
- C-5.0/0 - - . D-4.4/0

Pattern 30

S48 T12 W2 W5 N1
- F-5.0/0 G-1.0/0 - F-4.7/0
- B-4.0/0 - - -
- G-4.0/0 - G-2 0/0 D-4.7/0
- D-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - F-4.7/0
- B-4.0/0 - - -
- G-4.0/0 - G-2 0/0 D-4.7/0
- D-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - F-4.7/0
- B-4.0/0 - - -
- G-4.0/0 - G-2 0/0 D-4.7/0
- D-5.0/0 - - . D-4.4/0
- F-5.0/0 G-1.0/0 - C-4.4/7
- B-4.0/0 - - C#4.12/0
- G-4.0/0 - G-2 0/0 C-4.12/7
- . D-5.0/0 - - . D-4.7/0

Settings

  • InstrumentsFile: instruments.wat
  • FramesPerStep: 5
// Copyright © 2024 Jocelyn Turcotte <[email protected]>
// SPDX-License-Identifier: CC0-1.0
//
// After modifying the instruments Zig source code, you must re-compile the WebAssembly file that can be executed by Chiptrack.
// This file instructs the Zig compiler how to compile it and for this you need
// - The Zig 0.13 compiler, available at https://ziglang.org/download/
// - ct.zig, the Chiptrack instruments support module, available at https://raw.githubusercontent.com/jturcotte/chiptrack/v0.4/instruments/ct.zig
// - wasm2wat in your PATH, available at https://github.com/WebAssembly/wabt/releases
//
// Then to rebuild the instruments .wat file from modified source code:
// zig build
//
// The compiled instruments.wat file will be in the source folder, beside the zig file.
// Chiptrack will reload it automatically if the song is currently loaded.
const std = @import("std");
pub fn build(b: *std.Build) void {
// Build options, "zig build --help" will show their usage.
const source_file =
b.option([]const u8, "source", "Instruments source file to compile (default: instruments.zig).") orelse "instruments.zig";
const ct_zig_path =
b.option([]const u8, "ct.zig", "Path to ct.zig (default: ct.zig).") orelse "ct.zig";
const wat_out =
b.option(bool, "wat", "Compile the instruments to WAT (Web Assembly Text Format) instead of binary WASM. Chiptrack can load either format but this is better for GitHub gist uploads and requires wasm2wat in PATH (default: true).") orelse true;
if (std.fs.cwd().access(ct_zig_path, .{}) == std.fs.Dir.AccessError.FileNotFound)
@panic("ct.zig was not found but is necessary to build. You can download it from https://raw.githubusercontent.com/jturcotte/chiptrack/v0.4/instruments/ct.zig .");
// Listing the module here also allows editors like VSCode with Zig language support to discover it and provide code completion.
const ct_module = b.addModule("ct", .{ .root_source_file = .{ .cwd_relative = ct_zig_path } });
// Build the wasm file.
const wasm = b.addExecutable(.{
.name = std.fs.path.stem(source_file),
.root_source_file = .{ .cwd_relative = source_file },
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.optimize = .ReleaseFast,
});
wasm.rdynamic = true;
wasm.export_table = true;
wasm.max_memory = 65536;
wasm.stack_size = 8192;
wasm.root_module.addImport("ct", ct_module);
const wf = b.addWriteFiles();
b.getInstallStep().dependOn(&wf.step);
if (wat_out) {
// Generate the wat file by calling wasm2wat on the compiled wasm.
const wasm2wat = b.addSystemCommand(&.{ "wasm2wat", "-f" });
wasm2wat.addFileArg(wasm.getEmittedBin());
const final_url = std.fmt.allocPrint(b.allocator, "{s}.wat", .{wasm.name}) catch unreachable;
// Copy the output wat file into the source folder, beside the zig file.
wf.addCopyFileToSource(wasm2wat.captureStdOut(), final_url);
} else {
// Copy the wasm file into the source folder, beside the zig file.
wf.addCopyFileToSource(wasm.getEmittedBin(), std.fmt.allocPrint(b.allocator, "{s}.wasm", .{wasm.name}) catch unreachable);
}
}
(module $instruments.wasm
(type (;0;) (func (param i32 i32 i32 i32 i32 i32) (result i32)))
(type (;1;) (func (param i32 i32 i32 i32 i32 i32 i32)))
(type (;2;) (func (param i32 i32)))
(type (;3;) (func))
(type (;4;) (func (param i32 i32 i32 i32)))
(type (;5;) (func (param i32 i32 i32)))
(import "env" "set_instrument_at_column" (func $set_instrument_at_column (type 0)))
(import "env" "define_param" (func $define_param (type 1)))
(import "env" "gba_set_sound_reg" (func $gba_set_sound_reg (type 2)))
(import "env" "gba_set_wave_table" (func $gba_set_wave_table (type 2)))
(func $_start (type 3)
(local i32)
(drop
(call $set_instrument_at_column
(i32.const 8281)
(i32.const 0)
(i32.const 0)
(i32.const 1)
(i32.const 0)
(i32.const 2)))
(call $define_param
(i32.and
(call $set_instrument_at_column
(i32.const 8268)
(i32.const 0)
(i32.const 0)
(i32.const 3)
(i32.const 4)
(i32.const 5))
(i32.const 255))
(i32.const 0)
(i32.const 8307)
(i32.const 4)
(i32.const 0)
(i32.const 127)
(i32.const 0))
(drop
(call $set_instrument_at_column
(i32.const 8214)
(i32.const 0)
(i32.const 0)
(i32.const 6)
(i32.const 0)
(i32.const 7)))
(drop
(call $set_instrument_at_column
(i32.const 8303)
(i32.const 0)
(i32.const 0)
(i32.const 8)
(i32.const 0)
(i32.const 9)))
(drop
(call $set_instrument_at_column
(i32.const 8235)
(i32.const 0)
(i32.const 0)
(i32.const 10)
(i32.const 0)
(i32.const 11)))
(call $define_param
(i32.and
(call $set_instrument_at_column
(i32.const 8231)
(i32.const 0)
(i32.const 0)
(i32.const 12)
(i32.const 4)
(i32.const 13))
(i32.const 255))
(i32.const 0)
(i32.const 8307)
(i32.const 4)
(i32.const 0)
(i32.const 127)
(i32.const 0))
(drop
(call $set_instrument_at_column
(i32.const 8224)
(i32.const 0)
(i32.const 0)
(i32.const 14)
(i32.const 0)
(i32.const 15)))
(drop
(call $set_instrument_at_column
(i32.const 8245)
(i32.const 0)
(i32.const 0)
(i32.const 16)
(i32.const 0)
(i32.const 17)))
(call $define_param
(local.tee 0
(i32.and
(call $set_instrument_at_column
(i32.const 8271)
(i32.const 0)
(i32.const 16)
(i32.const 18)
(i32.const 19)
(i32.const 20))
(i32.const 255)))
(i32.const 0)
(i32.const 8350)
(i32.const 4)
(i32.const 0)
(i32.const 8)
(i32.const 0))
(call $define_param
(local.get 0)
(i32.const 1)
(i32.const 8326)
(i32.const 8)
(i32.const 1)
(i32.const 8)
(i32.const 0))
(call $define_param
(i32.and
(call $set_instrument_at_column
(i32.const 8220)
(i32.const 0)
(i32.const 0)
(i32.const 21)
(i32.const 0)
(i32.const 22))
(i32.const 255))
(i32.const 0)
(i32.const 8307)
(i32.const -98)
(i32.const -128)
(i32.const 127)
(i32.const 0))
(drop
(call $set_instrument_at_column
(i32.const 8278)
(i32.const 1)
(i32.const 0)
(i32.const 23)
(i32.const 0)
(i32.const 24)))
(drop
(call $set_instrument_at_column
(i32.const 8265)
(i32.const 1)
(i32.const 0)
(i32.const 25)
(i32.const 0)
(i32.const 26)))
(drop
(call $set_instrument_at_column
(i32.const 8256)
(i32.const 1)
(i32.const 0)
(i32.const 25)
(i32.const 0)
(i32.const 27)))
(drop
(call $set_instrument_at_column
(i32.const 8242)
(i32.const 1)
(i32.const 0)
(i32.const 28)
(i32.const 0)
(i32.const 29)))
(drop
(call $set_instrument_at_column
(i32.const 8211)
(i32.const 1)
(i32.const 0)
(i32.const 30)
(i32.const 0)
(i32.const 31)))
(drop
(call $set_instrument_at_column
(i32.const 8288)
(i32.const 1)
(i32.const 0)
(i32.const 32)
(i32.const 0)
(i32.const 33)))
(drop
(call $set_instrument_at_column
(i32.const 8275)
(i32.const 2)
(i32.const 0)
(i32.const 34)
(i32.const 0)
(i32.const 35)))
(drop
(call $set_instrument_at_column
(i32.const 8262)
(i32.const 2)
(i32.const 0)
(i32.const 36)
(i32.const 0)
(i32.const 37)))
(drop
(call $set_instrument_at_column
(i32.const 8253)
(i32.const 2)
(i32.const 0)
(i32.const 34)
(i32.const 0)
(i32.const 38)))
(drop
(call $set_instrument_at_column
(i32.const 8239)
(i32.const 2)
(i32.const 0)
(i32.const 34)
(i32.const 0)
(i32.const 39)))
(drop
(call $set_instrument_at_column
(i32.const 8228)
(i32.const 2)
(i32.const 0)
(i32.const 34)
(i32.const 0)
(i32.const 40)))
(drop
(call $set_instrument_at_column
(i32.const 8208)
(i32.const 2)
(i32.const 0)
(i32.const 41)
(i32.const 0)
(i32.const 42)))
(drop
(call $set_instrument_at_column
(i32.const 8295)
(i32.const 2)
(i32.const 0)
(i32.const 43)
(i32.const 0)
(i32.const 44)))
(drop
(call $set_instrument_at_column
(i32.const 8284)
(i32.const 2)
(i32.const 0)
(i32.const 45)
(i32.const 0)
(i32.const 38)))
(call $define_param
(local.tee 0
(i32.and
(call $set_instrument_at_column
(i32.const 8292)
(i32.const 3)
(i32.const 0)
(i32.const 46)
(i32.const 0)
(i32.const 47))
(i32.const 255)))
(i32.const 0)
(i32.const 8201)
(i32.const 11)
(i32.const 0)
(i32.const 15)
(i32.const 0))
(call $define_param
(local.get 0)
(i32.const 1)
(i32.const 8192)
(i32.const 0)
(i32.const 0)
(i32.const 7)
(i32.const 0))
(call $define_param
(local.tee 0
(i32.and
(call $set_instrument_at_column
(i32.const 8259)
(i32.const 3)
(i32.const 0)
(i32.const 48)
(i32.const 0)
(i32.const 49))
(i32.const 255)))
(i32.const 0)
(i32.const 8201)
(i32.const 11)
(i32.const 0)
(i32.const 15)
(i32.const 0))
(call $define_param
(local.get 0)
(i32.const 1)
(i32.const 8192)
(i32.const 0)
(i32.const 0)
(i32.const 7)
(i32.const 0))
(drop
(call $set_instrument_at_column
(i32.const 8217)
(i32.const 3)
(i32.const 0)
(i32.const 50)
(i32.const 0)
(i32.const 51)))
(drop
(call $set_instrument_at_column
(i32.const 8249)
(i32.const 3)
(i32.const 0)
(i32.const 52)
(i32.const 0)
(i32.const 53)))
(drop
(call $set_instrument_at_column
(i32.const 8299)
(i32.const 3)
(i32.const 0)
(i32.const 54)
(i32.const 0)
(i32.const 55))))
(func $instruments.square1_2.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16512))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_2.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.ne
(local.get 2)
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 128))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square1_3.press (type 4) (param i32 i32 i32 i32)
(i32.store8 offset=8524
(i32.const 0)
(local.get 2))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 32896))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_26.release (type 5) (param i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 128))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_3.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 128))
(block ;; label = @1
(block ;; label = @2
(br_if 0 (;@2;)
(i64.ge_s
(i64.extend_i32_u
(local.get 2))
(i64.load8_s offset=8524
(i32.const 0))))
(br_if 1 (;@1;)
(i32.lt_u
(local.get 2)
(i32.const 2)))
(br_if 1 (;@1;)
(i32.sub
(local.tee 2
(i32.add
(local.get 2)
(i32.const -2)))
(i32.mul
(local.tee 2
(i32.div_u
(local.get 2)
(i32.const 3)))
(i32.const 3))))
(local.set 3
(i32.or
(i32.and
(i32.sub
(i32.const 24576)
(i32.shl
(local.get 2)
(i32.const 12)))
(i32.const 61440))
(i32.const 128))))
(call $gba_set_sound_reg
(i32.const 67108962)
(local.get 3))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square1_9.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 32896))
(call $gba_set_sound_reg
(i32.const 67108964)
(local.tee 0
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(local.get 0)
(i32.const 32768))))
(func $instruments.square1_9.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.ne
(local.get 2)
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.and
(i32.sub
(i32.const 12)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))))
(func $instruments.square1_10.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24704))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_10.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 20608))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 0 (;@3;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -3))))
(local.set 3
(i32.const 128)))
(call $gba_set_sound_reg
(i32.const 67108962)
(local.get 3))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square1_16.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28864))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_16.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.ne
(local.get 2)
(i32.const 1)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square1_26.press (type 4) (param i32 i32 i32 i32)
(i32.store8 offset=8528
(i32.const 0)
(local.get 2))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28864))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_26.frame (type 5) (param i32 i32 i32)
(local i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_if 0 (;@3;)
(i64.lt_s
(i64.extend_i32_u
(local.get 2))
(i64.load8_s offset=8528
(i32.const 0))))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 128))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 1 (;@2;)))
(block ;; label = @3
(br_if 0 (;@3;)
(i32.and
(local.tee 3
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 15)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.or
(i32.and
(i32.sub
(i32.const 16384)
(i32.shl
(local.get 3)
(i32.const 8)))
(i32.const 61440))
(i32.const 128)))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(br_if 1 (;@1;)
(i32.rem_u
(local.get 2)
(i32.const 3)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.add
(i32.and
(local.get 2)
(i32.const 1))
(i32.div_u
(i32.const 33554432)
(local.get 0))))
(i32.const 2047))))
(call $gba_set_sound_reg
(i32.const 67108964)
(local.get 2))))
(func $instruments.square1_27.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 61632))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_27.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 49280))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(block ;; label = @4
(br_table 2 (;@2;) 0 (;@4;) 3 (;@1;) 1 (;@3;) 3 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(local.set 3
(i32.const 16512))
(br 1 (;@2;)))
(local.set 3
(i32.const 128)))
(call $gba_set_sound_reg
(i32.const 67108962)
(local.get 3))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square1_35.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_35.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(block ;; label = @4
(block ;; label = @5
(block ;; label = @6
(block ;; label = @7
(block ;; label = @8
(block ;; label = @9
(block ;; label = @10
(block ;; label = @11
(block ;; label = @12
(block ;; label = @13
(block ;; label = @14
(block ;; label = @15
(block ;; label = @16
(block ;; label = @17
(block ;; label = @18
(block ;; label = @19
(block ;; label = @20
(block ;; label = @21
(block ;; label = @22
(block ;; label = @23
(block ;; label = @24
(block ;; label = @25
(block ;; label = @26
(block ;; label = @27
(block ;; label = @28
(block ;; label = @29
(block ;; label = @30
(block ;; label = @31
(block ;; label = @32
(block ;; label = @33
(block ;; label = @34
(block ;; label = @35
(block ;; label = @36
(block ;; label = @37
(block ;; label = @38
(block ;; label = @39
(block ;; label = @40
(block ;; label = @41
(block ;; label = @42
(block ;; label = @43
(block ;; label = @44
(block ;; label = @45
(br_table 0 (;@45;) 1 (;@44;) 2 (;@43;) 3 (;@42;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 4 (;@41;) 44 (;@1;) 44 (;@1;) 5 (;@40;) 44 (;@1;) 44 (;@1;) 6 (;@39;) 44 (;@1;) 44 (;@1;) 7 (;@38;) 8 (;@37;) 44 (;@1;) 9 (;@36;) 44 (;@1;) 44 (;@1;) 10 (;@35;) 44 (;@1;) 44 (;@1;) 11 (;@34;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 44 (;@1;) 12 (;@33;) 44 (;@1;) 44 (;@1;) 13 (;@32;) 44 (;@1;) 44 (;@1;) 14 (;@31;) 44 (;@1;) 44 (;@1;) 15 (;@30;) 44 (;@1;) 44 (;@1;) 16 (;@29;) 44 (;@1;) 44 (;@1;) 17 (;@28;) 44 (;@1;) 44 (;@1;) 18 (;@27;) 44 (;@1;) 44 (;@1;) 19 (;@26;) 44 (;@1;) 44 (;@1;) 20 (;@25;) 44 (;@1;) 21 (;@24;) 22 (;@23;) 44 (;@1;) 44 (;@1;) 23 (;@22;) 44 (;@1;) 44 (;@1;) 24 (;@21;) 44 (;@1;) 44 (;@1;) 25 (;@20;) 44 (;@1;) 44 (;@1;) 26 (;@19;) 44 (;@1;) 44 (;@1;) 27 (;@18;) 44 (;@1;) 44 (;@1;) 28 (;@17;) 29 (;@16;) 44 (;@1;) 30 (;@15;) 44 (;@1;) 44 (;@1;) 31 (;@14;) 44 (;@1;) 44 (;@1;) 32 (;@13;) 44 (;@1;) 44 (;@1;) 33 (;@12;) 44 (;@1;) 44 (;@1;) 34 (;@11;) 44 (;@1;) 44 (;@1;) 35 (;@10;) 44 (;@1;) 44 (;@1;) 36 (;@9;) 44 (;@1;) 44 (;@1;) 37 (;@8;) 44 (;@1;) 44 (;@1;) 38 (;@7;) 44 (;@1;) 44 (;@1;) 39 (;@6;) 44 (;@1;) 44 (;@1;) 40 (;@5;) 44 (;@1;) 44 (;@1;) 41 (;@4;) 44 (;@1;) 44 (;@1;) 42 (;@3;) 44 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 42 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 32832))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 41 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 40 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 4160))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 39 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 38 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 37 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 36 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 35 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 34 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 33 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 32 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 31 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 30 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 29 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 28 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 27 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 26 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 25 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 24 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 23 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 22 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 21 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 20 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 19 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 18 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 17 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 16 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 15 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 14 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 13 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 12 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 11 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 10 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 9 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 8 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 7 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 6 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 5 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 4 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 3 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 2 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 1 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))))
(call $gba_set_sound_reg
(i32.const 67108964)
(local.get 2))))
(func $instruments.square1_43.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(i32.store offset=8536
(i32.const 0)
(local.get 2))
(i32.store offset=8532
(i32.const 0)
(i32.const -1))
(i32.store offset=8540
(i32.const 0)
(local.get 3)))
(func $instruments.square1_43.release (type 5) (param i32 i32 i32)
(i32.store offset=8532
(i32.const 0)
(i32.add
(i32.load offset=8536
(i32.const 0))
(local.get 2))))
(func $instruments.square1_43.frame (type 5) (param i32 i32 i32)
(local i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_if 0 (;@3;)
(i32.ge_u
(local.get 2)
(local.tee 3
(i32.load offset=8532
(i32.const 0)))))
(block ;; label = @4
(block ;; label = @5
(block ;; label = @6
(block ;; label = @7
(block ;; label = @8
(block ;; label = @9
(block ;; label = @10
(block ;; label = @11
(block ;; label = @12
(block ;; label = @13
(block ;; label = @14
(block ;; label = @15
(block ;; label = @16
(block ;; label = @17
(block ;; label = @18
(block ;; label = @19
(block ;; label = @20
(br_table 0 (;@20;) 1 (;@19;) 2 (;@18;) 3 (;@17;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 4 (;@16;) 19 (;@1;) 19 (;@1;) 5 (;@15;) 19 (;@1;) 19 (;@1;) 6 (;@14;) 19 (;@1;) 19 (;@1;) 7 (;@13;) 19 (;@1;) 19 (;@1;) 8 (;@12;) 19 (;@1;) 19 (;@1;) 9 (;@11;) 19 (;@1;) 19 (;@1;) 10 (;@10;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 19 (;@1;) 11 (;@9;) 19 (;@1;) 19 (;@1;) 12 (;@8;) 19 (;@1;) 19 (;@1;) 13 (;@7;) 19 (;@1;) 19 (;@1;) 14 (;@6;) 19 (;@1;) 19 (;@1;) 15 (;@5;) 19 (;@1;) 19 (;@1;) 16 (;@4;) 19 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 17 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 36928))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 16 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 15 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 14 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 13 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 12 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 11 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 10 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 9 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 32832))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 8 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 36928))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 7 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 6 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 5 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 4 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 3 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 2 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 1 (;@2;)))
(br_if 1 (;@1;)
(i32.le_u
(i32.add
(i32.load offset=8540
(i32.const 0))
(local.get 3))
(local.get 2)))
(block ;; label = @3
(block ;; label = @4
(block ;; label = @5
(br_table 0 (;@5;) 4 (;@1;) 4 (;@1;) 4 (;@1;) 4 (;@1;) 1 (;@4;) 4 (;@1;) 2 (;@3;) 4 (;@1;)
(i32.sub
(local.get 2)
(local.get 3))))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 2 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 4160))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 1 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 64))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(call $gba_set_sound_reg
(i32.const 67108964)
(local.get 2))))
(func $instruments.square1_48.press (type 4) (param i32 i32 i32 i32)
(i32.store8 offset=8544
(i32.const 0)
(local.get 2))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(call $gba_set_sound_reg
(i32.const 67108964)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square1_48.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.le_u
(i32.load8_u offset=8544
(i32.const 0))
(local.get 2)))
(block ;; label = @2
(block ;; label = @3
(block ;; label = @4
(block ;; label = @5
(block ;; label = @6
(block ;; label = @7
(block ;; label = @8
(block ;; label = @9
(block ;; label = @10
(block ;; label = @11
(block ;; label = @12
(block ;; label = @13
(block ;; label = @14
(block ;; label = @15
(block ;; label = @16
(block ;; label = @17
(block ;; label = @18
(block ;; label = @19
(block ;; label = @20
(block ;; label = @21
(block ;; label = @22
(block ;; label = @23
(block ;; label = @24
(block ;; label = @25
(block ;; label = @26
(block ;; label = @27
(block ;; label = @28
(block ;; label = @29
(block ;; label = @30
(block ;; label = @31
(block ;; label = @32
(block ;; label = @33
(block ;; label = @34
(block ;; label = @35
(block ;; label = @36
(block ;; label = @37
(block ;; label = @38
(block ;; label = @39
(block ;; label = @40
(block ;; label = @41
(block ;; label = @42
(block ;; label = @43
(block ;; label = @44
(block ;; label = @45
(block ;; label = @46
(block ;; label = @47
(block ;; label = @48
(block ;; label = @49
(block ;; label = @50
(block ;; label = @51
(block ;; label = @52
(block ;; label = @53
(block ;; label = @54
(block ;; label = @55
(block ;; label = @56
(block ;; label = @57
(block ;; label = @58
(block ;; label = @59
(block ;; label = @60
(br_table 0 (;@60;) 1 (;@59;) 2 (;@58;) 3 (;@57;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 4 (;@56;) 59 (;@1;) 59 (;@1;) 5 (;@55;) 59 (;@1;) 59 (;@1;) 6 (;@54;) 59 (;@1;) 59 (;@1;) 7 (;@53;) 8 (;@52;) 59 (;@1;) 9 (;@51;) 59 (;@1;) 59 (;@1;) 10 (;@50;) 59 (;@1;) 59 (;@1;) 11 (;@49;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 59 (;@1;) 12 (;@48;) 59 (;@1;) 59 (;@1;) 13 (;@47;) 59 (;@1;) 59 (;@1;) 14 (;@46;) 59 (;@1;) 59 (;@1;) 15 (;@45;) 59 (;@1;) 59 (;@1;) 16 (;@44;) 59 (;@1;) 59 (;@1;) 17 (;@43;) 59 (;@1;) 59 (;@1;) 18 (;@42;) 59 (;@1;) 59 (;@1;) 19 (;@41;) 59 (;@1;) 59 (;@1;) 20 (;@40;) 59 (;@1;) 21 (;@39;) 22 (;@38;) 59 (;@1;) 59 (;@1;) 23 (;@37;) 59 (;@1;) 59 (;@1;) 24 (;@36;) 59 (;@1;) 59 (;@1;) 25 (;@35;) 59 (;@1;) 59 (;@1;) 26 (;@34;) 59 (;@1;) 59 (;@1;) 27 (;@33;) 59 (;@1;) 59 (;@1;) 28 (;@32;) 29 (;@31;) 59 (;@1;) 30 (;@30;) 59 (;@1;) 59 (;@1;) 31 (;@29;) 59 (;@1;) 59 (;@1;) 32 (;@28;) 59 (;@1;) 59 (;@1;) 33 (;@27;) 59 (;@1;) 59 (;@1;) 34 (;@26;) 59 (;@1;) 59 (;@1;) 35 (;@25;) 59 (;@1;) 59 (;@1;) 36 (;@24;) 59 (;@1;) 59 (;@1;) 37 (;@23;) 59 (;@1;) 59 (;@1;) 38 (;@22;) 59 (;@1;) 59 (;@1;) 39 (;@21;) 59 (;@1;) 59 (;@1;) 40 (;@20;) 59 (;@1;) 59 (;@1;) 41 (;@19;) 59 (;@1;) 59 (;@1;) 42 (;@18;) 59 (;@1;) 43 (;@17;) 44 (;@16;) 59 (;@1;) 59 (;@1;) 45 (;@15;) 59 (;@1;) 59 (;@1;) 46 (;@14;) 59 (;@1;) 59 (;@1;) 47 (;@13;) 59 (;@1;) 59 (;@1;) 48 (;@12;) 59 (;@1;) 59 (;@1;) 49 (;@11;) 59 (;@1;) 59 (;@1;) 50 (;@10;) 51 (;@9;) 59 (;@1;) 52 (;@8;) 59 (;@1;) 59 (;@1;) 53 (;@7;) 59 (;@1;) 59 (;@1;) 54 (;@6;) 59 (;@1;) 59 (;@1;) 55 (;@5;) 59 (;@1;) 59 (;@1;) 56 (;@4;) 59 (;@1;) 59 (;@1;) 57 (;@3;) 59 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 57 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 36928))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 56 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 55 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 54 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 53 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 52 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 51 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 50 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 49 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 48 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 47 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 32832))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 46 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 45 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 44 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 28736))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 43 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 42 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 41 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 40 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 39 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 38 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 37 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 24640))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 36 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 35 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 34 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 33 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 32 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 31 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 30 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 29 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 20544))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 28 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 27 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 26 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 25 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 24 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 23 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 22 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 16448))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 21 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 20 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 19 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 18 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 17 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 16 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 15 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 12352))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 14 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 13 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 12 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 11 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 10 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 9 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 8 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 7 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108962)
(i32.const 8256))
(local.set 2
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(br 6 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 5 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 4 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 3 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 2 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 1)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047)))
(br 1 (;@2;)))
(local.set 2
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))))
(call $gba_set_sound_reg
(i32.const 67108964)
(local.get 2))))
(func $instruments.square2_2.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 12288))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square2_2.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.load
(i32.add
(i32.shl
(local.get 2)
(i32.const 2))
(i32.const 8432))))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square2_3.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 20480))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square2_3.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 28672))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 0 (;@3;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(local.set 3
(i32.const 0)))
(call $gba_set_sound_reg
(i32.const 67108968)
(local.get 3))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square2_4.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.load
(i32.add
(i32.shl
(local.get 2)
(i32.const 2))
(i32.const 8444))))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square2_5.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 28672))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square2_5.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 0 (;@3;) 1 (;@2;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 28800))
(return))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 128))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square2_9.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 8192))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square2_9.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.load
(i32.add
(i32.shl
(local.get 2)
(i32.const 2))
(i32.const 8456))))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.square2_12.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.const 16384))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.square2_12.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 2)))
(call $gba_set_sound_reg
(i32.const 67108968)
(i32.add
(i32.mul
(local.get 2)
(i32.const -12288))
(i32.const 24576)))
(call $gba_set_sound_reg
(i32.const 67108972)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 33554432)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))))
(func $instruments.wave_2.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 0))
(call $gba_set_wave_table
(i32.const 8381)
(i32.const 16))
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 8192))
(call $gba_set_sound_reg
(i32.const 67108980)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 16777216)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.wave_2.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 24576))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 2 (;@1;) 0 (;@3;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -6))))
(local.set 3
(i32.const 0)))
(call $gba_set_sound_reg
(i32.const 67108978)
(local.get 3))))
(func $instruments.wave_3.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 0))
(call $gba_set_wave_table
(i32.const 8381)
(i32.const 16))
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 16384))
(call $gba_set_sound_reg
(i32.const 67108980)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 16777216)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.wave_3.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 0))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 2 (;@1;) 2 (;@1;) 0 (;@3;) 2 (;@1;) 1 (;@2;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -2))))
(local.set 3
(i32.const 16384)))
(call $gba_set_sound_reg
(i32.const 67108978)
(local.get 3))))
(func $instruments.wave_12.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 24576))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 2 (;@1;) 0 (;@3;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -2))))
(local.set 3
(i32.const 0)))
(call $gba_set_sound_reg
(i32.const 67108978)
(local.get 3))))
(func $instruments.wave_5.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -2)))
(i32.const 7)))
(br_if 0 (;@1;)
(i32.eqz
(i32.and
(i32.shr_u
(i32.const 173)
(i32.and
(local.get 2)
(i32.const 255)))
(i32.const 1))))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.load
(i32.add
(i32.shl
(local.get 2)
(i32.const 2))
(i32.const 8468))))))
(func $instruments.wave_6.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -2)))
(i32.const 5)))
(br_if 0 (;@1;)
(i32.eqz
(i32.and
(i32.shr_u
(i32.const 45)
(i32.and
(local.get 2)
(i32.const 255)))
(i32.const 1))))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.load
(i32.add
(i32.shl
(local.get 2)
(i32.const 2))
(i32.const 8500))))))
(func $instruments.wave_9.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 0))
(call $gba_set_wave_table
(i32.const 8397)
(i32.const 16))
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 24576))
(call $gba_set_sound_reg
(i32.const 67108980)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 16777216)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.wave_9.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.ne
(local.get 2)
(i32.const 4)))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 0))))
(func $instruments.wave_11.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 0))
(call $gba_set_wave_table
(i32.const 8413)
(i32.const 16))
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108980)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 16777216)
(local.get 0)))
(i32.const 2047))
(i32.const 32768)))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 16384)))
(func $instruments.wave_11.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 24576))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 1 (;@2;) 2 (;@1;) 0 (;@3;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(local.set 3
(i32.const 0)))
(call $gba_set_sound_reg
(i32.const 67108978)
(local.get 3))))
(func $instruments.wave_12.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 0))
(call $gba_set_wave_table
(i32.const 8413)
(i32.const 16))
(call $gba_set_sound_reg
(i32.const 67108976)
(i32.const 192))
(call $gba_set_sound_reg
(i32.const 67108978)
(i32.const 16384))
(call $gba_set_sound_reg
(i32.const 67108980)
(i32.or
(i32.and
(i32.sub
(i32.const 0)
(i32.div_u
(i32.const 16777216)
(local.get 0)))
(i32.const 2047))
(i32.const 32768))))
(func $instruments.noise_1.press (type 4) (param i32 i32 i32 i32)
(i32.store8 offset=8545
(i32.const 0)
(i32.rem_u
(local.get 1)
(i32.const 12)))
(i32.store8 offset=8546
(i32.const 0)
(local.tee 1
(i32.and
(local.get 2)
(i32.const 15))))
(i32.store8 offset=8547
(i32.const 0)
(i32.and
(local.get 3)
(i32.const 7)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.or
(i32.shl
(local.get 1)
(i32.const 12))
(i32.const 2176)))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.or
(i32.or
(i32.and
(i32.shl
(i32.load8_u offset=8545
(i32.const 0))
(i32.const 4))
(i32.const 240))
(i32.and
(i32.load8_u offset=8547
(i32.const 0))
(i32.const 7)))
(i32.const 32768))))
(func $instruments.noise_1.frame (type 5) (param i32 i32 i32)
(local i32)
(local.set 3
(i32.const 128))
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(br_table 0 (;@3;) 2 (;@1;) 1 (;@2;) 2 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(local.set 3
(i32.or
(i32.shl
(select
(i32.const 0)
(local.tee 2
(i32.add
(local.tee 3
(i32.and
(i32.load8_u offset=8546
(i32.const 0))
(i32.const 15)))
(i32.const -9)))
(i32.gt_u
(local.get 2)
(local.get 3)))
(i32.const 12))
(i32.const 128))))
(call $gba_set_sound_reg
(i32.const 67108984)
(local.get 3))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.or
(i32.or
(i32.and
(i32.shl
(i32.load8_u offset=8545
(i32.const 0))
(i32.const 4))
(i32.const 240))
(i32.and
(i32.load8_u offset=8547
(i32.const 0))
(i32.const 7)))
(i32.const 32768)))))
(func $instruments.noise_4.press (type 4) (param i32 i32 i32 i32)
(i32.store8 offset=8548
(i32.const 0)
(i32.rem_u
(local.get 1)
(i32.const 12)))
(i32.store8 offset=8549
(i32.const 0)
(local.tee 1
(i32.and
(local.get 2)
(i32.const 15))))
(i32.store8 offset=8550
(i32.const 0)
(i32.and
(local.get 3)
(i32.const 7)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.or
(i32.shl
(local.get 1)
(i32.const 12))
(i32.const 2176)))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.or
(i32.or
(i32.and
(i32.shl
(i32.load8_u offset=8548
(i32.const 0))
(i32.const 4))
(i32.const 240))
(i32.and
(i32.load8_u offset=8550
(i32.const 0))
(i32.const 7)))
(i32.const 32768))))
(func $instruments.noise_4.frame (type 5) (param i32 i32 i32)
(local i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(block ;; label = @4
(block ;; label = @5
(br_table 0 (;@5;) 1 (;@4;) 4 (;@1;) 2 (;@3;) 4 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.or
(i32.shl
(select
(i32.const 0)
(local.tee 3
(i32.add
(local.tee 2
(i32.and
(i32.load8_u offset=8549
(i32.const 0))
(i32.const 15)))
(i32.const -2)))
(i32.gt_u
(local.get 3)
(local.get 2)))
(i32.const 12))
(i32.const 128)))
(local.set 2
(i32.or
(i32.or
(i32.and
(i32.shl
(i32.load8_u offset=8548
(i32.const 0))
(i32.const 4))
(i32.const 240))
(i32.and
(i32.load8_u offset=8550
(i32.const 0))
(i32.const 7)))
(i32.const 32768)))
(br 2 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.or
(i32.shl
(select
(i32.const 0)
(local.tee 3
(i32.add
(local.tee 2
(i32.and
(i32.load8_u offset=8549
(i32.const 0))
(i32.const 15)))
(i32.const -9)))
(i32.gt_u
(local.get 3)
(local.get 2)))
(i32.const 12))
(i32.const 128)))
(local.set 2
(i32.or
(i32.or
(i32.and
(i32.shl
(i32.load8_u offset=8548
(i32.const 0))
(i32.const 4))
(i32.const 240))
(i32.and
(i32.load8_u offset=8550
(i32.const 0))
(i32.const 7)))
(i32.const 32768)))
(br 1 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 128))
(local.set 2
(i32.const 32880)))
(call $gba_set_sound_reg
(i32.const 67108988)
(local.get 2))))
(func $instruments.noise_9.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 28672))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32819)))
(func $instruments.noise_9.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 6)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.sub
(i32.const 24576)
(i32.shl
(local.get 2)
(i32.const 12))))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32819))))
(func $instruments.noise_15.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 36864))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32784)))
(func $instruments.noise_15.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(br_if 0 (;@1;)
(i32.gt_u
(local.tee 2
(i32.add
(local.get 2)
(i32.const -1)))
(i32.const 8)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.sub
(i32.const 32768)
(i32.shl
(local.get 2)
(i32.const 12))))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32784))))
(func $instruments.noise_20.press (type 4) (param i32 i32 i32 i32)
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 53376))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32784)))
(func $instruments.noise_20.frame (type 5) (param i32 i32 i32)
(block ;; label = @1
(block ;; label = @2
(block ;; label = @3
(block ;; label = @4
(block ;; label = @5
(block ;; label = @6
(block ;; label = @7
(block ;; label = @8
(br_table 0 (;@8;) 7 (;@1;) 1 (;@7;) 7 (;@1;) 2 (;@6;) 3 (;@5;) 7 (;@1;) 4 (;@4;) 7 (;@1;)
(i32.add
(local.get 2)
(i32.const -1))))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 45184))
(br 4 (;@3;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 16512))
(br 3 (;@3;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 49280))
(call $gba_set_sound_reg
(i32.const 67108988)
(i32.const 32))
(local.set 2
(i32.const 32800))
(br 3 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 12416))
(local.set 2
(i32.const 32800))
(br 2 (;@2;)))
(call $gba_set_sound_reg
(i32.const 67108984)
(i32.const 128))
(local.set 2
(i32.const 32800))
(br 1 (;@2;)))
(local.set 2
(i32.const 32784)))
(call $gba_set_sound_reg
(i32.const 67108988)
(local.get 2))))
(table (;0;) 56 56 funcref)
(memory (;0;) 1 1)
(global $__stack_pointer (mut i32) (i32.const 8192))
(export "memory" (memory 0))
(export "_start" (func $_start))
(export "__indirect_function_table" (table 0))
(elem (;0;) (i32.const 1) func $instruments.square1_2.press $instruments.square1_2.frame $instruments.square1_3.press $instruments.square1_26.release $instruments.square1_3.frame $instruments.square1_9.press $instruments.square1_9.frame $instruments.square1_10.press $instruments.square1_10.frame $instruments.square1_16.press $instruments.square1_16.frame $instruments.square1_26.press $instruments.square1_26.frame $instruments.square1_27.press $instruments.square1_27.frame $instruments.square1_35.press $instruments.square1_35.frame $instruments.square1_43.press $instruments.square1_43.release $instruments.square1_43.frame $instruments.square1_48.press $instruments.square1_48.frame $instruments.square2_2.press $instruments.square2_2.frame $instruments.square2_3.press $instruments.square2_3.frame $instruments.square2_4.frame $instruments.square2_5.press $instruments.square2_5.frame $instruments.square2_9.press $instruments.square2_9.frame $instruments.square2_12.press $instruments.square2_12.frame $instruments.wave_2.press $instruments.wave_2.frame $instruments.wave_3.press $instruments.wave_3.frame $instruments.wave_12.frame $instruments.wave_5.frame $instruments.wave_6.frame $instruments.wave_9.press $instruments.wave_9.frame $instruments.wave_11.press $instruments.wave_11.frame $instruments.wave_12.press $instruments.noise_1.press $instruments.noise_1.frame $instruments.noise_4.press $instruments.noise_4.frame $instruments.noise_9.press $instruments.noise_9.frame $instruments.noise_15.press $instruments.noise_15.frame $instruments.noise_20.press $instruments.noise_20.frame)
(data $.rodata (i32.const 8192) "Freq Div\00Volume\00W9\00T9\00S9\00N9\00S48\00S27\00W6\00S26\00S16\00W5\00T5\00S35\00N15\00W4\00T4\00N4\00W3\00T3\00S3\00S43\00W2\00T2\00S2\00W12\00T12\00N1\00W11\00N20\00S10\00Ln Length (frames)\00Release Length (frames)\00Sustain after release (frames)\00\22f\aa\ee\ff\ff\fe\ea\a6f\8a\cf\fe\ec\a63\ff\ff\ff\ff\00\00\00\00\ff\ff\ff\ff\00\00\00\00\01\02\03\04\05\06\05\0a\0f\14\1eP\09\12\1b$\00\00\00\00P\00\00\00 \00\00\00\00\00\00\00p\00\00\00@\00\00\00\00\00\00\00@\00\00\00\10\00\00\00\00\00\00\00`\00\00\00`\00\00\00\00\00\00\00 \00\00\00`\00\00\00`\00\00\00`\00\00\00\00\00\00\00`\00\00\00`\00\00\00\00\00\00\00@\00\00\00`\00\00\00\00\00\00")
(data $.data (i32.const 8524) "\04"))
const std = @import("std");
const ct = @import("ct");
const gba = ct.gba;
const square1_2 = struct {
pub const id: [*:0]const u8 = "S2";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
}
};
const square1_3 = struct {
pub const id: [*:0]const u8 = "S3";
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .min = 0, .default = 4 };
var len: i8 = 4;
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void {
len = p0;
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 8 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
if (t >= len) {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
} else {
if (t >= 2 and (t - 2) % 3 == 0) {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = @truncate(6 - ((t - 2) / 3)) }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
}
}
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void {
// When len is a multiple of frames_per_step the last frame won't be executed,
// so make sure to also silence at the end of the release step.
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
};
const square1_9 = struct {
pub const id: [*:0]const u8 = "S9";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 8 }).writeTo(gba.square1);
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 12)).writeTo(gba.square1);
},
else => {},
}
}
};
const square1_10 = struct {
pub const id: [*:0]const u8 = "S10";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
}
};
const square1_16 = struct {
pub const id: [*:0]const u8 = "S16";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
}
};
const square1_26 = struct {
pub const id: [*:0]const u8 = "S26";
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .min = 0, .default = 4 };
var len: i8 = 0;
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void {
len = p0;
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
if (t >= len) {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
} else {
if ((t - 1) % 16 == 0) {
// Reduce the envelope every 16th frame.
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = @truncate(4 - (t - 1) / 16) }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
if (t % 3 == 0) {
// Every 3rd frame, tremolo based on evenness, thus looping every 6 frames.
const base: i12 = gba.encodeSquareFreq(freq);
const adj: i2 = @intCast(t % 2);
(gba.CtrlFreq{}).withFreq(@intCast(base - adj)).writeTo(gba.square1);
}
}
}
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
};
const square1_27 = struct {
pub const id: [*:0]const u8 = "S27";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 15 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 12 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
}
};
/// 2, 6, 8, 5
const square1_35 = struct {
pub const id: [*:0]const u8 = "S35";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 1 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
10 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
13 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
16 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
19 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
20 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
22 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
25 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
28 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
34 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
37 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
40 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
43 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
46 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
49 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
52 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
55 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
58 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
60 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
61 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
64 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
67 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
70 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
73 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
76 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
79 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
80 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
82 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
85 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
88 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
91 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
94 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
97 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
100 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
103 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
106 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
109 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
112 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
115 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
118 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
else => {},
}
}
};
/// 3, 7, 9, 6, ..., 5, 6, 7, 8, 9
const square1_43 = struct {
pub const id: [*:0]const u8 = "S43";
// Continues sustaining X frames after the release callback
pub const param_0 = ct.Parameter{ .name = "Sustain after release (frames)", .min = 0, .max = 8, .default = 4 };
// The frame function ramps down after release over 8 frames, this allows cutting it shorter (without silencing the channel).
pub const param_1 = ct.Parameter{ .name = "Release Length (frames)", .min = 1, .max = 8, .default = 8 };
pub const frames_after_release: u32 = param_0.max + param_1.max;
var release_frame: u32 = 0;
var sustain_ext_frames: u32 = 0;
var release_len: u32 = 0;
pub fn press(freq: u32, _: u8, p0: i8, p1: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
release_frame = std.math.maxInt(u32);
sustain_ext_frames = @intCast(p0);
release_len = @intCast(p1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
if (t < release_frame) {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
10 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
13 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
16 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
19 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
22 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
25 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
28 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
34 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
37 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
40 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
43 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
46 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
49 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
} else if (t < release_frame + release_len) {
switch (t - release_frame) {
0 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
5 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 1 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
7 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 0 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
else => {},
}
}
}
pub fn release(_: u32, _: u8, t: u32) callconv(.C) void {
release_frame = t + sustain_ext_frames;
}
};
/// 3, 7, 9, 6, ..., 5, 6, 5, 6, 7, 8
const square1_48 = struct {
pub const id: [*:0]const u8 = "S48";
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .default = @bitCast(@as(u8, 158)) };
var len: u8 = 0;
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void {
len = @bitCast(p0);
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
if (t < len) {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
10 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
13 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
16 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
19 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
20 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
22 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
25 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
28 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
34 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
37 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
40 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
43 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
46 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
49 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
52 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
55 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
58 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
60 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
61 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
64 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
67 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
70 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
73 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
76 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
79 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
80 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
82 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
85 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
88 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
91 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
94 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
97 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
100 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
103 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
106 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
109 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
112 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
115 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
118 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
120 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
121 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
124 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
127 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
130 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
133 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
136 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
139 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
140 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1);
},
142 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
145 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
148 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
151 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
154 => {
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1);
},
157 => {
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1);
},
else => {},
}
}
}
};
const square2_2 = struct {
pub const id: [*:0]const u8 = "T2";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const square2_3 = struct {
pub const id: [*:0]const u8 = "T3";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const square2_4 = struct {
pub const id: [*:0]const u8 = "T4";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const square2_5 = struct {
pub const id: [*:0]const u8 = "T5";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 7 }).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const square2_9 = struct {
pub const id: [*:0]const u8 = "T9";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const square2_12 = struct {
pub const id: [*:0]const u8 = "T12";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
}
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2);
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2);
},
else => {},
}
}
};
const wave_2_table = gba.wav(0x2266aaeefffffeeaa6668acffeeca633);
const wave_2 = struct {
pub const id: [*:0]const u8 = "W2";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_2_table);
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
6 => {
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave);
},
8 => {
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave);
},
else => {},
}
}
};
const wave_3 = struct {
pub const id: [*:0]const u8 = "W3";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_2_table);
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => {
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave);
},
5 => {
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave);
},
7 => {
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave);
},
else => {},
}
}
};
const wave_4 = struct {
pub const id: [*:0]const u8 = "W4";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_2_table);
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => {
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave);
},
4 => {
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave);
},
else => {},
}
}
};
const wave_5 = struct {
pub const id: [*:0]const u8 = "W5";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_2_table);
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave),
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
5 => (gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave),
7 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave),
9 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
else => {},
}
}
};
const wave_6 = struct {
pub const id: [*:0]const u8 = "W6";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_2_table);
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave),
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
5 => (gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave),
7 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
else => {},
}
}
};
const wave_9 = struct {
pub const id: [*:0]const u8 = "W9";
const table = gba.wav(0xffffffff00000000ffffffff00000000);
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&table);
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
else => {},
}
}
};
const wave_11_table = gba.wav(0x010203040506050a0f141e5009121b24);
const wave_11 = struct {
pub const id: [*:0]const u8 = "W11";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_11_table);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave),
3 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
else => {},
}
}
};
const wave_12 = struct {
pub const id: [*:0]const u8 = "W12";
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void {
gba.WaveRam.setTable(&wave_11_table);
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave);
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave),
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave),
else => {},
}
}
};
const noise_1 = struct {
pub const id: [*:0]const u8 = "N1";
pub const param_0 = ct.Parameter{ .name = "Volume", .default = 11, .min = 0, .max = 15 };
pub const param_1 = ct.Parameter{ .name = "Freq Div", .default = 0, .min = 0, .max = 7 };
// note: noise freq
var freq_div: u3 = 0;
var freq: u4 = 0;
var vol: u4 = 0;
pub fn press(_: u32, note: u8, p0: i8, p1: i8) callconv(.C) void {
freq = @intCast(note % 12);
vol = @intCast(p0);
freq_div = @intCast(p1);
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_inc, .env_start = vol }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 9 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
},
else => {},
}
}
};
const noise_4 = struct {
pub const id: [*:0]const u8 = "N4";
pub const param_0 = ct.Parameter{ .name = "Volume", .default = 11, .min = 0, .max = 15 };
pub const param_1 = ct.Parameter{ .name = "Freq Div", .default = 0, .min = 0, .max = 7 };
// note: noise freq
var freq_div: u3 = 0;
var freq: u4 = 0;
var vol: u4 = 0;
pub fn press(_: u32, note: u8, p0: i8, p1: i8) callconv(.C) void {
freq = @intCast(note % 12);
vol = @intCast(p0);
freq_div = @intCast(p1);
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_inc, .env_start = vol }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 2 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 9 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 7, .trigger = 1 }).writeTo(gba.noise);
},
else => {},
}
}
};
const noise_9 = struct {
pub const id: [*:0]const u8 = "N9";
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
5 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
6 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
7 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise);
},
else => {},
}
}
};
const noise_15 = struct {
pub const id: [*:0]const u8 = "N15";
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 9 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 8 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
2 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
4 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
5 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
6 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
7 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
8 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
9 => {
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
else => {},
}
}
};
const noise_20 = struct {
pub const id: [*:0]const u8 = "N20";
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 13 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
}
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void {
switch (t) {
1 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 11 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
3 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise);
},
5 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 12 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise);
},
6 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 3 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise);
},
8 => {
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise);
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise);
},
else => {},
}
}
};
pub fn main() void {
ct.registerInstrument(square1_2, 0);
ct.registerInstrument(square1_3, 0);
ct.registerInstrument(square1_9, 0);
ct.registerInstrument(square1_10, 0);
ct.registerInstrument(square1_16, 0);
ct.registerInstrument(square1_26, 0);
ct.registerInstrument(square1_27, 0);
ct.registerInstrument(square1_35, 0);
ct.registerInstrument(square1_43, 0);
ct.registerInstrument(square1_48, 0);
ct.registerInstrument(square2_2, 1);
ct.registerInstrument(square2_3, 1);
ct.registerInstrument(square2_4, 1);
ct.registerInstrument(square2_5, 1);
ct.registerInstrument(square2_9, 1);
ct.registerInstrument(square2_12, 1);
ct.registerInstrument(wave_2, 2);
ct.registerInstrument(wave_3, 2);
ct.registerInstrument(wave_4, 2);
ct.registerInstrument(wave_5, 2);
ct.registerInstrument(wave_6, 2);
ct.registerInstrument(wave_9, 2);
ct.registerInstrument(wave_11, 2);
ct.registerInstrument(wave_12, 2);
ct.registerInstrument(noise_1, 3);
ct.registerInstrument(noise_4, 3);
ct.registerInstrument(noise_9, 3);
ct.registerInstrument(noise_15, 3);
ct.registerInstrument(noise_20, 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment