Skip to main content

create_chip_with_callbacks

Function create_chip_with_callbacks 

Source
pub fn create_chip_with_callbacks(
    chip_type: ChipType,
    clock: u32,
    callbacks: Box<InterfaceCallbacks>,
) -> UniquePtr<Chip> 
Expand description

Create a chip and forward ymfm interface callbacks to callbacks.

Examples found in repository?
examples/vgmrender.rs (lines 47-53)
42    fn new(chip_type: ChipType, clock: u32) -> Self {
43        let state = Rc::new(RefCell::new(VgmHandlerState {
44            data: std::array::from_fn(|_| Vec::new()),
45        }));
46        let pcm_offset = Rc::new(RefCell::new(0u32));
47        let chip = ffi::create_chip_with_callbacks(
48            chip_type,
49            clock,
50            Box::new(InterfaceCallbacks::new(vgm_handler_with_state(Rc::clone(
51                &state,
52            )))),
53        );
54        let channels = chip.channels() as usize;
55        let step: EmulatedTime = 0x1_0000_0000i64 / i64::from(chip.sample_rate());
56        Self {
57            chip,
58            channels,
59            queue: std::collections::VecDeque::new(),
60            pos: 0,
61            step,
62            native: vec![0i32; channels],
63            handler_state: state,
64            pcm_offset,
65        }
66    }