Skip to main content

Nsf

Struct Nsf 

Source
pub struct Nsf {
Show 15 fields pub total_songs: u8, pub starting_song: u8, pub load_addr: u16, pub init_addr: u16, pub play_addr: u16, pub bankswitched: bool, pub initial_banks: [u8; 8], pub expansion: u8, pub pal: bool, pub play_speed_ntsc: u16, pub play_speed_pal: u16, pub prg: Vec<u8>, pub song_name: Box<str>, pub artist: Box<str>, pub copyright: Box<str>,
}
Expand description

Parsed NSF header + program image.

Fields§

§total_songs: u8

Total number of songs in the file (1-based count).

§starting_song: u8

The 1-based song the file wants to start on.

§load_addr: u16

16-bit load address of the program image.

§init_addr: u16

init routine address (called once per track with A = song index).

§play_addr: u16

play routine address (called once per frame).

§bankswitched: bool

true when the file uses $5FF8-$5FFF 4 KiB bank switching.

§initial_banks: [u8; 8]

Initial bank register values ($070-$077 of the header).

§expansion: u8

Expansion-chip bitfield ($07B). Routed into the matching synth cores by the nsf_expansion module when any bit is set (v1.7.0 G2/G3).

§pal: bool

true when the file declares a PAL or dual-region timing preference.

§play_speed_ntsc: u16

NTSC play-speed divider (header $6E-$6F), in microseconds per play call. 0 means “use the hardware default” (≈16639 µs ≈ 60.0988 Hz). Classic NESM only; NSFe has no µs word and derives the rate from region.

§play_speed_pal: u16

PAL play-speed divider (header $78-$79), in microseconds per play call. 0 means the PAL hardware default (≈19997 µs ≈ 50.007 Hz).

§prg: Vec<u8>

The program image, padded + 4 KiB-aligned when bank-switched.

§song_name: Box<str>

UTF-8-lossy song / artist / copyright strings (trimmed at the first NUL).

§artist: Box<str>

Artist name.

§copyright: Box<str>

Copyright holder.

Implementations§

Source§

impl Nsf

Source

pub const fn effective_speed_us(&self) -> u16

The effective play-speed divider (µs) this file wants, resolving a 0 header word to the region hardware default and picking NTSC vs PAL by the region flag.

Source

pub fn nonstandard_play_period_cycles(&self) -> Option<u32>

The play period in NTSC CPU cycles, or None when the file plays at the standard once-per-NTSC-frame 60 Hz rate (the fast, vblank-NMI-driven path). Some(cycles) selects the cycle-timer IRQ driver — a PAL tune (50 Hz) or any custom divider on the NTSC console.

Trait Implementations§

Source§

impl Clone for Nsf

Source§

fn clone(&self) -> Nsf

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Nsf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Nsf

§

impl RefUnwindSafe for Nsf

§

impl Send for Nsf

§

impl Sync for Nsf

§

impl Unpin for Nsf

§

impl UnsafeUnpin for Nsf

§

impl UnwindSafe for Nsf

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.