Enum Font

Source
#[non_exhaustive]
pub enum Font { Octo, Vip, Dream6800, Eti660, Schip, Fish, AKouZ1, }
Expand description

Represents the different fonts a CHIP-8 interpreter can provide.

It’s not likely that many (or any) historical CHIP-8 games depend on a particular font, but it’s possible, and for that reason (and to make historical games look accurate) the font can be overriden here and you can get the sprite data for the fonts by calling [get_font_data].

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Octo

The font used by Octo. Its small digits are identical to SUPER-CHIP’s, but the big digits are a bigger version of the small ones, rather than SUPER-CHIP’s rounded big digits. Contains small digits for 0–F, as well as big digits for 0–F.

§

Vip

The font used by the original CHIP-8 interpreter on the COSMAC VIP. Contains small digits for 0–F only.

§

Dream6800

The font used by CHIP-8/CHIPOS on the DREAM 6800. Contains small digits for 0–F only.

§

Eti660

The font used by the CHIP-8 interpreter on the ETI-660. Contains small digits for 0–F only. Very similar to Dream6800.

§

Schip

The font used by SUPER-CHIP 1.1 on the HP 48. Contains small digits for 0–F (identical to Octo’s), but only big digits for 0–9.

§

Fish

Custom font used by the Fish’n’Chips CHIP-8 emulator. Contains small digits for 0–F and big digits (7x9 pixels) for 0–F.

§

AKouZ1

Font designed by A-KouZ1, used by in the KChip-8 and FPChip-8 emulators. Contains small digits for 0–F and big digits for 0–F.

Implementations§

Source§

impl Font

Source

pub fn get_font_data(&self) -> ([u8; 80], Option<Vec<u8>>)

Returns a tuple where the first element is an array of 16 sprites that are 5 bytes tall, where each one represents the sprite data for a hexadecimal digit in a CHIP-8 font, and the other optional element is a vector of sprites that are 10 bytes tall.

Note that some fonts are smaller than this, but the extra padding is still included so emulators and games can use the same routines regardless of the font.

Not all fonts provide the larger sprites, as they became standard with SUPER-CHIP’s high resolution mode. Furthermore, the SUPER-CHIP font set itself only provides large sprites for the decimal digits 0–9, not the hexadecimal A–F.

A modern CHIP-8 interpreter will put its font data (for one font) somewhere in the first 512 bytes of memory, which are reserved for the interpreter, but the actual memory location doesn’t matter. It’s common to put it at either address 0 or 80 (0x50).

Trait Implementations§

Source§

impl Debug for Font

Source§

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

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

impl Default for Font

The default font is Octo’s font, as it’s the modern standard and contains all hexadecimal digits in both small and large variants.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Font

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Font

Source§

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

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

impl FromStr for Font

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Font

Source§

fn eq(&self, other: &Font) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Font

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Font

Auto Trait Implementations§

§

impl Freeze for Font

§

impl RefUnwindSafe for Font

§

impl Send for Font

§

impl Sync for Font

§

impl Unpin for Font

§

impl UnwindSafe for Font

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> 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> IntoResult<T> for T

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,