logo
macro_rules! retro_core {
    ( $( $definition:tt )+ ) => { ... };
}
Expand description

This macro must be used to initialize your Core.

Examples

struct ExampleCore {
    option_1: bool,
    option_2: bool,

    pixels: [u8; 800 * 600 * 4],
    timer: i64,
    even: bool,
}
retro_core!(ExampleCore {
    option_1: false,
    option_2: true,

    pixels: [0; 800 * 600 * 4],
    timer: 5_000_001,
    even: true,
});

/// Dummy implementation
impl CoreOptions for ExampleCore {}
impl Core for ExampleCore {
    fn get_info(&self) -> SystemInfo {
        SystemInfo {
            library_name: CString::new("ExampleCore").unwrap(),
            library_version: CString::new("1.0.0").unwrap(),
            valid_extensions: CString::new("").unwrap(),
            need_fullpath: false,
            block_extract: false,
        }
    }
    fn on_get_av_info(&mut self, _ctx: &mut GetAvInfoContext) -> retro_system_av_info {
        retro_system_av_info {
            geometry: retro_game_geometry {
                base_width: 800,
                base_height: 600,
                max_width: 800,
                max_height: 600,
                aspect_ratio: 0.0,
            },
            timing: retro_system_timing {
                fps: 60.0,
                sample_rate: 0.0,
            },
        }
    }
    fn on_init(&mut self, ctx: &mut InitContext) { }
}