Simon Lindholm
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# m64 format Disassembler: https://gist.github.com/simonlindholm/307e73aefed6e1a358931522c291f878 Disassembly of SM64 US sequence 0: https://paste.rs/6za ## Legend * `u8` means a single byte, interpreted as an unsigned integer * `s8` means a single byte, interpreted as a signed integer * `u16` means two bytes, interpreted as a big-endian unsigned integer * `var` means an unsigned integer which is either one or two bytes depending on the top bit of the first byte. If the bit is unset, it's the same as `u8`; if set, it's the same as `u16` with that bit ignored. * `addr` means the same as `u16`, interpreted as as index into the sequence data. * X, Y, Z are the arguments passed to the command * N is the lower 4 bites of the command, or lower 6 bits for notes ## Sequences | hex | mnemonic |description| |--------------------|---------------------------|-----------| | 0xff | end | End of script, loop or function | | 0xfe | delay1 | Delay for 1 tick | | 0xfd, var | delay | Delay for X ticks | | 0xfc, addr | call | Call a function | | 0xfb, addr | jump | Jump to a point in the sequence script | | 0xfa, addr | beqz | Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | | 0xf9, addr | bltz | Jump if Q < 0 | | 0xf8, u8 | loop | Repeat until `loopend` for X iterations (256 if X = 0) | | 0xf7 | loopend | Loop end marker | | 0xf5, addr | bgez | Jump if Q >= 0 | | 0xf2, u8 | reservenotes | Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | | 0xf1 | unreservenotes | Drop all earlier reservations made by this sequence. | | 0xdf, s8 | transpose | Set transposition in semitones. | | 0xde, s8 | transposerel | Change transposition by some delta. | | 0xdd, u8 | settempo | Set tempo in BPM. | | 0xdc, s8 | addtempo | Change tempo by some delta. | | 0xdb, u8 | setvol | Set volume scale (0..255 = none to twice normal). | | 0xda, s8 | changevol | Change volume scale by some delta. | | 0xd7, u16 | initchannels | Initialize channels (bitmask). This copies mute behavior and note allocation policy. | | 0xd6, u16 | disablechannels | Uninitialize channels (bitmask). | | 0xd5, s8 | setmutescale | Set volume multiplier for muted mode (0..127). | | 0xd4 | mute | Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | | 0xd3, u8 | setmutebhv | Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | | 0xd2, addr | setshortnotevelocitytable | Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | | 0xd1, addr | setshortnotedurationtable | Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | | 0xd0, u8 | setnoteallocationpolicy | Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel's reserved notes, else if 0x4 is set, from the channel's or sequence's reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | | 0xcc, u8 | setval | Set Q to a constant. | | 0xc9, u8 | bitand | Bitand Q by a constant. | | 0xc8, u8 | subtract | Subtract a constant from Q. | | 0x90-0x9f, addr | startchannel | Start channel N, with a given channel script. | | 0x80-0x8f | getvariation | Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | | 0x70-0x7f | setvariation | Set the variation bit to Q. | | 0x50-0x5f | subvariation | Subtract the variation bit from Q. | | 0x00-0x0f | testchdisabled | Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. | ## Channels | hex | mnemonic |description| |--------------------|---------------------------|-----------| | 0xff | end | End of script, loop or function | | 0xfe | delay1 | Delay for 1 tick | | 0xfd, var | delay | Delay for X ticks | | 0xfc, addr | call | Call a function | | 0xfb, addr | jump | Jump to a point in the channel script | | 0xfa, addr | beqz | Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | | 0xf9, addr | bltz | Jump if Q < 0 | | 0xf8, u8 | loop | Repeat until `loopend` for X iterations (256 if X = 0) | | 0xf7 | loopend | Loop end marker | | 0xf6 | break | Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | | 0xf5, addr | bgez | Jump if Q >= 0 | | 0xf3 | hang | Infinite delay. | | 0xf2, u8 | reservenotes | Reserve X notes for exclusive use by this channel (dropping earlier reservations). | | 0xf1 | unreservenotes | Drop all earlier reservations made by this channel. | | 0xe4 | dyncall | If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by `setdyntable`/`dynsetdyntable`. | | 0xe3, u8 | setvibratodelay | Set delay until vibrato starts for each note. | | 0xe2, u8, u8, u8 | setvibratoextentlinear | Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | | 0xe1, u8, u8, u8 | setvibratoratelinear | Like above except for vibrato rate. | | 0xe0, u8 | setvolscale | Set scale factor for volume (0..255 = none to twice normal). | | 0xdf, u8 | setvol | Set scale factor #2 for volume (0..255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | | 0xde, u16 | freqscale | Pitch bend using a raw frequency multiplier X/2^15. | | 0xdd, u8 | setpan | Set the pan for this channel (0..128) | | 0xdc, u8 | setpanchanweight | The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0..128 maps to 0..1). W defaults to 1.0. | | 0xdb, s8 | transpose | Set transposition in semitones. | | 0xda, addr | setenvelope | Set ADSR envelope. See below for format. | | 0xd9, u8 | setdecayrelease | Set ADSR decay/release rate. | | 0xd8, u8 | setvibratoextent | Set vibrato extent. | | 0xd7, u8 | setvibratorate | Set vibrato rate. | | 0xd6, u8 | setupdatesperframe | Seems like it was meant to set the number of updates per frame? But it doesn't actually do anything. | | 0xd4, u8 | setreverb | Set amount of reverb (or "dry/wet mix"?). | | 0xd3, s8 | pitchbend | Pitch bend by <= 1 octave in either direction (-127..127). | | 0xd2, u8 | setsustain | Set ADSR sustain volume. | | 0xd1, u8 | setnoteallocationpolicy | Set note allocation policy for channel. See the description for sequence scripts. | | 0xd0, u8 | stereoheadseteffects | Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don't know which ones precisely -- pan *is* still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | | 0xcc, u8 | setval | Set Q to a constant. | | 0xcb, addr | readseq | Set Q to sequenceData[X + Q]. | | 0xca, u8 | setmutebhv | Set mute behavior for this channel. | | 0xc9, u8 | bitand | Bitand Q by a constant. | | 0xc8, u8 | subtract | Subtract a constant from Q. | | 0xc7, u8, addr | writeseq | Overwrite the byte at the given position in the sequence script by (Q + X). | | 0xc6, u8 | setbank | Switch bank within instrument bank sets, to the X'th bank, 0-indexed, counting from the end. | | 0xc5 | dynsetdyntable | If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | | 0xc4 | largenoteson | Set notes for this channel to use "large notes" format. SM64 does this for all channels. (See `note` vs. `shortnote` in the layer section below.) | | 0xc3 | largenotesoff | Set notes for this channel to use "short notes" format. | | 0xc2, addr | setdyntable | Set dyntable to point to a given u16 array from the sequence data. | | 0xc1, u8 | setinstr | Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | | 0xb0-0xbf | dynsetlayer | If Q != -1, start layer N, with layer script given by dyntable[Q]. | | 0xa0-0xaf | freelayer | Stop layer N. | | 0x90-0x9f, addr | setlayer | Start layer N, with layer script starting at address X. | | 0x80-0x8f | ioreadval | Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | | 0x70-0x7f | iowriteval | Set IO[N] to Q. | | 0x60-0x6f | setnotepriority | Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren't any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | | 0x50-0x5f | ioreadvalsub | Decrease Q by IO[N]. | | 0x40-0x4f, u8 | ioreadval2 | Set Q to IO2[X], where IO2 is the IO array for channel N. | | 0x30-0x3f, u8 | iowriteval2 | Set IO2[X] to Q, where IO2 is the IO array for channel N. | | 0x20-0x2f | disablechannel | Disable channel N for the parent sequence. | | 0x10-0x1f, addr | startchannel | Start channel N for the parent sequence, with channel script starting at address X. | | 0x00-0x0f | testlayerfinished | Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). | ## Layers (is this the right name? I've seen "track" used as well) | hex | mnemonic |description| |-------------------------|-----------------------------------|-----------| | 0xff | end | End of script, loop or function | | 0xfc, addr | call | Call a function | | 0xfb, addr | jump | Jump to a point in the layer script | | 0xf8, u8 | loop | Repeat until `loopend` for X iterations (256 if X = 0) | | 0xf7 | loopend | Loop end marker | | 0xe0-0xef | setshortnotedurationfromtable | Set the duration for future short notes to table[N], where table defaults to `{229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0}` and can be set by `setshortnotedurationtable`. | | 0xd0-0xdf | setshortnotevelocityfromtable | Set the velocity for future short notes to table[N], where table defaults to `{12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127}` and can be set by `setshortnotevelocitytable`. | | 0xca, u8 | setpan | Set the pan for this layer (0..128). | | 0xc9, u8 | setshortnoteduration | Set the duration for future short notes. | | 0xc8 | disableportamento | Disable portamento for later notes. | | 0xc7, u8, u8, u8/var | portamento | Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | | 0xc6, u8 | setinstr | Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | | 0xc5 | somethingoff | Turn off some bool related to how notes decay somehow? (This is the default.) | | 0xc4 | somethingon | Turn on the same thing. | | 0xc3, var | setshortnotedefaultplaypercentage | Set the default play percentage for short notes (see below). | | 0xc2, u8 | transpose | Set transposition in semitones. | | 0xc1, u8 | setshortnotevelocity | Set velocity for future short notes. | | 0xc0, var | delay | Delay for N ticks | | 0x00-0x3f, var, u8, u8 | note0 | Play note with play percentage X, velocity Y, duration Z and pitch N. (Is "play percentage" the right term?). Only valid if channel is set to "large notes". | | 0x40-0x7f, var, u8 | note1 | Play note with play percentage X, velocity Y, duration 0 and pitch N. Only valid if channel is set to "large notes". | | 0x80-0xbf, u8, u8 | note2 | Play note with velocity X, duration Y, pitch N and the last used play percentage. Only valid if channel is set to "large notes". | | 0x00-0x3f, var | smallnote0 | Play note with play percentage X and pitch N, with velocity and duration taken from the short notes settings set by setshortnote{velocity,duration} (or the fromtable variants), defaulting to 0 and 0x80 respectively if not set. Only valid if channel is set to "small notes". | | 0x40-0x7f | smallnote1 | Play note with pitch N and the default play percentage, as set by setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in smallnote0. Only valid if channel is set to "small notes". | | 0x80-0xbf | smallnote2 | Play note with pitch N and the previous play percentage. Velocity and duration is set like in smallnote0. Only valid if channel is set to "small notes". | ## ADSR envelope ADSR envelopes describe how note volume changes over time, and have the format of any number of pairs of u16's, which have to be 2-byte aligned. Volume starts at 0. Each pair is of one of the following forms: * 0, anything: stop the note * -1, anything: sustain the note indefinitely at the same volume * -2, index: goto that envelope table row * -3, anything: restart the envelope loop from the beginning, with volume 0 * time, volume: transition to that volume over the given amount of time

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully