Music in the game is managed by Music Scripts ("MScripts" for short). This is still early in the reverse-engineering phase. Documentation will be fleshed out as I know more. # Memory Locations There are a few memory locations relevant to MScripts: | Bank | Address Range | Description | | ---- | ------------- | ---------------- | | 5 | $826A - $828D | Ops lookup table | | 5 | | | # MScripts Structure BScripts have the following structure: | Script Offset | Size (bytes) | Description | | ------------- | ------------ | ----------- | | 0 | 1 | Op ID | | 1+ | N | Parameters | | ... | | | Scripts will end with an End Script (0xFF) or Go To (0x05 + address). # Ops Operations are identified by a number between 0 and 7, and a special value 0xFF. Implementations are all in Bank 12. Here's a quick summary of the ops: | Op ID | Name | Arguments | Implementation Address | | ----- | --------------------------------------- | ----------- | ---------------------- | | $EE | Reduce SQ2 Length By | 1 (1 byte) | $853B | | $EF | Set Something_Music_017f | 1 (1 byte) | $852F | | $F0 | Set Square Wave decay mode | 1 (1 byte) | $8523 | | $F1 | Set Square Wave volume | 1 (1 byte) | $8517 | | $F2 | Set Something_Music_0172 | 1 (1 byte) | $8483 | | $F3 | Repeat value | 1 (1 byte) | | | $F4 | Restart music | 0 | $84B7 | | $F5 | Return from subroutine | 1 (2 bytes) | $84F0 | | $F6 | Set SQ1 High | 1 (1 byte) | $8502 | | $F7 | Set MScript_Maybe_8BitCounter | 1 (1 byte) | $850E | | $F8 | Jump to subroutine | 0 | $84D0 | | $F9 | Save address (see $FE) | 0 | $848F | | $FA | No-op | 0 | $8480 | | $FB | Continue loop if N iterations completed | 1 (1 byte) | $043D | | $FC | End of loop | 0 | $8458 | | $FD | Start of loop. | 1 (1 byte) | $841F | | $FE | Restore address (from $F9) | 0 | $84A5 | | $FF | Finish channel playback | | $8408 | ## Op $00: Reduce SQ2 Length By TODO ...