News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - HertzDevil

Pages: [1]
1
ROM Hacking Discussion / Journey to Silius music hacking notes
« on: January 09, 2017, 10:32:50 am »
Some notes I made while adding support for Journey to Silius to my generic MML inserter. They will be sent to the database or the wiki later.

Command List
  • 00 xx, 01 xx, ... 7F xx: Plays a note for xx ticks; 00 is C2 (MIDI note 36). The high nybble does not seem to have any purpose on the noise track. xx must be omitted if fixed note duration is enabled (see F6).
  • E5: Finishes a group of slur notes. E0 to E4 are all unused aliases.
  • E6: Disables the current pitch envelope.
  • E7 xx yyyy: Sets a pitch envelope; The envelope pointed by yyyy starts xx ticks after each new note.
  • E8 xx yyyy: (unused)
  • E9: Begins a group of slur notes; the next note plays as usual, and then all new notes do not retrigger the instrument envelopes until the next E5 command.
  • EA xxxx: Sets a volume/duty envelope; the envelope pointed by xxxx starts with all new notes.
  • EB xx: Writes xx to the 2A03 pulse sweep register ($4001 / $4005) for all new notes.
  • EC xx: On the pulse or noise channel, disables the volume envelope and writes xx to the volume/duty register ($4000 / $4004 / $400C) for all new notes. On the triangle channel, writes xx to the linear counter register ($4008) for all new notes.
  • ED xx yy: Waits for yy ticks, decreasing the track volume by 1 every xx ticks.
  • EE xx: Forces all new notes to trigger the release envelope xx ticks before it finishes. Unused.
  • EF: Disables the release part of the volume/duty envelope.
  • F0: Halts the current track.
  • F1 xx: Note rest; plays nothing for xx ticks. xx must be omitted if fixed note duration is enabled (see F6).
  • F2 xx: Extends the duration of the previous note by xx ticks. xx must be omitted if fixed note duration is enabled (see F6).
  • F5 xx: Gate time; behaves like EE, but the release time is at most half the note duration. F3 and F4 are unused aliases.
  • F6 xx: Enables fixed note duration; all future note events (00-7F, F1, F2) use xx as the number of ticks.
  • F7: Disables fixed note duration.
  • F8 xx: Detune; adds (xx - 80) to the channel's period register. Values less than 80 will therefore raise the pitch.
  • F9 xx: Transpose; shifts all new notes by xx semitones.
  • FA: Leaves the current pattern, if there is one.
  • FB xxxx: Invokes the pattern pointed by xxxx.
  • FC xxxx: Unconditionally moves the track pointer to xxxx.
  • FD xx yyyy: Loop; moves the track pointer to yyyy for xx times.
  • FE xx yyyy: Loop; same as FD, but uses different variables, permitting nested loops.
Volume/Duty Envelope Format
  • Byte pointer to the release point, relative to the beginning of the envelope, or 00 if there is none;
  • One byte for each tick, where the entire byte is written verbatim to the volume/duty register;
  • The byte 00;
  • Byte pointer to the sustain envelope's loop point, relative to the beginning of the envelope (must be positive). If this is negative, decreases the instrument volume by 1 every (xx - 80) ticks, or holds the volume if it is exactly 80;
  • If there is a release envelope, the 3 items above are repeated.
Pitch Envelope Format
  • One byte for each tick, where the most significant bit is the direction, raising the pitch if clear, and the remaining 7 bits are the offset amount for the period register;
  • The byte 00; (80 must be used for parts of the envelope with zero pitch offset)
  • Byte pointer to the envelope loop point, relative to the beginning of the envelope.
Song Format
  • Track index, may be 00 to 08, higher values have higher priority (used by sound effects);
  • Channel index, may be 00 (Pulse 1), 01 (Pulse 2), 02 (Triangle), or 03 (Noise), omitted for the DPCM track;
  • Pointer to the beginning of the track data;
  • After all track definitions are placed, the byte FF terminates the song definition.
Lookup Tables
  • $862F - $86F0: Period lookup table, starting with 97 high bytes followed by the corresponding low bytes. All period values are subtracted by 0x80.
  • $BEFB - $BF50: Song / sound effect pointer table, 43 entries.
  • $BF51 - $BFC0: DPCM assignment table, 28 entries, where each entry consists of 4 bytes; DPCM pitch, initial delta counter value, sample index (real address is C000 + xx * 40), sample length (real length is xx * 10 + 1).
Caveats
  • Envelopes may appear anywhere within the music data, so every time a track needs to use a new instrument envelope it must repeat the envelope pointer.
  • There are no instrument definitions for the triangle / noise channel's percussion. They are controlled entirely by separate notes and pattern invocations.
  • Command FA does nothing if there is not a current pattern in use, which means patterns may be defined within the main track data itself, or even defined on another track (Stage 1 does this for almost the entire Pulse 1 track's echo data). Example taken from the title's triangle track:
Code: [Select]
$AD3C: 1B 01 1A 01 19 01 F1 07 FA                   [ (kick8)[o2 d+%1 d%1 c+%1 r%7]
$AD45: FB 3C AD                                       (kick8)
$AD48: F6 01 21 20 1F 1E 1D 1C 1B 1A 19 F1 F7 FA      (snare8)[L1 o2 ag+gf+fed+dc+ r L0]
$AD56: FB 3C AD                                       (kick8)
$AD59: FB 3C AD                                       (kick8)
$AD5C: FB 3C AD                                       (kick8)
$AD5F: FB 48 AD                                       (snare8)
$AD62: FB 3C AD                                       (kick8)
$AD65: FE 02 3C AD                                  ]3
$AD69: F6 01 25 24 23 22 21 20 1F 1E 1D F1 F7 FA    (tomhi8)[L1 o3 c+c<ba+ag+gf+f r L0]
$AD77: FB 69 AD                                     (tomhi8)
$AD7A: F6 01 1D 1C 1B 1A 19 18 17 16 15 F1 F7 FA    (tommid8)[L1 o2 fed+dc+c<ba+a r L0]
$AD88: FB 2E AD                                     (tomlo8) ; defined earlier
$AD8B: FB 12 AD                                     (tomhi16) ; defined earlier
$AD8E: FB 12 AD                                     (tomhi16) ; defined earlier
$AD91: F1 05                                        r16
$AD93: FB 12 AD                                     (tomhi16) ; defined earlier
$AD96: FB 20 AD                                     (tommid16) ; defined earlier
$AD99: FB 20 AD                                     (tommid16) ; defined earlier
$AD9C: FB 2E AD                                     (tomlo8) ; defined earlier
  • Command FC may point to the middle of a loop. This may be used to implement loop breaks, however it does not seem to be used on local loops, only the global loop (the last command of the title's Pulse 1 track does this, skipping over a rest on looping).

2
Personal Projects / MGCInts (MML Generic Compiler Interfaces)
« on: December 20, 2016, 04:17:11 pm »
I have been making a generic MML (Music Macro Language) toolkit entirely in Lua, which allows users to write their own grammar definitions for a target sound engine. It aims to unify binary music hacking tools for almost any conceivable target, under a uniform MML syntax scheme.

MML is chosen instead of tracker formats or sequenced formats, since text files are inherently portable, and MML scripts are very transparent about the underlying data format. There is usually a one-to-one correspondence between MML streams and the data they compile to; this allows hackers to quickly inspect music data from existing ROM images (there is a utility module especially for this purpose, which reconstructs from binary data MML streams that are mostly compatible with the grammar definition it produces at the same time). Other developers may incorporate MGCInts into their toolchain and write specialized converters from other formats to MML.

Currently, it supports the following games: (see here for more details)
  • Castlevania (NES / NSF; Example)
  • Mega Man 3 (NSF)
  • Zelda II: The Adventure of Link (NSF, not published yet; Example)
  • Shatterhand (NSF, not published yet)
  • Journey to Silius (NSF, not published yet)
  • Super Robot Wars Compact 2 (WS, not published yet)
This project is licensed under the Mozilla Public License Version 2.0. It is still in very early alpha; it does not support multisong insertion yet (which means anything compiled may corrupt other music data), most engines only support JoshW NSF files, and there are almost zero examples for both the sound engines and the framework other than the source code itself. Stay tuned for updates in the coming months or, if you cannot wait to try out the MML compiler, report issues at my own bug tracker.

Download: https://github.com/HertzDevil/MGCInts (download as ZIP from the master branch or the Releases tab)

Pages: [1]