#[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

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

Formats the value using the given formatter. Read more

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

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

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.