1#[doc(alias = "GSPGPU_Event")]
5#[derive(Copy, Clone, Debug, PartialEq, Eq)]
6#[repr(u8)]
7pub enum Event {
8 Psc0 = ctru_sys::GSPGPU_EVENT_PSC0,
10 Psc1 = ctru_sys::GSPGPU_EVENT_PSC1,
12 VBlank0 = ctru_sys::GSPGPU_EVENT_VBlank0,
14 VBlank1 = ctru_sys::GSPGPU_EVENT_VBlank1,
16 PPF = ctru_sys::GSPGPU_EVENT_PPF,
18 P3D = ctru_sys::GSPGPU_EVENT_P3D,
20 DMA = ctru_sys::GSPGPU_EVENT_DMA,
22}
23
24#[doc(alias = "GSPGPU_FramebufferFormat")]
25#[derive(Copy, Clone, Debug, PartialEq, Eq)]
27#[repr(u8)]
28pub enum FramebufferFormat {
29 Rgba8 = ctru_sys::GSP_RGBA8_OES,
31 Bgr8 = ctru_sys::GSP_BGR8_OES,
33 Rgb565 = ctru_sys::GSP_RGB565_OES,
35 Rgb5A1 = ctru_sys::GSP_RGB5_A1_OES,
37 Rgba4 = ctru_sys::GSP_RGBA4_OES,
39}
40
41impl FramebufferFormat {
42 pub fn pixel_depth_bytes(&self) -> usize {
44 use self::FramebufferFormat::*;
45 match *self {
46 Rgba8 => 4,
47 Bgr8 => 3,
48 Rgb565 => 2,
49 Rgb5A1 => 2,
50 Rgba4 => 2,
51 }
52 }
53}
54
55#[doc(alias = "gspWaitForEvent")]
59pub fn wait_for_event(ev: Event, discard_current: bool) {
60 unsafe {
61 ctru_sys::gspWaitForEvent(ev.into(), discard_current);
62 }
63}
64
65impl From<ctru_sys::GSPGPU_FramebufferFormat> for FramebufferFormat {
66 fn from(g: ctru_sys::GSPGPU_FramebufferFormat) -> Self {
67 use self::FramebufferFormat::*;
68 match g {
69 ctru_sys::GSP_RGBA8_OES => Rgba8,
70 ctru_sys::GSP_BGR8_OES => Bgr8,
71 ctru_sys::GSP_RGB565_OES => Rgb565,
72 ctru_sys::GSP_RGB5_A1_OES => Rgb5A1,
73 ctru_sys::GSP_RGBA4_OES => Rgba4,
74 _ => unreachable!(),
75 }
76 }
77}
78
79from_impl!(FramebufferFormat, ctru_sys::GSPGPU_FramebufferFormat);
80from_impl!(Event, ctru_sys::GSPGPU_Event);