Struct Options

Source
#[non_exhaustive]
pub struct Options { pub tickrate: Option<u16>, pub max_size: Option<u16>, pub screen_rotation: ScreenRotation, pub font_style: Font, pub touch_input_mode: TouchMode, pub start_address: Option<u16>, pub colors: Colors, pub quirks: Quirks, }
Expand description

Representation of Octo options.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§tickrate: Option<u16>

The number of CHIP-8 instructions executed per 60Hz frame, ie. the “speed” of the virtual CPU. These are all approximations of hardware limitations, because on real hardware different instructions execute in different times, but it’s a conventional middle ground.

Common values:

  • 7–15 (approximate speed of the original interpreter for the COSMAC VIP)
  • 20–30 (approximate speed of the SUPER-CHIP interpreters for the HP 48 calculators)
  • 10000 (Octo’s “Ludicrous speed” setting)
§max_size: Option<u16>

The maximum amount of virtual memory, in bytes, that is available to the program. If the CHIP-8 program is larger than this, the interpreter should give an error.

At least 512 bytes are always reserved for the CHIP-8 interpreter and unavailable to the CHIP-8 game; see the field start_address.

This is mostly relevant when developing CHIP-8 games for real hardware, as an assertion that the game will fit in the target platform’s memory. Most CHIP-8 interpreters can ignore this value without consequence.

Common values:

  • 3216 (original interpreter for the COSMAC VIP with 4K RAM)
  • 3583 (SUPER-CHIP interpreter for the HP 48)
  • 3584 (Octo)
  • 65024 (XO-CHIP interpreters)

Other values might be used for games for more obscure platforms, games that were designed to run on a COSMAC VIP with only 2K RAM, etc.

§screen_rotation: ScreenRotation

The orientation of the display.

§font_style: Font

The font style expected by the game.

§touch_input_mode: TouchMode

The touch controls this game supports.

§start_address: Option<u16>

The memory address in the virtual RAM that this game should be loaded from. On legacy hardware, the interpreter itself was loaded into the lower memory addresses, and then the game was loaded after it (usually at address 0x200, ie. 512).

Common values:

  • 512 (original interpreter for the COSMAC VIP, DREAM 6800, HP 48, etc)
  • 1536 (interpreter for the ETI-660)
§colors: Colors

Custom colors this game would like to use, if possible. It’s not important for a CHIP-8 interpreter to support custom colors although not doing so might impact the creator’s artistic vision, especially for XO-CHIP games that use more than two colors.

§quirks: Quirks

Specific behaviors this game expects from the interpreter in order to run properly. See [OctoQuirks] for specifics.

Implementations§

Source§

impl Options

Source

pub fn from_ini(s: &str) -> Result<Self, Error>

Deserializes Options from an INI string.

§Errors

Returns an Err if deserialization from the INI failed.

Source

pub fn to_ini(self) -> String

Serializes Options to an INI string.

Source

pub fn new(platform: Platform) -> Self

Get a preset set of Options based on a target Platform.

Trait Implementations§

Source§

impl Debug for Options

Source§

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

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

impl Default for Options

Returns a default with a pretty fast tickrate, the maximum ROM size possible, and no quirks enabled except that the LoResDxy0Behavior assumes Octo behavior.

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Options

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 Options

Serializes Options into a JSON string.

This format is used by Octo in Octocarts and HTML exports, as well as the Chip-8 Archive.

Source§

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

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

impl FromStr for Options

Deserializes Options from a JSON string.

This format is used by Octo in Octocarts and HTML exports, as well as the Chip-8 Archive.

Source§

type Err = Error

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 Options

Source§

fn eq(&self, other: &Options) -> 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 Options

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 Options

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