A WLA DX port of the FamiTracker / 0CC-FamiTracker NSF driver with an external compiler script that allows certain binary music data exported from the tracker to play properly as a GBS music file or a GB ROM file.
- Port NSF driver to GB-Z80
- driver.s
- init.s
- player.s
- effects.s
- instrument.s
- apu.s
merge changes from 0.5.0 beta
- Write Game Boy-specific driver code
- Length counter
- PU1 hardware sweep
- Effects
- Wxy
- Xxx
- EEy
- EF0
- EFy
- Hxy
- Ixy
- Kxx
- Nxy
- Vxx
- Vxy
- NSF bankswitching
- GB bankswitching
- Write GB / GBS generator for existing FT binary music data
- Compile GB / GBS files
- Patch period table
- Patch vibrato table / old vibrato style
- Refactor 0CC-FamiTracker (...)
Expects a NSF file exported from any of the following:
- FamiTracker 0.4.6 / FamiTracker 0.4.5
FamiTracker 0.5.0 beta 5 (other beta versions will not be verified)- 0CC-FamiTracker 0.3.13
Bankswitched music data must be natively supported if tracker implementations are available. The current port is capable of emulating the bankswitching used in the NSF driver as long as the music data is aligned in the same way as the NSF.
The track should contain exactly one Namco 163 channel, and no other expansion chips. The driver shall read the two pulse channels, the N163 channel, and the noise channel. Global effects outside these channels may still work.
Pattern effects are translated as is from the N163 channel to the Game Boy wave channel. No conversion takes place to account for the different pitch scales across Famicom / NES and GB.
Tracker implementations of the Game Boy sound chip are free to alter the binary music data format where cross-console compatibility is not desired. In particular, the following implementation details shall be different if DRV_VERSION
is not defined to be one of the values for existing FamiTracker builds: (see below)
- Track initialization; (slightly different header formats)
- Effective channels; (for FT compatibility, ignores channel 2 / 5 (triangle / DPCM), and reads channel 4 (n163 channel 1))
- Pattern effect table; (new effects)
- Bankswitching behaviour; (Game Boy uses 16 KB banks instead of 4 KB)
- Channel pitch tables. (only one table required for Game Boy)
DRV_VERSION
: The version of the binary music data. Must be one ofVER_046
,VER_050
,VER_0CC
, andVER_FINAL
, which is reserved for future tracker implementations. These options change the specific details the driver may use to read the slightly different data formats properly.TEST_CODE
: The name of an assembly source code file containing at least theft_music_init
andft_music_play
labels. If the file exists, compiles using this file instead of the default driver source code.NOISE_MODE
: Determines how notes on the noise channel map to Game Boy noise pitches. Must be one of the following:
- `DEFAULT_NOISE`: Maps `n` to `((n & 0x0F) << 4) | 0x07`. Note pitches repeat per 16 notes as in FamiTracker.
- `APPROX_NOISE`: Uses a lookup table to map noise pitches as closely as possible to the NES noise channel.
- `SCALE_NOISE`: Maps `n` to `n >= 0x40 ? /*lookup table*/[min(0x48, n) - 0x40] : (n >> 2 << 4) | (n & 0x03)`. This option expands noise channel notes such that note pitches run consecutively from C-0 to B-7, and moreover prevent the noise channel from wrapping around its pitch on overflow or underflow. This option allows the noise channel to take all 68 different noise pitches continuously.
All instruments share one type, based on the N163 sequence instrument type. Unlike N163, a Game Boy instrument may store zero waves; instruments do not overwrite the wave buffer on the wave channel whenever the wave index is greater than the instrument wave count.
Before tracker implementations are available, the driver should be expected to read both 2A03 and N163 instruments properly. 0CC-FamiTracker already did this in a generic manner; the official FamiTracker does not put instrument types into exported data, but this is not much of an issue as 2A03 and N163 instruments cannot be interchangeably used there.
Volume values do not write unless they are different from the register values. Volume mixing of the channel and the instrument does not affect the hardware envelope rate where available.
The wave channel maps internal volumes to permissible values:
- 8-F: 100%
- 4-7: 50%
- 1-3: 25%
- 0: 0%
The wave channel ignores hardware volume envelope settings in volume sequences.
Tracker implementations should not display notes on the noise channel as "?-#" where SCALE_NOISE
is defined.
Instrument volume sequences support the hardware volume envelope by overloading the high nibble of the sequence terms.
Arpeggio schemes are as in 0CC-FamiTracker.
Absolute pitch sequences are as in FamiTracker beta. Any term is equivalent to first applying an arpeggio to the current note.
Duty / noise mode settings are as in FamiTracker. They may not alter the noise channel's frequency divider even when DEFAULT_NOISE
is used.
There are no plans to add pan control to instrument sequences at this moment. Pan settings might overload the duty / noise settings.
The compiler and the sound driver both assume that the NTSC region is used.
By default, the sound driver assigns 16384
to TIMER_RATE
, 60
to REFRESH_RATE
, and 3
to DIVIDER
. With these parameters, the sound driver refreshes once per timer interrupt at a rate of exactly 16384 ÷ 3 ÷ (256 - 165) = 60.015
Hz; if vertical blank interrupts are used instead, this rate becomes exactly 4194304 ÷ 70224 = 59.73
Hz, and the standard tempo (150 BPM) will be scaled to approximately 149.32 BPM. The GBS file puts the refresh rate settings in the GBS header, and the GB ROM image manually writes these values during initialization.
There are no plans to implement the fast pitch/vibrato mode or the wave/speech kits from LSDj.
The GBS specification states that either the vertical blank or the timer shall be used to clock the sound driver, but never both. Any feature requiring both interrupts will not be available.
For suggestions message @HertzDevil
on Twitter or hezedefil
on Skype. Do not contact through places designated for 0CC-FamiTracker.
Dear HertzDevil, won't you please open the source of the player?