Skip to main content

Register

Enum Register 

Source
#[repr(u8)]
pub enum Register {
Show 16 variants AFreq8bitFinetone = 0, AFreq4bitRoughtone = 1, BFreq8bitFinetone = 2, BFreq4bitRoughtone = 3, CFreq8bitFinetone = 4, CFreq4bitRoughtone = 5, NoiseFreq5bit = 6, IoPortMixerSettings = 7, ALevel = 8, BLevel = 9, CLevel = 10, EFreq8bitFineAdj = 11, EFreq8bitRoughAdj = 12, EShape = 13, DataIoA = 14, DataIoB = 15,
}
Expand description

One of the 16 registers (0-15) of the YM2149 sound chip.

Used to select which register to write / read. Each register controls different aspects of tone generation, noise, mixing, amplitude, and envelope.

Check the datasheet / docs for detailed information.

Variants§

§

AFreq8bitFinetone = 0

Frequency of channel A: 8 bit fine tone adjustment

§

AFreq4bitRoughtone = 1

Frequency of channel A: 4 bit rough tone adjustment

Mask: 0x0F

§

BFreq8bitFinetone = 2

Frequency of channel B: 8 bit fine tone adjustment

§

BFreq4bitRoughtone = 3

Frequency of channel B: 4 bit rough tone adjustment

Mask: 0x0F

§

CFreq8bitFinetone = 4

Frequency of channel C: 8 bit fine tone adjustment

§

CFreq4bitRoughtone = 5

Frequency of channel C: 4 bit rough tone adjustment

Mask: 0x0F

§

NoiseFreq5bit = 6

Frequency of noise: 5 bit noise frequency

Mask: 0x1F

§

IoPortMixerSettings = 7

I/O Port and mixer settings

From the datasheet:

  • Sound is output when ‘0’ is written to the register.
  • Selection of input/output for the I/O ports is determined by bits B7 and B6 of register R7.
  • Input is selected when ‘0’ is written to the register bits.
Bit:B7B6B5B4B3B2B1B0
Type:I/OI/ONoiseNoiseNoiseToneToneTone
Channel:IOBIOACBACBA

Example:

// Enables only channel A, with IOA and IOB functioning as outputs.
use ym2149_core::{
    command::{Command, CommandOutput},
    register::Register,
    chip::YM2149
};

struct DebugWriter;

impl CommandOutput for DebugWriter {
    fn execute(&mut self, command: Command) {
        let arr = command.as_array();
        println!("Writing 0b{:08b} to register 0b{:08b}.", arr[0], arr[1]);
    }
}

let mut chip = YM2149::new(
    DebugWriter{},
    2_000_000,
).expect("Error building chip");

chip.command(
    Register::IoPortMixerSettings,
    0b11111110
);
§

ALevel = 8

§Level of channel A

Level control (formats identical for ALevel, BLevel and CLevel)

From the datasheet:

  • Mode M selects whether the level is fixed (when M = 0) or variable (M = 1).
  • When M = 0, the level is determined from one of 16 by level selection signals L3, L2, L1, and L0 which compromise the lower four bits.
  • When M = 1, the level is determined by the 5 bit output of E4, E3, E2, E1, and E0 of the envelope generator of the SSG.
B7 (MSB)B6B5B4B3B2B1B0
N/AN/AN/AML3L2L1L0
§

BLevel = 9

Level of channel B

Same format as ALevel

§

CLevel = 10

Level of channel C

Same format as ALevel

§

EFreq8bitFineAdj = 11

Frequency of envelope: 8 bit fine adjustment

§

EFreq8bitRoughAdj = 12

Frequency of envelope: 8 bit rough adjustment

§

EShape = 13

Shape of envelope

§

DataIoA = 14

Data of I/O port A

§

DataIoB = 15

Data of I/O port B

Trait Implementations§

Source§

impl Clone for Register

Source§

fn clone(&self) -> Register

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Register

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ValidRegister for Register

Source§

fn address(self) -> u8

Source§

impl Copy for Register

Auto Trait Implementations§

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, 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.