This commit is contained in:
2024-05-11 23:24:13 +02:00
commit e66c5afde0
130 changed files with 17039 additions and 0 deletions
+133
View File
@@ -0,0 +1,133 @@
package display
import "core:c"
import sce "../common"
foreign import _display "system:SceDisplay_stub"
@(link_prefix = "sceDisplay")
foreign _display {
/**
* Set/Update framebuffer parameters
*
* @param[in] pParam - Pointer to a ::SceDisplayFrameBuf structure.
* @param[in] sync - One of ::SceDisplaySetBufSync
*
* @return 0 on success, < 0 on error.
* @note - If NULL is provided as pParam pointer, output is blacked out.
*/
SetFrameBuf :: proc(pParam: ^SceDisplayFrameBuf, sync: SceDisplaySetBufSync) -> c.int ---
/**
* Get current framebuffer parameters
*
* @param[out] pParam - Pointer to a ::SceDisplayFrameBuf structure
* which will receive framebuffer parameters.
*
* @param[in] sync - One of ::SceDisplaySetBufSync
*
* @return 0 on success, < 0 on error.
*/
GetFrameBuf :: proc(pParam: ^SceDisplayFrameBuf, sync: SceDisplaySetBufSync) -> c.int ---
/**
* Primary display index
*/
GetPrimaryHead :: proc() -> c.int ---
/**
* Get current number of fps for the current screen mode.
*
* @param[out] pFps - Pointer to a float variable to store current number of fps.
*
* @return 0 on success, < 0 on error.
* @note - This function returns a theoretical value, this might not be the exact frame rate.
*/
GetRefreshRate :: proc(pFps: ^c.float) -> c.int ---
/**
* Get maximum framebuffer resolution
*
* @param[out] width - Maximum width
* @param[out] height - Maximum height
*
* @return 0 on success, < 0 on error.
*/
GetMaximumFrameBufResolution :: proc(width: ^c.int, height: ^c.int) -> c.int ---
/**
* Number of vertical blank pulses up to now
*/
GetVcount :: proc() -> c.int ---
/**
* Number of vertical blank pulses up to now for a display
*
* @param[in] display - Display index
*/
GetVcountInternal :: proc(display: c.int) -> c.int ---
/**
* Wait for vertical blank start
*/
WaitVblankStart :: proc() -> c.int ---
/**
* Wait for vertical blank start with callback
*/
WaitVblankStartCB :: proc() -> c.int ---
/**
* Wait for vertical blank start after specified number of vertical periods
*
* @param[in] vcount - Number of vertical periods before waiting for vertical blank start
*/
WaitVblankStartMulti :: proc(vcount: c.uint) -> c.int ---
/**
* Wait for vertical blank start with callback after specified number of vertical periods
*
* @param[in] vcount - Number of vertical periods before waiting for vertical blank start
*/
WaitVblankStartMultiCB :: proc(vcount: c.uint) -> c.int ---
/**
* Wait for vertical blank start since last update of framebuffer
*/
WaitSetFrameBuf :: proc() -> c.int ---
/**
* Wait for vertical blank start with callback since last update of framebuffer
*/
WaitSetFrameBufCB :: proc() -> c.int ---
/**
* Wait for vertical blank start after specified number of vertical periods
* since last update of framebuffer.
*
* @param[in] vcount - Number of vertical periods before waiting for vertical blank start
*/
WaitSetFrameBufMulti :: proc(vcount: c.uint) -> c.int ---
/**
* Wait for vertical blank start with callback after specified number of vertical periods
* since last update of framebuffer.
*
* @param[in] vcount - Number of vertical periods before waiting for vertical blank start
*/
WaitSetFrameBufMultiCB :: proc(vcount: c.uint) -> c.int ---
/**
* Register callback to be used at each vertical blank start
*
* @param[in] uid - Callback UID
*/
RegisterVblankStartCallback :: proc(uid: sce.UID) -> c.int ---
/**
* Unregister callback used at each vertical blank start
*
* @param[in] uid - Callback UID
*/
UnregisterVblankStartCallback :: proc(uid: sce.UID) -> c.int ---
}
+56
View File
@@ -0,0 +1,56 @@
package display
import "core:c"
import sce "../common"
// TODO: should be c.int
SceDisplayErrorCode :: enum c.uint {
OK = 0,
INVALID_HEAD = 0x80290000,
INVALID_VALUE = 0x80290001,
INVALID_ADDR = 0x80290002,
INVALID_PIXELFORMAT = 0x80290003,
INVALID_PITCH = 0x80290004,
INVALID_RESOLUTION = 0x80290005,
INVALID_UPDATETIMING = 0x80290006,
NO_FRAME_BUFFER = 0x80290007,
NO_PIXEL_DATA = 0x80290008,
NO_OUTPUT_SIGNAL = 0x80290009
}
#assert(size_of(SceDisplayErrorCode) == 4)
SceDisplayPixelFormat :: enum c.uint {
A8B8G8R8 = 0x00000000,
A2B10G10R10 = 0x60800000,
}
#assert(size_of(SceDisplayPixelFormat) == 4)
SceDisplaySetBufSync :: enum c.int {
/** Buffer change effective immediately */
SCE_DISPLAY_SETBUF_IMMEDIATE = 0,
/** Buffer change effective next frame */
SCE_DISPLAY_SETBUF_NEXTFRAME = 1,
__SCE_DISPLAY_SETBUF = -1 // 0xFFFFFFFF
}
#assert(size_of(SceDisplaySetBufSync) == 4)
/**
* Structure used with ::ksceDisplaySetFrameBuf to set/update framebuffer.
* Original screen resolution is 960x544, but the following resolutions
* can also be supplied as width and height :
* 480x272, 640x368, 720x408
*
* @note - This structure is returned by ::ksceDisplayGetFrameBuf
*/
SceDisplayFrameBuf :: struct {
size: sce.Size, //!< sizeof(SceDisplayFrameBuf)
base: rawptr, //!< Pointer to framebuffer
pitch: c.uint, //!< pitch pixels
pixelformat: c.uint, //!< pixel format (one of ::SceDisplayPixelFormat)
width: c.uint, //!< framebuffer width
height: c.uint, //!< framebuffer height
}
when size_of(rawptr) == 4 {
#assert(size_of(SceDisplayFrameBuf) == 0x18)
}