#[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
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
sourceimpl Font
impl Font
sourcepub fn get_font_data(&self) -> ([u8; 80], Option<Vec<u8>>)
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
sourceimpl Default for Font
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.
sourceimpl<'de> Deserialize<'de> for Font
impl<'de> Deserialize<'de> for Font
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Font
Auto Trait Implementations
impl RefUnwindSafe for Font
impl Send for Font
impl Sync for Font
impl Unpin for Font
impl UnwindSafe for Font
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more