1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::prelude::*;
use soloud_sys::soloud as ffi;

#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
pub enum VicModel {
    Pal = 0,
    Ntsc,
}

#[repr(u8)]
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
pub enum VicRegister {
    Bass = 0,
    Alto,
    Soprano,
    Noise,
    MaxRegs,
}

#[derive(AudioExt)]
pub struct Vic {
    _inner: *mut ffi::Vic,
}

impl Vic {
    /// Get the VicModel of the Vic object
    pub fn model(&self) -> VicModel {
        assert!(!self._inner.is_null());
        unsafe { std::mem::transmute(ffi::Vic_getModel(self._inner)) }
    }
    
    /// Set the VicModel of the Vic object
    pub fn set_model(&mut self, model: VicModel) {
        assert!(!self._inner.is_null());
        unsafe { ffi::Vic_setModel(self._inner, model as i32) }
    }

    /// Get the VicRegister of the Vic object
    pub fn register(&self, reg: i32) -> VicRegister {
        assert!(!self._inner.is_null());
        unsafe { std::mem::transmute(ffi::Vic_getRegister(self._inner, reg)) }
    }
    
    /// Set the VicRegister of the Vic object
    pub fn set_register(&mut self, val: u8, reg: VicRegister) {
        assert!(!self._inner.is_null());
        unsafe { ffi::Vic_setRegister(self._inner, val as i32, reg as u8) }
    }
}