psp/sys/display.rs
1use core::ffi::c_void;
2use num_enum::TryFromPrimitive;
3
4#[repr(u32)]
5/// Display mode.
6///
7/// Display modes other than LCD are unknown.
8pub enum DisplayMode {
9 // https://github.com/hrydgard/ppsspp/blob/25197451e5cdb1b83dc69fea14c501bdb1e13b1a/Core/HLE/sceDisplay.cpp#L922
10 Lcd = 0,
11 // TODO: What are the other modes?
12}
13
14#[derive(Debug, Copy, Clone, TryFromPrimitive)]
15#[repr(u32)]
16/// Framebuffer pixel formats.
17pub enum DisplayPixelFormat {
18 /// 16-bit RGB 5:6:5
19 Psm5650 = 0,
20 /// 16-bit RGBA 5:5:5:1
21 Psm5551 = 1,
22 /// 16-bit RGBA 4:4:4:4
23 Psm4444 = 2,
24 /// 32-bit RGBA 8:8:8:8
25 Psm8888 = 3,
26}
27
28#[derive(Debug, Clone, Copy)]
29#[repr(u32)]
30pub enum DisplaySetBufSync {
31 /// Buffer change effective immediately
32 Immediate = 0,
33 /// Buffer change effective next frame
34 NextFrame = 1,
35}
36
37psp_extern! {
38 #![name = "sceDisplay"]
39 #![flags = 0x4001]
40 #![version = (0, 0)]
41
42 #[psp(0x0E20F177)]
43 /// Set display mode
44 ///
45 /// # Parameters
46 ///
47 /// - `mode`: Display mode, normally `DisplayMode::Lcd`.
48 /// - `width`: Width of screen in pixels.
49 /// - `height`: Height of screen in pixels.
50 ///
51 /// # Return value
52 ///
53 /// ???
54 pub fn sceDisplaySetMode(mode: DisplayMode, width: usize, height: usize) -> u32;
55
56 #[psp(0xDEA197D4)]
57 /// Get display mode
58 ///
59 /// # Parameters
60 ///
61 /// - `pmode`: Pointer to an integer to receive the current mode.
62 /// - `pwidth`: Pointer to an integer to receive the current width.
63 /// - `pheight`: Pointer to an integer to receive the current height.
64 ///
65 /// # Return value
66 ///
67 /// 0 on success
68 pub fn sceDisplayGetMode(pmode: *mut i32, pwidth: *mut i32, pheight: *mut i32) -> i32;
69
70 #[psp(0x289D82FE)]
71 /// Display set framebuffer
72 ///
73 /// # Parameters
74 ///
75 /// - `top_addr`: Address of start of framebuffer
76 /// - `buffer_width`: Buffer width (must be power of 2)
77 /// - `pixel_format`: One of `PspDisplayPixelFormats`.
78 /// - `sync`: One of `PspDisplaySetBufSync`
79 ///
80 /// # Return value
81 ///
82 /// 0 on success
83 pub fn sceDisplaySetFrameBuf(
84 top_addr: *const u8,
85 buffer_width: usize,
86 pixel_format: DisplayPixelFormat,
87 sync: DisplaySetBufSync,
88 ) -> u32;
89
90 #[psp(0xEEDA2E54)]
91 /// Get display framebuffer information
92 ///
93 /// # Parameters
94 ///
95 /// - `top_addr`: Pointer to void* to receive address of start of framebuffer
96 /// - `buffer_width`: Pointer to usize to receive buffer width (must be power of 2)
97 /// - `pixelformat`: Pointer to receive DisplayPixelFormat.
98 /// - `sync`: One of `DisplaySetBufSync`
99 pub fn sceDisplayGetFrameBuf(
100 top_addr: *mut *mut c_void,
101 buffer_width: *mut usize,
102 pixel_format: *mut DisplayPixelFormat,
103 sync: DisplaySetBufSync,
104 ) -> i32;
105
106 #[psp(0x9C6EAAD7)]
107 /// Number of vertical blank pulses up to now
108 pub fn sceDisplayGetVcount() -> u32;
109
110 #[psp(0x36CDFADE)]
111 /// Wait for vertical blank
112 pub fn sceDisplayWaitVblank() -> i32;
113
114 #[psp(0x8EB9EC49)]
115 /// Wait for vertical blank with callback
116 pub fn sceDisplayWaitVblankCB() -> i32;
117
118 #[psp(0x984C27E7)]
119 /// Wait for vertical blank start
120 pub fn sceDisplayWaitVblankStart() -> i32;
121
122 #[psp(0x46F186C3)]
123 /// Wait for vertical blank start with callback
124 pub fn sceDisplayWaitVblankStartCB() -> i32;
125
126 #[psp(0x210EAB3A)]
127 /// Get accumulated HSYNC count
128 pub fn sceDisplayGetAccumulatedHcount() -> i32;
129
130 #[psp(0x773DD3A3)]
131 /// Get current HSYNC count
132 pub fn sceDisplayGetCurrentHcount() -> i32;
133
134 #[psp(0xDBA6C4C4)]
135 /// Get number of frames per second
136 pub fn sceDisplayGetFramePerSec() -> f32;
137
138 #[psp(0xB4F378FA)]
139 /// Get whether or not frame buffer is being displayed
140 pub fn sceDisplayIsForeground() -> i32;
141
142 #[psp(0x4D4E10EC)]
143 /// Test whether vblank is active
144 pub fn sceDisplayIsVblank() -> i32;
145}