From e66c5afde00d6747bd051252e26474165aaa9ca3 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Sat, 11 May 2024 23:24:13 +0200 Subject: [PATCH] initial --- .gitmodules | 3 + AVConfig/AVConfig.odin | 77 ++ AppMgr/AppMgr.odin | 440 ++++++++ AppMgr/types.odin | 171 +++ AppUtil/AppUtil.odin | 89 ++ AppUtil/types.odin | 176 +++ Atrac/Atrac.odin | 34 + Atrac/types.odin | 123 ++ AudioIn/AudioIn.odin | 20 + AudioIn/types.odin | 42 + AudioOut/AudioOut.odin | 107 ++ AudioOut/types.odin | 66 ++ Audiodec/Audiodec.odin | 23 + Audiodec/types.odin | 189 ++++ Audioenc/Audioenc.odin | 18 + Audioenc/types.odin | 113 ++ AvPlayer/AvPlayer.odin | 122 ++ AvPlayer/types.odin | 149 +++ BgAppUtil/BgAppUtil.odin | 24 + Camera/Camera.odin | 407 +++++++ Camera/types.odin | 235 ++++ Clib/Clib.odin | 70 ++ CommonDialog/CommonDialog.odin | 84 ++ CommonDialog/types.odin | 353 ++++++ Compat/Compat.odin | 299 +++++ Ctrl/Ctrl.odin | 275 +++++ Ctrl/types.odin | 134 +++ Deci4p/Deci4p.odin | 17 + Display/Display.odin | 133 +++ Display/types.odin | 56 + Dmac/Dmac.odin | 114 ++ Dmac/types.odin | 35 + Fiber/Fiber.odin | 27 + Fiber/types.odin | 44 + Fios2/Fios2.odin | 37 + Fios2/types.odin | 88 ++ Gps/Gps.odin | 27 + Gxm/Gxm.odin | 306 +++++ Gxm/types.odin | 1429 ++++++++++++++++++++++++ Hid/Hid.odin | 54 + Hid/types.odin | 29 + Http/Http.odin | 84 ++ Http/types.odin | 270 +++++ Ime/Ime.odin | 36 + Ime/types.odin | 233 ++++ IncomingDialog/IncomingDialog.odin | 45 + IncomingDialog/types.odin | 42 + Io/Io.odin | 337 ++++++ Io/types.odin | 156 +++ Jpeg/Jpeg.odin | 258 +++++ Jpeg/types.odin | 146 +++ Kernel/Kernel.odin | 804 +++++++++++++ Kernel/Modulemgr.odin | 48 + Kernel/Processmgr.odin | 50 + Kernel/Sysmem.odin | 79 ++ Kernel/ThreadMgr.odin | 433 +++++++ Kernel/types.odin | 953 ++++++++++++++++ LICENSE | 21 + Location/Location.odin | 60 + Location/types.odin | 140 +++ MonoBridge/MonoBridge.odin | 25 + Motion/Motion.odin | 171 +++ Motion/types.odin | 79 ++ MotionDev/MotionDev.odin | 49 + Mtp/Mtp.odin | 26 + MusicExport/MusicExport.odin | 24 + Net/Net.odin | 92 ++ Net/types.odin | 735 ++++++++++++ NetCtl/NetCtl.odin | 30 + NetCtl/types.odin | 103 ++ NetSyscalls/NetSyscalls.odin | 55 + Ngs/Ngs.odin | 71 ++ Ngs/types.odin | 38 + NotificationUtil/NotificationUtil.odin | 43 + NotificationUtil/types.odin | 55 + NpDrm/NpDrm.odin | 100 ++ NpDrm/types.odin | 80 ++ Paf/Paf.odin | 103 ++ Paf/types.odin | 63 ++ Pamgr/Pamgr.odin | 43 + Perf/Perf.odin | 78 ++ Pgf/Pgf.odin | 33 + Pgf/types.odin | 179 +++ PhotoExport/PhotoExport.odin | 20 + Power/Power.odin | 239 ++++ Power/types.odin | 56 + PromoterUtil/PromoterUtil.odin | 98 ++ PromoterUtil/types.odin | 29 + PspnetAdhoc/PspnetAdhoc.odin | 43 + PspnetAdhoc/types.odin | 163 +++ Pvf/Pvf.odin | 45 + Pvf/types.odin | 305 +++++ README.md | 10 + RazorCapture/RazorCapture.odin | 22 + RazorHud/RazorHud.odin | 43 + RazorHud/types.odin | 132 +++ RegistryMgr/RegistryMgr.odin | 143 +++ Rtc/Rtc.odin | 301 +++++ SblACMgr/SblACMgr.odin | 10 + SblUpdateMgr/SblUpdateMgr.odin | 47 + ScreenShot/ScreenShot.odin | 19 + ScreenShot/types.odin | 44 + ShaccCg/ShaccCg.odin | 23 + ShaccCg/types.odin | 126 +++ ShellSvc/ShellSvc.odin | 50 + ShellSvc/types.odin | 29 + ShutterSound/ShutterSound.odin | 31 + Sqlite/Sqlite.odin | 23 + Ssl/Ssl.odin | 39 + Sysmodule/Sysmodule.odin | 87 ++ Sysmodule/types.odin | 152 +++ Touch/Touch.odin | 69 ++ Touch/types.odin | 79 ++ TriggerUtil/TriggerUtil.odin | 145 +++ TriggerUtil/types.odin | 65 ++ Udcd/Udcd.odin | 65 ++ Udcd/types.odin | 48 + UsbAudioIn/UsbAudioIn.odin | 101 ++ UsbAudioIn/types.odin | 36 + UsbSerial/UsbSerial.odin | 78 ++ UsbServ/UsbServ.odin | 32 + UsbStor/UsbStor.odin | 48 + Usbd/Usbd.odin | 279 +++++ Usbd/types.odin | 243 ++++ VideoExport/VideoExport.odin | 44 + Videodec/Videodec.odin | 57 + Videodec/types.odin | 167 +++ VshBridge/VshBridge.odin | 190 ++++ common/types.odin | 254 +++++ vita-headers | 1 + 130 files changed, 17039 insertions(+) create mode 100644 .gitmodules create mode 100644 AVConfig/AVConfig.odin create mode 100644 AppMgr/AppMgr.odin create mode 100644 AppMgr/types.odin create mode 100644 AppUtil/AppUtil.odin create mode 100644 AppUtil/types.odin create mode 100644 Atrac/Atrac.odin create mode 100644 Atrac/types.odin create mode 100644 AudioIn/AudioIn.odin create mode 100644 AudioIn/types.odin create mode 100644 AudioOut/AudioOut.odin create mode 100644 AudioOut/types.odin create mode 100644 Audiodec/Audiodec.odin create mode 100644 Audiodec/types.odin create mode 100644 Audioenc/Audioenc.odin create mode 100644 Audioenc/types.odin create mode 100644 AvPlayer/AvPlayer.odin create mode 100644 AvPlayer/types.odin create mode 100644 BgAppUtil/BgAppUtil.odin create mode 100644 Camera/Camera.odin create mode 100644 Camera/types.odin create mode 100644 Clib/Clib.odin create mode 100644 CommonDialog/CommonDialog.odin create mode 100644 CommonDialog/types.odin create mode 100644 Compat/Compat.odin create mode 100644 Ctrl/Ctrl.odin create mode 100644 Ctrl/types.odin create mode 100644 Deci4p/Deci4p.odin create mode 100644 Display/Display.odin create mode 100644 Display/types.odin create mode 100644 Dmac/Dmac.odin create mode 100644 Dmac/types.odin create mode 100644 Fiber/Fiber.odin create mode 100644 Fiber/types.odin create mode 100644 Fios2/Fios2.odin create mode 100644 Fios2/types.odin create mode 100644 Gps/Gps.odin create mode 100644 Gxm/Gxm.odin create mode 100644 Gxm/types.odin create mode 100644 Hid/Hid.odin create mode 100644 Hid/types.odin create mode 100644 Http/Http.odin create mode 100644 Http/types.odin create mode 100644 Ime/Ime.odin create mode 100644 Ime/types.odin create mode 100644 IncomingDialog/IncomingDialog.odin create mode 100644 IncomingDialog/types.odin create mode 100644 Io/Io.odin create mode 100644 Io/types.odin create mode 100644 Jpeg/Jpeg.odin create mode 100644 Jpeg/types.odin create mode 100644 Kernel/Kernel.odin create mode 100644 Kernel/Modulemgr.odin create mode 100644 Kernel/Processmgr.odin create mode 100644 Kernel/Sysmem.odin create mode 100644 Kernel/ThreadMgr.odin create mode 100644 Kernel/types.odin create mode 100644 LICENSE create mode 100644 Location/Location.odin create mode 100644 Location/types.odin create mode 100644 MonoBridge/MonoBridge.odin create mode 100644 Motion/Motion.odin create mode 100644 Motion/types.odin create mode 100644 MotionDev/MotionDev.odin create mode 100644 Mtp/Mtp.odin create mode 100644 MusicExport/MusicExport.odin create mode 100644 Net/Net.odin create mode 100644 Net/types.odin create mode 100644 NetCtl/NetCtl.odin create mode 100644 NetCtl/types.odin create mode 100644 NetSyscalls/NetSyscalls.odin create mode 100644 Ngs/Ngs.odin create mode 100644 Ngs/types.odin create mode 100644 NotificationUtil/NotificationUtil.odin create mode 100644 NotificationUtil/types.odin create mode 100644 NpDrm/NpDrm.odin create mode 100644 NpDrm/types.odin create mode 100644 Paf/Paf.odin create mode 100644 Paf/types.odin create mode 100644 Pamgr/Pamgr.odin create mode 100644 Perf/Perf.odin create mode 100644 Pgf/Pgf.odin create mode 100644 Pgf/types.odin create mode 100644 PhotoExport/PhotoExport.odin create mode 100644 Power/Power.odin create mode 100644 Power/types.odin create mode 100644 PromoterUtil/PromoterUtil.odin create mode 100644 PromoterUtil/types.odin create mode 100644 PspnetAdhoc/PspnetAdhoc.odin create mode 100644 PspnetAdhoc/types.odin create mode 100644 Pvf/Pvf.odin create mode 100644 Pvf/types.odin create mode 100644 README.md create mode 100644 RazorCapture/RazorCapture.odin create mode 100644 RazorHud/RazorHud.odin create mode 100644 RazorHud/types.odin create mode 100644 RegistryMgr/RegistryMgr.odin create mode 100644 Rtc/Rtc.odin create mode 100644 SblACMgr/SblACMgr.odin create mode 100644 SblUpdateMgr/SblUpdateMgr.odin create mode 100644 ScreenShot/ScreenShot.odin create mode 100644 ScreenShot/types.odin create mode 100644 ShaccCg/ShaccCg.odin create mode 100644 ShaccCg/types.odin create mode 100644 ShellSvc/ShellSvc.odin create mode 100644 ShellSvc/types.odin create mode 100644 ShutterSound/ShutterSound.odin create mode 100644 Sqlite/Sqlite.odin create mode 100644 Ssl/Ssl.odin create mode 100644 Sysmodule/Sysmodule.odin create mode 100644 Sysmodule/types.odin create mode 100644 Touch/Touch.odin create mode 100644 Touch/types.odin create mode 100644 TriggerUtil/TriggerUtil.odin create mode 100644 TriggerUtil/types.odin create mode 100644 Udcd/Udcd.odin create mode 100644 Udcd/types.odin create mode 100644 UsbAudioIn/UsbAudioIn.odin create mode 100644 UsbAudioIn/types.odin create mode 100644 UsbSerial/UsbSerial.odin create mode 100644 UsbServ/UsbServ.odin create mode 100644 UsbStor/UsbStor.odin create mode 100644 Usbd/Usbd.odin create mode 100644 Usbd/types.odin create mode 100644 VideoExport/VideoExport.odin create mode 100644 Videodec/Videodec.odin create mode 100644 Videodec/types.odin create mode 100644 VshBridge/VshBridge.odin create mode 100644 common/types.odin create mode 160000 vita-headers diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0acef7f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vita-headers"] + path = vita-headers + url = https://github.com/vitasdk/vita-headers.git diff --git a/AVConfig/AVConfig.odin b/AVConfig/AVConfig.odin new file mode 100644 index 0000000..108b635 --- /dev/null +++ b/AVConfig/AVConfig.odin @@ -0,0 +1,77 @@ +package avconfig + +import "core:c" + +foreign import avconfig "system:SceAVConfig_stub" + +/** Color Space Mode values to specify to ::sceAVConfigSetDisplayColorSpaceMode */ +SceAVConfigColorSpaceMode :: enum c.int { + DEFAULT = 0, //!< Default + HIGH_CONTRAST = 1 //!< High Contrast Mode +} + +@(link_prefix = "sceAVConfig") +foreign avconfig { + /** + * Get the maximum brightness. + * + * @param[out] maxBrightness - Maximum brightness. + * + * @return 0 on success, < 0 on error. + */ + GetDisplayMaxBrightness :: proc(maxBrightness: ^c.int) -> c.int --- + + /** + * Set the screen brightness. + * + * @param brightness - Brightness that the screen will be set to (range 21-65536, 0 turns off the screen). + * + * @return 0 on success, < 0 on error. + */ + SetDisplayBrightness :: proc(brightness: c.int) -> c.int --- + + /** + * Get the shutter volume. + * + * @param[out] volume - shutter volume. + * + * @return 0 on success, < 0 on error. + */ + GetShutterVol :: proc(volume: ^c.int) -> c.int --- + + /** + * Get the system volume. + * + * @param[out] volume - System volume. + * + * @return 0 on success, < 0 on error. + */ + GetSystemVol :: proc(volume: ^c.int) -> c.int --- + + /** + * Set the system volume. + * + * @param volume - volume that the device will be set to (range 0-30). + * + * @return 0 on success, < 0 on error. + */ + SetSystemVol :: proc(volume: c.int) -> c.int --- + + /** + * Turns on mute. + * + * @return 0 on success, < 0 on error. + * + */ + MuteOn :: proc() -> c.int --- + + /** + * Sets the color space mode on runtime. + * + * @param[in] csm - see ::SceAVConfigColorSpaceMode() + * + * @return 0 on success, < 0 on error. + * @note - This does not change color_space_mode in the registry. + */ + SetDisplayColorSpaceMode :: proc(csm: c.int) -> c.int --- +} diff --git a/AppMgr/AppMgr.odin b/AppMgr/AppMgr.odin new file mode 100644 index 0000000..faf6cd2 --- /dev/null +++ b/AppMgr/AppMgr.odin @@ -0,0 +1,440 @@ +package appmgr + +import "core:c" +import sce "../common" + +foreign import appmgr "system:SceAppMgr_stub" + +foreign appmgr { + /** + * Save data on savedata0: partition + * + * @param[in] data - Data to save + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataDataSave :: proc(data: ^SceAppMgrSaveDataData) -> c.int --- + + /** + * Remove data on savedata0: partition + * + * @param[in] data - Data to remove + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataDataRemove :: proc(data: ^SceAppMgrSaveDataDataDelete) -> c.int --- + + /** + * Create a savedata slot + * + * @param[in] data - Slot data + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataSlotCreate :: proc(data: ^SceAppMgrSaveDataSlot) -> c.int --- + + /** + * Get current param of a savedata slot + * + * @param[out] data - Slot data + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataSlotGetParam :: proc(data: ^SceAppMgrSaveDataSlot) -> c.int --- + + /** + * Set current param of a savedata slot + * + * @param[in] data - Slot data + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataSlotSetParam :: proc(data: ^SceAppMgrSaveDataSlot) -> c.int --- + + /** + * Delete a savedata slot + * + * @param[in] data - Slot data + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrSaveDataSlotDelete :: proc(data: ^SceAppMgrSaveDataSlotDelete) -> c.int --- + + /** + * Get Process ID by Title ID + * + * @param[out] pid - Process ID + * @param[in] name - Title ID + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrGetIdByName :: proc(pid: ^sce.UID, name: cstring) -> c.int --- + + /** + * Get Title ID by Process ID + * + * @param[in] pid - Process ID + * @param[out] name - Title ID + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrGetNameById :: proc(pid: sce.UID, name: cstring) -> c.int --- + + /** + * Destroy other apps + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrDestroyOtherApp :: proc() -> c.int --- + + /** + * Destroy an application by Title ID + * + * @param[in] name - Title ID of the application + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrDestroyAppByName :: proc(name: cstring) -> c.int --- + + /** + * Destroy an application by Application ID + * + * @param[in] appId - Application ID of the application + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrDestroyAppByAppId :: proc(appId: sce.Int32) -> c.int --- + + /** + * Get PID of an application for Shell + * + * @param[in] appId - Application ID of the application + * + * @return The PID on success, < 0 on error. + */ + sceAppMgrGetProcessIdByAppIdForShell :: proc(appId: sce.Int32) -> sce.UID --- + + /** + * Get a list of running applications + * + * @param[out] appIds - Array of running application IDs + * @param[in] count - Max number of running applications to search + * + * @return Number of running applications. + */ + sceAppMgrGetRunningAppIdListForShell :: proc(appIds: ^sce.Int32, count: c.int) -> c.int --- + + /** + * Get an application state + * + * @param[out] appState - State of the application + * @param[in] len - sizeof(SceAppMgrState) + * @param[in] version - Version (?) + + * @return 0 on success, < 0 on error. + */ + _sceAppMgrGetAppState :: proc(appState: ^SceAppMgrAppState, len: sce.Size, version: c.uint32_t) -> c.int --- + + /** + * Receive system event + * + * @param[out] systemEvent - Received system event + + * @return 0 on success, < 0 on error. + */ + sceAppMgrReceiveSystemEvent :: proc(systemEvent: ^SceAppMgrSystemEvent) -> c.int --- + + /** + * Copies app param to an array + * + * @param[out] param - pointer to a 1024 byte location to store the app param + * + * @return 0 on success, < 0 on error. + * + * @note App param example: type=LAUNCH_APP_BY_URI&uri=psgm:play?titleid=NPXS10031 + */ + sceAppMgrGetAppParam :: proc(param: [^]c.char) -> c.int --- + + /** + * Obtains the BGM port, even when it is not in front + * + * @return 0 on success, < 0 on error. + * + */ + sceAppMgrAcquireBgmPort :: proc() -> c.int --- + + /** + * Release acquired BGM port + * + * @return 0 on success, < 0 on error. + * + */ + sceAppMgrReleaseBgmPort :: proc() -> c.int --- + + /** + * Set infobar state + * + * @param[in] visibility - Infobar visibility + * @param[in] color - Infobar color + * @param[in] transparency - Infobar transparency + * + * @return 0 on success, < 0 on error. + * + */ + sceAppMgrSetInfobarState :: proc(visibility: SceAppMgrInfoBarVisibility, color: SceAppMgrInfoBarColor, transparency: SceAppMgrInfoBarTransparency) -> c.int --- + + /** + * Load and start a SELF executable + * + * @param[in] appPath - Path of the SELF file + * @param[in] argv - Args to pass to SELF module_start + * @param[in] optParam - Optional params + * + * @return 0 on success, < 0 on error. + * + * @note SELF file must be located in app0: partition. + */ + // TODO: no idea how argv is supposed to be changed to odin types. C type is `char *argv[]` + sceAppMgrLoadExec :: proc(appPath: cstring, argv: [][^]c.char, optParam: ^SceAppMgrExecOptParam) -> c.int --- + + /** + * Start an application by URI + * + * @param[in] flags - Must be 0x20000 + * @param[in] uri - Uri to launch + * + * @return 0 on success, < 0 on error. + * + * @note If flags != 0x20000, Livearea is opened. + */ + sceAppMgrLaunchAppByUri :: proc(flags: c.int, uri: cstring) -> c.int --- + + /** + * Start an application by Title ID + * + * @param[in] name - Title ID of the application + * @param[in] param - The params passed to the application which can be retrieved with ::sceAppMgrGetAppParam + * @param[in] optParam - Optional params + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrLaunchAppByName2 :: proc(name: cstring, param: cstring, optParam: ^SceAppMgrLaunchAppOptParam) -> c.int --- + + /** + * Start an Application by Title ID + * + * @param[in] flags - Usually 0x60000 + * @param[in] name - Title ID of the application + * @param[in] param - The params passed to the application which can be retrieved with ::sceAppMgrGetAppParam + * + * @return 0 on success < 0 on error. + */ + sceAppMgrLaunchAppByName :: proc(flags: c.int, name: cstring, param: cstring) -> c.int --- + + /** + * Start an application by Title ID for Shell + * + * @param[in] name - Title ID of the application + * @param[in] param - The params passed to the application which can be retrieved with ::sceAppMgrGetAppParam + * @param[in] optParam - Optional params + * + * @return Application ID (?) + */ + sceAppMgrLaunchAppByName2ForShell :: proc(name: cstring, param: cstring, optParam: ^SceAppMgrLaunchAppOptParam) -> sce.UID --- + + /** + * Mount game data + * + * @param[in] app_path - example : "ux0:/app/${TITLEID}" + * @param[in] patch_path - example : "ux0:/patch/${TITLEID}", "invalid:" + * @param[in] rif_path - If NULL the system will automatically search the rif path. example : "ux0:/license/app/${TITLEID}/${HEX}.rif" + * @param[in] mount_point - Mountpoint output + * + * @return 0 on success, < 0 on error. + * + */ + sceAppMgrGameDataMount :: proc(app_path: cstring, patch_path: cstring, rif_path: cstring, mount_point: cstring) -> c.int --- + + /** + * Mount application data + * + * @param[in] id - App data ID + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note id: 100 (photo0), 101 (friends), 102 (messages), 103 (near), 105 (music), 108 (calendar) + */ + sceAppMgrAppDataMount :: proc(id: c.int, mount_point: cstring) -> c.int --- + + /** + * Mount application data by Title ID + * + * @param[in] id - App data ID + * @param[in] titleid - Application title ID + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note id: 106 (ad), 107 (ad) + */ + sceAppMgrAppDataMountById :: proc(id: c.int, titleid: cstring, mount_point: cstring) -> c.int --- + + /** + * Get application params from SFO descriptor + * + * @param[in] pid - Process ID + * @param[in] param - Param ID in the SFO descriptor + * @param[out] string - Param data + * @param[in] length - Length of the param data + * + * @return 0 on success, < 0 on error. + * + * @note param: 6 (contentid) 8 (category), 9 (stitle/title?), 10 (title/stitle?), 12 (titleid) + */ + sceAppMgrAppParamGetString :: proc(pid: c.int, param: c.int, string: cstring, length: sce.Size) -> c.int --- + + /** + * Get device info + * + * @param[in] dev - Device to get info about + * @param[out] max_size - Capacity of the device + * @param[out] free_size - Free space of the device + * + * @return 0 on success, < 0 on error. + * + * @note dev: ux0: + */ + sceAppMgrGetDevInfo :: proc(dev: cstring, max_size: ^c.uint64_t, free_size: ^c.uint64_t) -> c.int --- + + /** + * Mount application data (PSPEmu) + * + * @param[in] id - App data ID + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note id: 400 (ad), 401 (ad), 402 (ad) + */ + sceAppMgrMmsMount :: proc(id: c.int, mount_point: cstring) -> c.int --- + + /** + * Mount PSPEmu virtual memory stick + * + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note mount_point: ms + */ + sceAppMgrPspSaveDataRootMount :: proc(mount_point: cstring) -> c.int --- + + /** + * Mount working directory + * + * @param[in] id - Working directory ID + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note id: 200 (td), 201 (td), 203 (td), 204 (td), 206 (td) + */ + sceAppMgrWorkDirMount :: proc(id: c.int, mount_point: cstring) -> c.int --- + + /** + * Mount working directory by Title ID + * + * @param[in] id - Working directory ID + * @param[in] titleid - Application Title ID + * @param[in] mount_point - Mountpoint to use + * + * @return 0 on success, < 0 on error. + * + * @note id: 205 (cache0), 207 (td) + */ + sceAppMgrWorkDirMountById :: proc(id: c.int, titleid: cstring, mount_point: cstring) -> c.int --- + + /** + * Unmount a mountpoint + * + * @param[in] mount_point - Mountpoint to unmount + * + * @return 0 on success, < 0 on error. + * + * @note Unmount app0: for example to enable write access to ux0:app/TITLEID + */ + sceAppMgrUmount :: proc(mount_point: cstring) -> c.int --- + + /** + * Convert vs0 path string to a new one usable by applications + * + * @param[in] path - Path to convert + * @param[in] mount_point - Mountpoint to use + * @param[in] unk - Unknown + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrConvertVs0UserDrivePath :: proc(path: cstring, mount_point: cstring, unk: c.int) -> c.int --- + + /** + * Get raw path for a given path + * + * @param[out] path - Path to convert + * @param[in] resolved_path - The input process path + * @param[in] resolved_path_size - The input process path length + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrGetRawPath :: proc(path: cstring, resolved_path: cstring, resolved_path_size: c.int) -> c.int --- + + /** + * Get the real/resolved path of app0: (where it's actually mounted) + * + * @param[in] appId - Use -2 for the current application + * @param[out] resolved_path - Buffer that will hold the resolved path. It should have enough room to hold 292 characters or it will buffer overflow (noname120). + * + * @return 0 on success. + */ + sceAppMgrGetRawPathOfApp0ByAppIdForShell :: proc(appId: c.int, resolved_path: [292]c.char) -> c.int --- + + /** + * Get memory budget info for a running system application + * + * @param[out] info - Info related to the memory budget of the running application. + * + * @return 0 on success, < 0 on error. + * + * @note This function will always return an error if used in a normal application. + */ + sceAppMgrGetBudgetInfo :: proc(info: ^SceAppMgrBudgetInfo) -> c.int --- + + + /** + * Get current coredump state for shell + * + * @param[out] state - state info output. + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrGetCoredumpStateForShell :: proc(state: ^SceAppMgrCoredumpState) -> c.int --- + + sceAppMgrDrmOpen :: proc(param: ^SceAppMgrDrmOpenParam) -> sce.Int32 --- + + /** + * Get AppInfo via syscall directly + * + * @param[in] unk - unknown maybe titleid + * @param[out] state - The app state output buffer pointer + * @param[in] syscall_validity - The syscall validity buffer + * + * @return 0 on success, < 0 on error. + */ + sceAppMgrGetAppInfo :: proc(unk: cstring, state: ^SceAppMgrAppState) -> sce.Int32 --- + + _sceSharedFbOpen :: proc(index: c.int, sysver: c.int) -> sce.UID --- + sceSharedFbClose :: proc(fb_id: sce.UID) -> c.int --- + sceSharedFbBegin :: proc(fb_id: sce.UID, info: ^SceSharedFbInfo) -> c.int --- + sceSharedFbEnd :: proc(fb_id: sce.UID) -> c.int --- + sceSharedFbGetInfo :: proc(fb_id: sce.UID, info: ^SceSharedFbInfo) -> c.int --- +} diff --git a/AppMgr/types.odin b/AppMgr/types.odin new file mode 100644 index 0000000..0432eb8 --- /dev/null +++ b/AppMgr/types.odin @@ -0,0 +1,171 @@ +package appmgr + +import "core:c" +import sce "../common" +import apputil "../AppUtil" + +SCE_APPMGR_MAX_APP_NAME_LENGTH:: (31) + +// TODO: should be c.int +SceAppMgrErrorCode :: enum i64 { + BUSY = 0x80802000, //!< Busy + STATE = 0x80802013, //!< Invalid state + NULL_POINTER = 0x80802016, //!< NULL pointer + INVALID = 0x8080201A, //!< Invalid param + TOO_LONG_ARGV = 0x8080201D, //!< argv is too long + INVALID_SELF_PATH = 0x8080201E, //!< Invalid SELF path + NOEXEC = 0x8080201F, //!< The process is not authorized to run this function + BGM_PORT_BUSY = 0x80803000, //!< BGM port was occupied and could not be secured +} + +SceAppMgrSystemEventType :: enum c.int { + ON_RESUME = 0x10000003, + ON_STORE_PURCHASE = 0x10000004, + ON_NP_MESSAGE_ARRIVED = 0x10000005, + ON_STORE_REDEMPTION = 0x10000006 +} + +SceAppMgrInfoBarVisibility :: enum c.int { + INVISIBLE = 0, + VISIBLE = 1 +} + +SceAppMgrInfoBarColor :: enum c.int { + BLACK = 0, + WHITE = 1 +} + +SceAppMgrInfoBarTransparency :: enum c.int { + OPAQUE = 0, + TRANSLUCENT = 1 +} + +SceAppMgrApplicationMode :: enum c.int { + A = 2, //!< Application without physically contiguous memory access + B = 3, //!< Application with physically contiguous memory access + C = 4 //!< Application with physically contiguous memory and extra memory access +} + +SceAppMgrSystemEvent :: struct { + systemEvent: c.int, //!< One of ::SceAppMgrSystemEventType + reserved: [60]c.uint8_t, //!< Reserved data +} +#assert(size_of(SceAppMgrSystemEvent) == 0x40) + +SceAppMgrSaveDataData :: struct { + size: c.int, //!< Must be 0x4C + slotId: c.uint, //!< Save slot to use + slotParam: ^apputil.SceAppUtilSaveDataSlotParam, //!< Save slot params + reserved: [32]c.uint8_t, //!< Reserved data + files: ^apputil.SceAppUtilSaveDataFile, //!< Pointer to an array of files + fileNum: c.int, //!< Number of files to save + mountPoint: apputil.SceAppUtilSaveDataMountPoint, //!< Savedata mountpoint + requiredSizeKB: ^c.int, //!< Required size in KBs + unk_0x48: int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppMgrSaveDataData) == 0x4C) +} + +SceAppMgrSaveDataDataDelete :: struct { + size: c.int, //!< Must be 0x44 + slotId: c.uint, //!< Save slot to use + slotParam: ^apputil.SceAppUtilSaveDataSlotParam, //!< Save slot params + reserved: [32]c.uint8_t, //!< Reserved data + files: ^apputil.SceAppUtilSaveDataFile, //!< Pointer to an array of files + fileNum: c.int, //!< Number of files to delete + mountPoint: apputil.SceAppUtilSaveDataMountPoint, //!< Savedata mountpoint +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppMgrSaveDataDataDelete) == 0x44) +} + +SceAppMgrSaveDataSlot :: struct { + size: c.int, //!< Must be 0x418 + slotId: c.uint, //!< Save slot to use + slotParam: apputil.SceAppUtilSaveDataSlotParam, //!< Save slot params + reserved: [116]c.uint8_t, //!< Reserved data + mountPoint: apputil.SceAppUtilSaveDataMountPoint, //!< Savedata mountpoint + reserved2: [0x40]c.uint8_t, +} +#assert(size_of(SceAppMgrSaveDataSlot) == 0x418) + +SceAppMgrSaveDataSlotDelete :: struct { + size: c.int, //!< Must be 0x18 + slotId: c.uint, //!< Save slot to use + mountPoint: apputil.SceAppUtilSaveDataMountPoint, //!< Savedata mountpoint +} +#assert(size_of(SceAppMgrSaveDataSlotDelete) == 0x18) + +SceAppMgrAppState :: struct { + systemEventNum: sce.UInt32, + appEventNum: sce.UInt32, + isSystemUiOverlaid: sce.Bool, + reserved: [116]sce.UInt8, +} +#assert(size_of(SceAppMgrAppState) == 0x80) + +SceAppMgrBudgetInfo :: struct { + size: c.int, //!< Must be 0x88 + app_mode: c.int, //!< One of ::SceAppMgrApplicationMode + unk0: c.int, //!< Unknown Data + total_user_rw_mem: c.uint, //!< Total amount of accessible USER_RW memory + free_user_rw: c.uint, //!< Free amount of accessible USER_RW memory + extra_mem_allowed: sce.Bool, //!< Flag for extra memory accessibility + unk1: c.int, //!< Unknown Data + total_extra_mem: c.uint, //!< Total amount of accessible extra memory + free_extra_mem: c.uint, //!< Free amount of accessible extra memory + unk2: [2]c.int, //!< Unknown Data + total_phycont_mem: c.uint, //!< Total amount of accessible physically contiguous memory + free_phycont_mem: c.uint, //!< Free amount of accessible physically contiguous memory + unk3: [10]c.int, //!< Unknown Data + total_cdram_mem: c.uint, //!< Total amount of accessible CDRAM memory + free_cdram_mem: c.uint, //!< Free amount of accessible CDRAM memory + reserved: [9]c.int, //!< Reserved data +} +#assert(size_of(SceAppMgrBudgetInfo) == 0x88) + +SceAppMgrExecOptParam :: struct{} // Missing struct +SceAppMgrLaunchAppOptParam :: struct{} // Missing struct + +SceAppMgrLoadExecOptParam :: struct { + reserved: [64]c.int, //!< Reserved data +} +#assert(size_of(SceAppMgrLoadExecOptParam) == 0x100) + +SceAppMgrCoredumpState :: struct { + pid: sce.UID, + process_state: c.int, + progress: c.int, // 0-100 + is_coredump_completed: c.int, + data_0x10: c.int, + path_len: sce.Size, + path: [0x400]c.char, + data_0x418: c.int, + data_0x41C: c.int, + data_0x420: c.int, + data_0x424: c.int, +} +#assert(size_of(SceAppMgrCoredumpState) == 0x428) + + +// missing structs +SceAppMgrDrmOpenParam :: struct{} +SceAppMgrAppInfo :: struct{} + +SceSharedFbInfo :: struct { + fb_base: rawptr, + fb_size: c.int, + fb_base2: rawptr, + unk0: [6]c.int, + stride: c.int, + width: c.int, + height: c.int, + unk1: c.int, + index: c.int, + unk2: [4]c.int, + vsync: c.int, + unk3: [3]c.int, +} + + diff --git a/AppUtil/AppUtil.odin b/AppUtil/AppUtil.odin new file mode 100644 index 0000000..6844e50 --- /dev/null +++ b/AppUtil/AppUtil.odin @@ -0,0 +1,89 @@ +package apputil + +import "core:c" +import sce "../common" + +foreign import apputil "system:SceAppUtil_stub" + +@(link_prefix = "sceAppUtil") +foreign apputil { + /** + * Initializes the AppUtil library. Call this before any of the other functions. + * + * @param[out] initParam - App init info. Must be initialized with zeros. + * @param[out] bootParam - App boot info. Must be initialized with zeros. + * + * @return 0 on success, < 0 on error. + */ + Init :: proc(initParam: ^SceAppUtilInitParam, bootParam: ^SceAppUtilBootParam) -> c.int --- + + //! Shutdown AppUtil library + Shutdown :: proc() -> c.int --- + + //! Receive app event + ReceiveAppEvent :: proc(eventParam: ^SceAppUtilAppEventParam) -> c.int --- + + //! Parse received app event from LiveArea + AppEventParseLiveArea :: proc(eventParam: ^SceAppUtilAppEventParam, buffer: [^]c.char) -> c.int --- + + //! Create savedata slot + SaveDataSlotCreate :: proc(slotId: c.uint, param: ^SceAppUtilSaveDataSlotParam, mountPoint: ^SceAppUtilSaveDataMountPoint) -> c.int --- + + //! Delete savedata slot + SaveDataSlotDelete :: proc(slotId: c.uint, mountPoint: ^SceAppUtilSaveDataMountPoint) -> c.int --- + + //! Set savedata slot param + SaveDataSlotSetParam :: proc(slotId: c.uint, param: ^SceAppUtilSaveDataSlotParam, mountPoint: ^SceAppUtilSaveDataMountPoint) -> c.int --- + + //! Get savedata slot param + SaveDataSlotGetParam :: proc(slotId: c.uint, param: ^SceAppUtilSaveDataSlotParam, mountPoint: ^SceAppUtilSaveDataMountPoint) -> c.int --- + + //!< Write savedata files and directories + SaveDataDataSave :: proc(slot: ^SceAppUtilSaveDataFileSlot, files: ^SceAppUtilSaveDataFile, fileNum: c.uint, mountPoint: ^SceAppUtilSaveDataMountPoint, requiredSizeKB: ^sce.Size) -> c.int --- + + //!< Delete savedata files + SaveDataDataRemove :: proc(slot: ^SceAppUtilSaveDataFileSlot, files: ^SceAppUtilSaveDataRemoveItem, fileNum: c.uint, mountPoint: ^SceAppUtilSaveDataMountPoint) -> c.int --- + + //! Mount music data + MusicMount :: proc() -> c.int --- + + //! Unmount music data + MusicUmount :: proc() -> c.int --- + + //! Mount photo data + PhotoMount :: proc() -> c.int --- + + //! Unmount photo data + PhotoUmount :: proc() -> c.int --- + + //! Mount cache data + CacheMount :: proc() -> c.int --- + + //! Unmount cache data + CacheUmount :: proc() -> c.int --- + + //! Get system parameters for int type + SystemParamGetInt :: proc(paramId: c.uint, value: ^c.int) -> c.int --- + + //! Get application parameters for string type + SystemParamGetString :: proc(paramId: c.uint, buf: [^]sce.Char8, bufSize: sce.Size) -> c.int --- + + //! Get application parameters for int type + AppParamGetInt :: proc(paramId: SceAppUtilAppParamId, value: ^c.int) -> c.int --- + + //! Save safe memory + SaveSafeMemory :: proc(buf: rawptr, bufSize: sce.Size, offset: sce.Off) -> c.int --- + + //! Load safe memory + LoadSafeMemory :: proc(buf: rawptr, bufSize: sce.Size, offset: sce.Off) -> c.int --- + + //! Launch PSN Store + StoreBrowse :: proc(param: ^SceAppUtilStoreBrowseParam) -> c.int --- + + //! Get background download status + BgdlGetStatus :: proc(stat: ^SceAppUtilBgdlStatus) -> c.int --- + + //! Launch web browser app + LaunchWebBrowser :: proc(param: ^SceAppUtilWebBrowserParam) -> c.int --- +} + diff --git a/AppUtil/types.odin b/AppUtil/types.odin new file mode 100644 index 0000000..1890412 --- /dev/null +++ b/AppUtil/types.odin @@ -0,0 +1,176 @@ +package apputil + +import "core:c" +import sce "../common" + +SceAppUtilSaveDataRemoveMode :: enum c.int { + DEFAULT = 0, + NO_SLOT = 1, +} + +SceAppUtilSaveDataSaveMode :: enum c.int { + FILE = 0, + DIRECTORY = 2, +} + +// TODO: should be c.int +SceAppUtilErrorCode :: enum i64 { + PARAMETER = 0x80100600, + NOT_INITIALIZED = 0x80100601, + NO_MEMORY = 0x80100602, + BUSY = 0x80100603, + NOT_MOUNTED = 0x80100604, + NO_PERMISSION = 0x80100605, + PASSCODE_MISMATCH = 0x80100606, + APPEVENT_PARSE_INVALID_DATA = 0x80100620, + SAVEDATA_SLOT_EXISTS = 0x80100640, + SAVEDATA_SLOT_NOT_FOUND = 0x80100641, + SAVEDATA_NO_SPACE_QUOTA = 0x80100642, + SAVEDATA_NO_SPACE_FS = 0x80100643, + DRM_NO_ENTITLEMENT = 0x80100660, + PHOTO_DEVICE_NOT_FOUND = 0x80100680, + MUSIC_DEVICE_NOT_FOUND = 0x80100685, + MOUNT_LIMIT_OVER = 0x80100686, + STACKSIZE_TOO_SHORT = 0x801006A0, +} + +SceAppUtilBootAttribute :: distinct c.uint +SceAppUtilAppEventType :: distinct c.uint +SceAppUtilSaveDataSlotId :: distinct c.uint +SceAppUtilSaveDataSlotStatus :: distinct c.uint +SceAppUtilAppParamId :: distinct c.uint +SceAppUtilBgdlStatusType :: distinct c.uint + +SceAppUtilBgdlStatus :: struct { + type: SceAppUtilBgdlStatusType, + addcontNumReady: sce.UInt32, + addcontNumNotReady: sce.UInt32, + licenseReady: sce.UInt32, + reserved: [28]sce.Char8, +} +#assert(size_of(SceAppUtilBgdlStatus) == 0x2C) + +SceAppUtilInitParam :: struct { + workBufSize: sce.Size, //!< Buffer size + reserved: [60]c.uint8_t, //!< Reserved range +} +#assert(size_of(SceAppUtilInitParam) == 0x40) + +SceAppUtilBootParam :: struct { + attr: SceAppUtilBootAttribute, //!< Boot attribute + appVersion: c.uint, //!< App version + reserved: [32]c.uint8_t, //!< Reserved range +} +#assert(size_of(SceAppUtilBootParam) == 0x28) + +SceAppUtilSaveDataMountPoint :: struct { + data: [16]c.uint8_t, +} +#assert(size_of(SceAppUtilSaveDataMountPoint) == 0x10) + +SceAppUtilAppEventParam :: struct { + type: SceAppUtilAppEventType, //!< Event type + dat: [1024]c.uint8_t, //!< Event parameter +} +#assert(size_of(SceAppUtilAppEventParam) == 0x404) + +SceAppUtilMountPoint :: struct { + data: [16]c.int8_t, //!< Mount point +} +#assert(size_of(SceAppUtilMountPoint) == 0x10) + +SceAppUtilSaveDataSlotEmptyParam :: struct { + title: [^]sce.WChar16, //!< Title string + iconPath: cstring, //!< Path to icon + iconBuf: rawptr, //!< Icon buffer + iconBufSize: sce.Size, //!< Icon buffer size + reserved: [32]c.uint8_t, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataSlotEmptyParam) == 0x30) +} + +SceAppUtilSaveDataSlot :: struct { + id: SceAppUtilSaveDataSlotId, //!< Slot id + status: SceAppUtilSaveDataSlotStatus, //!< Slot status + userParam: c.int, //!< Param for free usage + emptyParam: ^SceAppUtilSaveDataSlotEmptyParam, //!< Settings for empty slot +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataSlot) == 0x10) +} + +SceAppUtilSaveDataSlotParam :: struct { + status: SceAppUtilSaveDataSlotStatus, //!< Status + title: [32]sce.WChar16, //!< Title name + subTitle: [64]sce.WChar16, //!< Subtitle + detail: [256]sce.WChar16, //!< Detail info + iconPath: [64]c.char, //!< Icon path + userParam: c.int, //!< User param + sizeKB: sce.Size, //!< Data size (In KB) + modifiedTime: sce.DateTime, //!< Last modified time + reserved: [48]c.uint8_t, //!< Reserved range +} +#assert(size_of(SceAppUtilSaveDataSlotParam) == 0x34C) + +SceAppUtilSaveDataSaveItem :: struct { + dataPath: cstring, //!< Path to savedata + buf: rawptr, //!< Buffer of savedata file + pad: c.uint32_t, //!< Padding + offset: sce.Off, //!< Offset of savedata file + mode: c.int, //!< Savedata save mode (One of ::SceAppUtilSaveDataSaveMode) + reserved: [36]c.uint8_t, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataSaveItem) == 0x40) +} + +SceAppUtilSaveDataFile :: struct { + filePath: cstring, + buf: rawptr, + bufSize: sce.Size, + offset: sce.Off, + mode: c.uint, + progDelta: c.uint, + reserved: [32]c.uint8_t, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataFile) == 0x40) +} + +SceAppUtilSaveDataFileSlot :: struct { + id: c.uint, + slotParam: ^SceAppUtilSaveDataSlotParam, + reserved: [32]c.uint8_t, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataFileSlot) == 0x28) +} + +SceAppUtilSaveDataRemoveItem :: struct { + dataPath: cstring, //!< Path to savedata data + mode: c.int, //!< Savedata remove mode (One of ::SceAppUtilSaveDataRemoveMode) + reserved: [36]c.uint8_t, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilSaveDataRemoveItem) == 0x2C) +} + +SceAppUtilStoreBrowseParam :: struct { + type: c.uint, //!< Store browse type + id: cstring, //!< Target id +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilStoreBrowseParam) == 8) +} + +SceAppUtilWebBrowserParam :: struct { + str: cstring, //!< String that's passed to command specified by launchMode + strlen: sce.Size, //!< Length of str + launchMode: c.uint, //!< Browser mode + reserved: c.uint, //!< Reserved area +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAppUtilWebBrowserParam) == 0x10) +} + diff --git a/Atrac/Atrac.odin b/Atrac/Atrac.odin new file mode 100644 index 0000000..dc5024b --- /dev/null +++ b/Atrac/Atrac.odin @@ -0,0 +1,34 @@ +package atrac + +import "core:c" +import sce "../common" + +foreign import atrac "system:SceAtrac_stub" + +@(link_prefix = "sceAtrac") +foreign atrac { + QueryDecoderGroupMemSize :: proc(atracType: sce.UInt32, pDecoderGroup: ^SceAtracDecoderGroup) -> c.int --- + CreateDecoderGroup :: proc(atracType: sce.UInt32, pDecoderGroup: ^SceAtracDecoderGroup, pvWorkMem: rawptr, initAudiodecFlag: c.int) -> c.int --- + DeleteDecoderGroup :: proc(atracType: sce.UInt32, termAudiodecFlag: c.int) -> c.int --- + GetDecoderGroupInfo :: proc(atracType: sce.UInt32, pCreatedDecoder: ^SceAtracDecoderGroup, pAvailableDecoder: ^SceAtracDecoderGroup) -> c.int --- + SetDataAndAcquireHandle :: proc(pucBuffer: [^]sce.UChar8, uiReadSize: sce.UInt32, uiBufferSize: sce.UInt32) -> c.int --- + ReleaseHandle :: proc(atracHandle: c.int) -> c.int --- + Decode :: proc(atracHandle: c.int, pOutputBuffer: rawptr, pOutputSamples: ^sce.UInt32, pDecoderStatus: ^sce.UInt32) -> c.int --- + GetStreamInfo :: proc(atracHandle: c.int, pStreamInfo: ^SceAtracStreamInfo) -> c.int --- + AddStreamData :: proc(atracHandle: c.int, addSize: sce.UInt32) -> c.int --- + IsSubBufferNeeded :: proc(atracHandle: c.int) -> c.int --- + GetSubBufferInfo :: proc(atracHandle: c.int, pReadPosition: ^sce.UInt32, pMinSubBufferSize: ^sce.UInt32, pDataSize: ^sce.UInt32) -> c.int --- + SetSubBuffer :: proc(atracHandle: c.int, pSubBuffer: [^]sce.UChar8, subBufferSize: sce.UInt32) -> c.int --- + SetLoopNum :: proc(atracHandle: c.int, loopNum: c.int) -> c.int --- + SetOutputSamples :: proc(atracHandle: c.int, outputSamples: sce.UInt32) -> c.int --- + ResetNextOutputPosition :: proc(atracHandle: c.int, resetSample: sce.UInt32) -> c.int --- + GetContentInfo :: proc(atracHandle: c.int, pContentInfo: ^SceAtracContentInfo) -> c.int --- + GetLoopInfo :: proc(atracHandle: c.int, pLoopNum: ^c.int, pLoopStatus: ^sce.UInt32) -> c.int --- + GetOutputSamples :: proc(atracHandle: c.int, pOutputSamples: ^sce.UInt32) -> c.int --- + GetNextOutputPosition :: proc(atracHandle: c.int, pNextOutputSample: ^sce.UInt32) -> c.int --- + GetRemainSamples :: proc(atracHandle: c.int, pRemainSamples: ^sce.Long64) -> c.int --- + GetOutputableSamples :: proc(atracHandle: c.int, pOutputableSamples: ^sce.Long64) -> c.int --- + GetDecoderStatus :: proc(atracHandle: c.int, pDecoderStatus: ^sce.UInt32) -> c.int --- + GetVacantSize :: proc(atracHandle: c.int, pVacantSize: ^sce.UInt32) -> c.int --- + GetInternalError :: proc(atracHandle: c.int, pInternalError: ^c.int) -> c.int --- +} diff --git a/Atrac/types.odin b/Atrac/types.odin new file mode 100644 index 0000000..041dffb --- /dev/null +++ b/Atrac/types.odin @@ -0,0 +1,123 @@ +package atrac + +import "core:c" +import sce "../common" +import audiodec "../Audiodec" + +// TODO: should be c.int +SceAtracErrorCode :: enum i64 { + INVALID_POINTER = 0x80630000, + INVALID_SIZE = 0x80630001, + INVALID_WORD_LENGTH = 0x80630002, + INVALID_TYPE = 0x80630003, + INVALID_TOTAL_CH = 0x80630004, + INVALID_ALIGNMENT = 0x80630005, + ALREADY_CREATED = 0x80630006, + NOT_CREATED = 0x80630007, + SHORTAGE_OF_CH = 0x80630008, + UNSUPPORTED_DATA = 0x80630009, + INVALID_DATA = 0x8063000A, + READ_SIZE_IS_TOO_SMALL = 0x8063000B, + INVALID_HANDLE = 0x8063000C, + READ_SIZE_OVER_BUFFER = 0x8063000D, + MAIN_BUFFER_SIZE_IS_TOO_SMALL = 0x8063000E, + SUB_BUFFER_SIZE_IS_TOO_SMALL = 0x8063000F, + DATA_SHORTAGE_IN_BUFFER = 0x80630010, + ALL_DATA_WAS_DECODED = 0x80630011, + INVALID_MAX_OUTPUT_SAMPLES = 0x80630012, + ADDED_DATA_IS_TOO_BIG = 0x80630013, + NEED_SUB_BUFFER = 0x80630014, + INVALID_SAMPLE = 0x80630015, + NO_NEED_SUB_BUFFER = 0x80630016, + INVALID_LOOP_STATUS = 0x80630017, + REMAIN_VALID_HANDLE = 0x80630018, + INVALID_LOOP_NUM = 0x80630030 +} + +/* Memory alignment size */ +SCE_ATRAC_ALIGNMENT_SIZE :: (audiodec.SCE_AUDIODEC_ALIGNMENT_SIZE) + +/* The macro of rounding up the memory size */ +//SCE_ATRAC_ROUND_UP(size) ((size + SCE_ATRAC_ALIGNMENT_SIZE - 1) & ~(SCE_ATRAC_ALIGNMENT_SIZE - 1)) + +/* The definition of ATRAC(TM) type */ +SCE_ATRAC_TYPE_AT9 : c.uint : (0x2003) + +/* Maximum number of total total channels */ +SCE_ATRAC_AT9_MAX_TOTAL_CH :: (audiodec.SCE_AUDIODEC_AT9_MAX_CH_IN_LIBRARY) + +/* The definition of wordLength */ +SCE_ATRAC_WORD_LENGTH_16BITS :: (audiodec.SCE_AUDIODEC_WORD_LENGTH_16BITS) + +/* Maximum number of channels per stream */ +SCE_ATRAC_AT9_MAX_CH_IN_DECODER :: (audiodec.SCE_AUDIODEC_AT9_MAX_CH_IN_DECODER) + +/* Maximum number of samples */ +SCE_ATRAC_AT9_MAX_FRAME_SAMPLES :: (audiodec.SCE_AUDIODEC_AT9_MAX_SAMPLES) + +/* Maximum number of output samples */ +SCE_ATRAC_MAX_OUTPUT_SAMPLES :: (2048) + +/* Maximum number of output frames */ +SCE_ATRAC_AT9_MAX_OUTPUT_FRAMES :: (8) + +/* Minimum number of loop samples */ +SCE_ATRAC_AT9_MIN_LOOP_SAMPLES :: (3072) + +/* The definition of ATRAC infinite loop */ +SCE_ATRAC_INFINITE_LOOP_NUM : c.int : (-1) + +/* The definition of ATRAC infinite samples */ +SCE_ATRAC_INFINITE_SAMPLES : c.int : (-1) + +/* The definition of ATRAC decoder status */ +SceAtracDecoderStatus :: enum c.int { + ALL_DATA_WAS_DECODED = 0x00000001, + ALL_DATA_IS_ON_MEMORY = 0x00000002, + NONLOOP_PART_IS_ON_MEMORY = 0x00000004, + LOOP_PART_IS_ON_MEMORY = 0x00000008 +} + +/* The definition of loop status */ +SceAtracLoopStatus :: enum c.int { + NON_RESETABLE_PART = 0x00000000, + RESETABLE_PART = 0x00000001 +} + +/* The structure for decoder group */ +SceAtracDecoderGroup :: struct { + size: sce.UInt32, + wordLength: sce.UInt32, + totalCh: sce.UInt32, +} +#assert(size_of(SceAtracDecoderGroup) == 0xC) + +/* Content information structure */ +SceAtracContentInfo :: struct { + size: sce.UInt32, + atracType: sce.UInt32, + channel: sce.UInt32, + samplingRate: sce.UInt32, + endSample: sce.Int32, + loopStartSample: sce.Int32, + loopEndSample: sce.Int32, + bitRate: sce.UInt32, + fixedEncBlockSize: sce.UInt32, + fixedEncBlockSample: sce.UInt32, + frameSample: sce.UInt32, + loopBlockOffset: sce.UInt32, + loopBlockSize: sce.UInt32, +} +#assert(size_of(SceAtracContentInfo) == 0x34) + +/* Stream information structure */ +SceAtracStreamInfo :: struct { + size: sce.UInt32, + pWritePosition: ^sce.UChar8, // TODO: multipointer??? + readPosition: sce.UInt32, + writableSize: sce.UInt32, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAtracStreamInfo) == 0x10) +} + diff --git a/AudioIn/AudioIn.odin b/AudioIn/AudioIn.odin new file mode 100644 index 0000000..30ec64e --- /dev/null +++ b/AudioIn/AudioIn.odin @@ -0,0 +1,20 @@ +package audioin + +import "core:c" + +foreign import audioin "system:SceAudioIn_stub" + +@(link_prefix = "sceAudioIn") +foreign audioin { + //! Open port + OpenPort :: proc(portType: SceAudioInPortType, grain: c.int, freq: c.int, param: SceAudioInParam) -> c.int --- + + //! Close port + ReleasePort :: proc(port: c.int) -> c.int --- + + Input :: proc(port: c.int, destPtr: rawptr) -> c.int --- + + /* get status */ + GetAdopt :: proc(portType: SceAudioInPortType) -> c.int --- + GetStatus :: proc(select: c.int) -> c.int --- +} diff --git a/AudioIn/types.odin b/AudioIn/types.odin new file mode 100644 index 0000000..4fc4eda --- /dev/null +++ b/AudioIn/types.odin @@ -0,0 +1,42 @@ +package audioin + +import "core:c" + +// TODO: should be c.int +SceAudioInErrorCode :: enum i64 { + //! Undefined error + FATAL = 0x80260100, + //! Bad value of port number + INVALID_PORT = 0x80260101, + //! Invalid sample length + INVALID_SIZE = 0x80260102, + //! Invalid sample frequency + INVALID_SAMPLE_FREQ = 0x80260103, + //! Invalid port type + INVALID_PORT_TYPE = 0x80260104, + //! Invalid pointer value + INVALID_POINTER = 0x80260105, + //! Invalid port param + INVALID_PORT_PARAM = 0x80260106, + //! Cannot open no ports + PORT_FULL = 0x80260107, + //! Not enough memory + OUT_OF_MEMORY = 0x80260108, + //! Port is not opened + NOT_OPENED = 0x80260109, + //! Tried to input while busy + BUSY = 0x8026010A, + //! Invalid parameter + INVALID_PARAMETER = 0x8026010B +} + +SceAudioInPortType :: enum c.int { + VOICE = 0, + RAW = 2 +} + +SceAudioInParam :: enum c.int { + PARAM_FORMAT_S16_MONO = 0, + GETSTATUS_MUTE = 1 +} + diff --git a/AudioOut/AudioOut.odin b/AudioOut/AudioOut.odin new file mode 100644 index 0000000..0013943 --- /dev/null +++ b/AudioOut/AudioOut.odin @@ -0,0 +1,107 @@ +package audioout + +import "core:c" +import sce "../common" + +foreign import audioout "system:SceAudio_stub" + +@(link_prefix = "sceAudioOut") +foreign audioout { + /** + * Initialize audio port + * + * @param[in] type - One of ::SceAudioOutPortType + * @param[in] len - Number of samples, between ::SCE_AUDIO_MIN_LEN and ::SCE_AUDIO_MAX_LEN (multiple of 64) + * @param[in] freq - Sampling frequency (in Hz), one of the followings : + * 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 + * @param[in] mode - One of ::SceAudioOutMode + * + * @return port number, < 0 on error. + * @note - The volume is initially set to its max value (::SCE_AUDIO_OUT_MAX_VOL) + */ + OpenPort :: proc(type: SceAudioOutPortType, len: c.int, freq: c.int, mode: SceAudioOutMode) -> c.int --- + + /** + * Release an audio port + * + * @param[in] type - Port number returned by ::sceAudioOutOpenPort + * + * @return 0 on success, < 0 on error. + */ + ReleasePort :: proc(port: c.int) -> c.int --- + + /** + * Output audio (blocking function) + * + * @param[in] port - Port number returned by ::sceAudioOutOpenPort + * @param[in] *buf : Pointer to audio data buffer + * + * @return 0 on success, < 0 on error. + * @note - if NULL is specified for *buf, the function will not return until the last + * output audio data has been output. + */ + Output :: proc(port: c.int, buf: rawptr) -> c.int --- + + /** + * Set volume of specified output audio port + * + * @param[in] port - Port number returned by ::sceAudioOutOpenPort + * @param[in] ch - Channel numbers as flags (see ::SceAudioOutChannelFlag) + * @param[in] *vol - Array to int specifying volume for each channel (Left channel first for stereo) + * + * @return 0 on success, < 0 on error. + */ + SetVolume :: proc(port: c.int, ch: SceAudioOutChannelFlag, vol: ^c.int) -> c.int --- + + /** + * Change configuration of specified output port + * + * @param[in] port - Port number returned by ::sceAudioOutOpenPort + * @param[in] len - see ::sceAudioOutOpenPort() + * @param[in] freq - see ::sceAudioOutOpenPort() + * @param[in] mode - see ::sceAudioOutOpenPort() + * + * @return 0 on success, < 0 on error. + * @note - If (-1) is specified for any argument (excepted for port), current configuration is used instead. + */ + SetConfig :: proc(port: c.int, len: sce.Size, freq: c.int, mode: SceAudioOutMode) -> c.int --- + + /** + * Get a parameter value of specified output port + * + * @param[in] port - Port number returned by ::sceAudioOutOpenPort + * @param[in] type - One of ::SceAudioOutConfigType + * + * @return 0 on success, < 0 on error. + */ + GetConfig :: proc(port: c.int, type: SceAudioOutConfigType) -> c.int --- + + /** + * Set 'Automatic Level Control' mode on the BGM port + * ALC is also known as 'Dynamic Normalizer' + * + * @param[in] mode - One of ::SceAudioOutAlcMode + * + * @return 0 on success, < 0 on error. + */ + SetAlcMode :: proc(mode: SceAudioOutAlcMode) -> c.int --- + + /** + * Get the number of remaining samples to be output on the specified port + * + * @param[in] port - Port number returned by ::sceAudioOutOpenPort + * + * @return Number of samples on success, < 0 on error. + */ + GetRestSample :: proc(port: c.int) -> c.int --- + + /** + * Get status of port type + * Return different value on whether the port type is used for sound generation or not. + * + * @param[in] type - One of ::SceAudioOutPortType + * + * @return (1) if port is in use, (0) otherwise. < 0 on error. + */ + GetAdopt :: proc(type: SceAudioOutPortType) -> c.int --- +} diff --git a/AudioOut/types.odin b/AudioOut/types.odin new file mode 100644 index 0000000..bb9bd42 --- /dev/null +++ b/AudioOut/types.odin @@ -0,0 +1,66 @@ +package audioout + +import "core:c" + +// TODO: should be c.int +SceAudioOutErrorCode :: enum i64 { + NOT_OPENED = 0x80260001, + BUSY = 0x80260002, + INVALID_PORT = 0x80260003, + INVALID_POINTER = 0x80260004, + PORT_FULL = 0x80260005, + INVALID_SIZE = 0x80260006, + INVALID_FORMAT = 0x80260007, + INVALID_SAMPLE_FREQ = 0x80260008, + INVALID_VOLUME = 0x80260009, + INVALID_PORT_TYPE = 0x8026000A, + INVALID_FX_TYPE = 0x8026000B, + INVALID_CONF_TYPE = 0x8026000C, + OUT_OF_MEMORY = 0x8026000D +} + +SceAudioOutParam :: enum c.int { + FORMAT_S16_MONO = 0, + FORMAT_S16_STEREO = 1 +} + +SceAudioOutPortType :: enum c.int { + //! Used for main audio output, freq must be set to 48000 Hz + MAIN = 0, + //! Used for Background Music port + BGM = 1, + //! Used for voice chat port + VOICE = 2 +} + +SceAudioOutMode :: enum c.int { + MONO = 0, + STEREO = 1 +} + +SCE_AUDIO_MIN_LEN :: 64 //!< Minimum granularity +SCE_AUDIO_MAX_LEN :: 65472 //!< Maximum granularity + +SCE_AUDIO_OUT_MAX_VOL :: 32768 //!< Maximum output port volume +SCE_AUDIO_VOLUME_0DB :: SCE_AUDIO_OUT_MAX_VOL //!< Maximum output port volume + +/** Flags to use as 'ch' argument for ::sceAudioOutSetVolume */ +SceAudioOutChannelFlag :: enum c.int { + L_CH = 1, //!< Left Channel + R_CH = 2 //!< Right Channel +} + +/** Config type values to specify to ::sceAudioOutGetConfig */ +SceAudioOutConfigType :: enum c.int { + LEN = 0, + FREQ = 1, + MODE = 2 +} + +/** Argument 'mode' to specify to ::sceAudioOutSetAlcMode */ +SceAudioOutAlcMode :: enum c.int { + OFF = 0, + MODE1 = 1, + MODE_MAX = 2 +} + diff --git a/Audiodec/Audiodec.odin b/Audiodec/Audiodec.odin new file mode 100644 index 0000000..f28cfa8 --- /dev/null +++ b/Audiodec/Audiodec.odin @@ -0,0 +1,23 @@ +package audiodec + +import "core:c" +import sce "../common" + +foreign import audiodec "system:SceAudiodec_stub" + +@(link_prefix = "sceAudiodec") +foreign audiodec { + InitLibrary :: proc(codecType: sce.UInt32, pInitParam: ^SceAudiodecInitParam) -> sce.Int32 --- + TermLibrary :: proc(codecType: sce.UInt32) -> sce.Int32 --- + CreateDecoder :: proc(pCtrl: ^SceAudiodecCtrl, codecType: sce.UInt32) -> sce.Int32 --- + DeleteDecoder :: proc(pCtrl: ^SceAudiodecCtrl) -> sce.Int32 --- + Decode :: proc(pCtrl: ^SceAudiodecCtrl) -> sce.Int32 --- + DecodeNFrames :: proc(pCtrl: ^SceAudiodecCtrl, nFrames: sce.UInt32) -> sce.Int32 --- + DecodeNStreams :: proc(pCtrls: []^SceAudiodecCtrl, nStreams: sce.UInt32) -> sce.Int32 --- + ClearContext :: proc(pCtrl: ^SceAudiodecCtrl) -> sce.Int32 --- + GetInternalError :: proc(pCtrl: ^SceAudiodecCtrl, pInternalError: ^sce.Int32) -> sce.Int32 --- + + GetContextSize :: proc(pCtrl: ^SceAudiodecCtrl, codecType: sce.UInt32) -> sce.Int32 --- + CreateDecoderExternal :: proc(pCtrl: ^SceAudiodecCtrl, codecType: sce.UInt32, vaContext: sce.UIntVAddr, contextSize: sce.UInt32) -> sce.Int32 --- + DeleteDecoderExternal :: proc(pCtrl: ^SceAudiodecCtrl, pvaContext: ^sce.UIntVAddr) -> sce.Int32 --- +} diff --git a/Audiodec/types.odin b/Audiodec/types.odin new file mode 100644 index 0000000..ae66618 --- /dev/null +++ b/Audiodec/types.odin @@ -0,0 +1,189 @@ +package audiodec + +import "core:c" +import sce "../common" + +// TODO: this should be c.int +SceAudiodecErrorCode :: enum i64 { + ERROR_API_FAIL = 0x807F0000, + ERROR_INVALID_TYPE = 0x807F0001, + ERROR_INVALID_INIT_PARAM = 0x807F0002, + ERROR_ALREADY_INITIALIZED = 0x807F0003, + ERROR_OUT_OF_MEMORY = 0x807F0004, + ERROR_NOT_INITIALIZED = 0x807F0005, + ERROR_A_HANDLE_IN_USE = 0x807F0006, + ERROR_ALL_HANDLES_IN_USE = 0x807F0007, + ERROR_INVALID_PTR = 0x807F0008, + ERROR_INVALID_HANDLE = 0x807F0009, + ERROR_NOT_HANDLE_IN_USE = 0x807F000A, + ERROR_CH_SHORTAGE = 0x807F000B, + ERROR_INVALID_WORD_LENGTH = 0x807F000C, + ERROR_INVALID_SIZE = 0x807F000D, + ERROR_UNSUPPORTED = 0x807F000E, + ERROR_INVALID_NFRAMES = 0x807F000F, + ERROR_INVALID_NSTREAMS = 0x807F0010, + ERROR_DIFFERENT_TYPES = 0x807F0011, + ERROR_SAME_HANDLES = 0x807F0012, + ERROR_BUSY = 0x807F0013, + AT9_ERROR_INVALID_CONFIG = 0x807F2000, + MP3_ERROR_INVALID_CH = 0x807F2800, + MP3_ERROR_INVALID_MPEG_VERSION = 0x807F2801, + AAC_ERROR_INVALID_CH = 0x807F3000, + CELP_ERROR_INVALID_CONFIG = 0x807F3800 +} + +SCE_AUDIODEC_ALIGNMENT_SIZE : c.uint : 0x100 +// TODO: +//#define SCE_AUDIODEC_ROUND_UP(size) ((size + SCE_AUDIODEC_ALIGNMENT_SIZE - 1) & ~(SCE_AUDIODEC_ALIGNMENT_SIZE - 1)) + +SCE_AUDIODEC_WORD_LENGTH_16BITS :: 16 + +SceAudiodecType :: enum c.uint { + AT9 = 0x1003, + MP3 = 0x1004, + AAC = 0x1005, + CELP = 0x1006, +} + +SCE_AUDIODEC_AT9_MAX_CH_IN_LIBRARY :: 16 +SCE_AUDIODEC_MP3_MAX_STREAMS :: 8 +SCE_AUDIODEC_AAC_MAX_STREAMS :: 8 +SCE_AUDIODEC_CELP_MAX_STREAMS :: 8 + +SCE_AUDIODEC_AT9_MAX_CH_IN_DECODER :: 2 +SCE_AUDIODEC_MP3_MAX_CH_IN_DECODER :: 2 +SCE_AUDIODEC_AAC_MAX_CH_IN_DECODER :: 2 +SCE_AUDIODEC_CELP_MAX_CH_IN_DECODER :: 1 + +SCE_AUDIODEC_AT9_MAX_SAMPLES :: 256 +SCE_AUDIODEC_MP3_MAX_SAMPLES :: 1152 +SCE_AUDIODEC_AAC_MAX_SAMPLES :: 2048 +SCE_AUDIODEC_CELP_MAX_SAMPLES :: 320 + +SCE_AUDIODEC_AT9_MAX_ES_SIZE :: 1024 +SCE_AUDIODEC_MP3_MAX_ES_SIZE :: 1441 +SCE_AUDIODEC_AAC_MAX_ES_SIZE :: 1536 +SCE_AUDIODEC_CELP_MAX_ES_SIZE :: 24 + +SCE_AUDIODEC_AT9_EXTRA_ACCESS_SIZE :: 0 +SCE_AUDIODEC_MP3_EXTRA_ACCESS_SIZE :: 0 +SCE_AUDIODEC_AAC_EXTRA_ACCESS_SIZE :: 0 +SCE_AUDIODEC_CELP_EXTRA_ACCESS_SIZE :: 0 + +SCE_AUDIODEC_AT9_MAX_NFRAMES :: 8 +SCE_AUDIODEC_MP3_MAX_NFRAMES :: 1 +SCE_AUDIODEC_AAC_MAX_NFRAMES :: 1 +SCE_AUDIODEC_CELP_MAX_NFRAMES :: 1 + +SCE_AUDIODEC_AT9_MAX_NSTREAMS :: 6 +SCE_AUDIODEC_MP3_MAX_NSTREAMS :: 6 +SCE_AUDIODEC_AAC_MAX_NSTREAMS :: 6 +SCE_AUDIODEC_CELP_MAX_NSTREAMS :: 7 + +SceAudiodecMpegVersion :: enum c.int { + VERSION_2_5 = 0, + VERSION_RESERVED = 1, + VERSION_2 = 2, + VERSION_1 = 3 +} + +SCE_AUDIODEC_CELP_MPE :: 0 + +SCE_AUDIODEC_CELP_SAMPLING_RATE_8KHZ :: 8000 + +SceAudiodecCelpBitrate :: enum c.int { + BIT_RATE_3850BPS = 3850, + BIT_RATE_4650BPS = 4650, + BIT_RATE_5700BPS = 5700, + BIT_RATE_6600BPS = 6600, + BIT_RATE_7300BPS = 7300, + BIT_RATE_8700BPS = 8700, + BIT_RATE_9900BPS = 9900, + BIT_RATE_10700BPS = 10700, + BIT_RATE_11800BPS = 11800, + BIT_RATE_12200BPS = 12200, +} + +SceAudiodecInitStreamParam :: struct { + size: sce.UInt32, + totalStreams: sce.UInt32, +} +#assert(size_of(SceAudiodecInitStreamParam) == 8) + +SceAudiodecInitChParam :: struct { + size: sce.UInt32, + totalCh: sce.UInt32, +} +#assert(size_of(SceAudiodecInitChParam) == 8) + +SceAudiodecInitParam :: struct #raw_union { + size: sce.UInt32, + at9: SceAudiodecInitChParam, + mp3: SceAudiodecInitStreamParam, + aac: SceAudiodecInitStreamParam, + celp: SceAudiodecInitStreamParam, +} +#assert(size_of(SceAudiodecInitParam) == 8) + +SceAudiodecInfoAt9 :: struct { + size: sce.UInt32, + configData: [4]sce.UInt8, + ch: sce.UInt32, + bitRate: sce.UInt32, + samplingRate: sce.UInt32, + superFrameSize: sce.UInt32, + framesInSuperFrame: sce.UInt32, +} +#assert(size_of(SceAudiodecInfoAt9) == 0x1C) + +SceAudiodecInfoMp3 :: struct { + size: sce.UInt32, //!< sizeof(SceAudiodecInfoMp3) + ch: sce.UInt32, //!< number of channels (mono: 1, stereo/joint stereo/two mono: 2) + version: sce.UInt32, //!< MPEG version (MPEG1: 3, MPEG2: 2, MPEG2.5: 0) +} +#assert(size_of(SceAudiodecInfoMp3) == 0xC) + +SceAudiodecInfoAac :: struct { + size: sce.UInt32, + isAdts: sce.UInt32, + ch: sce.UInt32, + samplingRate: sce.UInt32, + isSbr: sce.UInt32, +} +#assert(size_of(SceAudiodecInfoAac) == 0x14) + +/** Information structure for CELP */ +SceAudiodecInfoCelp :: struct { + size: sce.UInt32, //!< sizeof(SceAudiodecInfoCelp) + excitationMode: sce.UInt32, //!< Excitation mode + samplingRate: sce.UInt32, //!< Sampling rate + bitRate: sce.UInt32, //!< Bit rate (one of ::SceAudiodecCelpBitrate) + lostCount: sce.UInt32, +} +#assert(size_of(SceAudiodecInfoCelp) == 0x14) + +SceAudiodecInfo :: struct #raw_union { + size: sce.UInt32, + at9: SceAudiodecInfoAt9, + mp3: SceAudiodecInfoMp3, + aac: SceAudiodecInfoAac, + celp: SceAudiodecInfoCelp, +} +#assert(size_of(SceAudiodecInfo) == 0x1C) + +SceAudiodecCtrl :: struct { + size: sce.UInt32, + handle: sce.Int32, + pEs: ^sce.UInt8, //!< pointer to elementary stream + inputEsSize: sce.UInt32, //!< size of elementary stream used actually (in byte) + maxEsSize: sce.UInt32, //!< maximum size of elementary stream used (in byte) + pPcm: rawptr, //!< pointer to PCM + outputPcmSize: sce.UInt32, //!< size of PCM output actually (in byte) + maxPcmSize: sce.UInt32, //!< maximum size of PCM output (in byte) + wordLength: sce.UInt32, //!< PCM bit depth + pInfo: ^SceAudiodecInfo, //!< pointer to SceAudiodecInfo +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAudiodecCtrl) == 0x28) +} + diff --git a/Audioenc/Audioenc.odin b/Audioenc/Audioenc.odin new file mode 100644 index 0000000..327062c --- /dev/null +++ b/Audioenc/Audioenc.odin @@ -0,0 +1,18 @@ +package audioenc + +import "core:c" +import sce "../common" + +foreign import audioenc "system:SceAudioenc_stub" + +@(link_prefix = "sceAudioenc") +foreign audioenc { + InitLibrary :: proc(codecType: c.int, pInitParam: ^SceAudioencInitParam) -> c.int --- + TermLibrary :: proc(codecType: c.uint) -> c.int --- + CreateEncoder :: proc(pCtrl: ^SceAudioencCtrl, codecType: c.int) -> c.int --- + DeleteEncoder :: proc(pCtrl: ^SceAudioencCtrl) -> c.int --- + Encode :: proc(pCtrl: ^SceAudioencCtrl) -> c.int --- + ClearContext :: proc(pCtrl: ^SceAudioencCtrl) -> c.int --- + GetOptInfo :: proc(pCtrl: ^SceAudioencCtrl) -> c.int --- + GetInternalError :: proc(pCtrl: ^SceAudioencCtrl, pInternalError: ^c.int) -> c.int --- +} diff --git a/Audioenc/types.odin b/Audioenc/types.odin new file mode 100644 index 0000000..d6510ad --- /dev/null +++ b/Audioenc/types.odin @@ -0,0 +1,113 @@ +package audioenc + +import "core:c" +import sce "../common" + +// TODO: should be c.int +SceAudioencErrorCode :: enum i64 { + API_FAIL = 0x80860000, + INVALID_TYPE = 0x80860001, + INVALID_INIT_PARAM = 0x80860002, + ALREADY_INITIALIZED = 0x80860003, + OUT_OF_MEMORY = 0x80860004, + NOT_INITIALIZED = 0x80860005, + A_HANDLE_IN_USE = 0x80860006, + ALL_HANDLES_IN_USE = 0x80860007, + INVALID_PTR = 0x80860008, + INVALID_HANDLE = 0x80860009, + NOT_HANDLE_IN_USE = 0x8086000A, + CH_SHORTAGE = 0x8086000B, + INVALID_WORD_LENGTH = 0x8086000C, + INVALID_SIZE = 0x8086000D, + INVALID_ALIGNMENT = 0x8086000E, + UNSUPPORTED = 0x8086000F +} + +// TODO: should be c.int +SceAudioencCelpErrorCode :: enum i64 { + INVALID_CONFIG = 0x80861001 +} + +SCE_AUDIOENC_WORD_LENGTH_16BITS :: 16 //!< Definition of wordlength +SCE_AUDIOENC_TYPE_CELP : c.uint : 0x2006 //!< Audio encoder type +SCE_AUDIOENC_CELP_MAX_STREAMS :: 1 //!< Max number of streams +SCE_AUDIOENC_CELP_MAX_SAMPLES :: 320 //!< Max number of samples +SCE_AUDIOENC_CELP_MAX_ES_SIZE :: 24 //!< Max elementary stream size +SCE_AUDIOENC_CELP_MPE :: (0) //!< CELP encoder default excitation mode +SCE_AUDIOENC_CELP_SAMPLING_RATE_8KHZ :: (8000) //!< CELP encoder default sampling rate + +SceAudioencCelpBitrate :: enum c.int { + BIT_RATE_3850BPS = 3850, + BIT_RATE_4650BPS = 4650, + BIT_RATE_5700BPS = 5700, + BIT_RATE_6600BPS = 6600, + BIT_RATE_7300BPS = 7300, + BIT_RATE_8700BPS = 8700, + BIT_RATE_9900BPS = 9900, + BIT_RATE_10700BPS = 10700, + BIT_RATE_11800BPS = 11800, + BIT_RATE_12200BPS = 12200 +} + +/** Initialization structure to provide to ::SceAudioencInitParam */ +SceAudioencInitStreamParam :: struct { + size: sce.Size, //!< sizeof(SceAudioencInitStreamParam) + totalStreams: c.uint, //!< Total number of audio streams +} +#assert(size_of(SceAudioencInitStreamParam) == 8) + +/** Information structure for CELP */ +SceAudioencInfoCelp :: struct { + size: sce.Size, //!< sizeof(SceAudioencInfoCelp) + excitationMode: c.uint, //!< Excitation mode + samplingRate: c.uint, //!< Sampling rate + bitRate: c.uint, //!< Bit rate (one of ::SceAudioencCelpBitrate) +} +#assert(size_of(SceAudioencInfoCelp) == 0x10) + +/** Optional information structure for CELP */ +SceAudioencOptInfoCelp :: struct { + size: sce.Size, //!< sizeof(SceAudioencOptInfoCelp) + header: [32]c.uint8_t, //!< Header buffer + headerSize: sce.Size, //!< Header size + encoderVersion: c.uint, //!< Encoder version +} +#assert(size_of(SceAudioencOptInfoCelp) == 0x2C) + +/** Initialization structure to pass as argument to ::sceAudioencInitLibrary */ +SceAudioencInitParam :: struct #raw_union { + size: sce.Size, //!< sizeof(SceAudioencInitParam) + celp: SceAudioencInitStreamParam, //!< See ::SceAudioencInitStreamParam +} +#assert(size_of(SceAudioencInitParam) == 8) + +SceAudioencInfo :: struct #raw_union { + size: sce.Size, //!< sizeof(SceAudioencInfo) + celp: SceAudioencInfoCelp, //!< Information structure for CELP +} +#assert(size_of(SceAudioencInfo) == 0x10) + +/** Audio encoder optional info */ +SceAudioencOptInfo :: struct #raw_union { + size: sce.Size, //!< sizeof(SceAudioencOptInfo) + celp: SceAudioencOptInfoCelp, //!< Optional information structure for CELP +} +#assert(size_of(SceAudioencOptInfo) == 0x2C) + +SceAudioencCtrl :: struct { + size: sce.Size, //!< sizeof(SceAudioencCtrl) + handle: c.int, //!< Encoder handle + pInputPcm: rawptr, //!< Pointer to elementary stream + inputPcmSize: sce.Size, //!< Size of elementary stream used actually (in byte) + maxPcmSize: sce.Size, //!< Max size of elementary stream used (in byte) + pOutputEs: rawptr, //!< Pointer to PCM + outputEsSize: sce.Size, //!< Size of PCM output actually (in byte) + maxEsSize: sce.Size, //!< Max size of PCM output (in byte) + wordLength: sce.Size, //!< PCM bit depth + pInfo: ^SceAudioencInfo, //!< Pointer to ::SceAudioencInfo + pOptInfo: ^SceAudioencOptInfo, //!< Pointer to ::SceAudioencOptInfo +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAudioencCtrl) == 0x2C) +} + diff --git a/AvPlayer/AvPlayer.odin b/AvPlayer/AvPlayer.odin new file mode 100644 index 0000000..5d74281 --- /dev/null +++ b/AvPlayer/AvPlayer.odin @@ -0,0 +1,122 @@ +package avplayer + +import "core:c" +import sce "../common" + +foreign import avplayer "system:SceAvPlayer_stub" + +@(link_prefix = "sceAvPlayer") +foreign avplayer { + /** + * @param[in] data - Init data for the video player + * + * @return The video player handle on success, < 0 on error. + */ + Init :: proc(data: ^SceAvPlayerInitData) -> SceAvPlayerHandle --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return 0 on success, < 0 on error. + */ + Pause :: proc(handle: SceAvPlayerHandle) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return 0 on success, < 0 on error. + */ + Resume :: proc(handle: SceAvPlayerHandle) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return 0 on success, < 0 on error. + */ + Start :: proc(handle: SceAvPlayerHandle) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return 0 on success, < 0 on error. + */ + Stop :: proc(handle: SceAvPlayerHandle) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[in] looping - A flag indicating whether the video playback should loop + * + * @return 0 on success, < 0 on error. + */ + SetLooping :: proc(handle: SceAvPlayerHandle, looping: sce.Bool) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return SCE_TRUE if the video playback is active, SCE_FALSE otherwise. + */ + IsActive :: proc(handle: SceAvPlayerHandle) -> sce.Bool --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[in] filename - Full path to the file to play + * + * @return 0 on success, < 0 on error. + */ + AddSource :: proc(handle: SceAvPlayerHandle, filename: cstring) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return 0 on success, < 0 on error. + */ + Close :: proc(handle: SceAvPlayerHandle) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[out] info - Descriptor for the received data + * + * @return SCE_TRUE if new data is available, SCE_FALSE otherwise. + */ + GetAudioData :: proc(handle: SceAvPlayerHandle, info: ^SceAvPlayerFrameInfo) -> sce.Bool --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[out] info - Descriptor for the received data + * + * @return SCE_TRUE if new data is available, SCE_FALSE otherwise. + */ + GetVideoData :: proc(handle: SceAvPlayerHandle, info: ^SceAvPlayerFrameInfo) -> sce.Bool --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * + * @return Current time on the video playback in milliseconds. + */ + CurrentTime :: proc(handle: SceAvPlayerHandle) -> c.uint64_t --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[in] offset - Offset to jump to on the video playback in milliseconds. + * + * @return 0 on success, < 0 on error. + */ + JumpToTime :: proc(handle: SceAvPlayerHandle, offset: c.uint64_t) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[in] offset - One of ::SceAvPlayerTrickSpeeds. + * + * @return 0 on success, < 0 on error. + */ + SetTrickSpeed :: proc(handle: SceAvPlayerHandle, speed: c.int) -> c.int --- + + /** + * @param[in] handle - A player handle created with ::sceAvPlayerInit + * @param[in] id - Stream ID to get info for. + * @param[out] info - Info retrieved for the requested stream. + * + * @return 0 on success, < 0 on error. + */ + GetStreamInfo :: proc(handle: SceAvPlayerHandle, id: c.uint32_t, info: ^SceAvPlayerStreamInfo) -> c.int --- +} diff --git a/AvPlayer/types.odin b/AvPlayer/types.odin new file mode 100644 index 0000000..fce15ec --- /dev/null +++ b/AvPlayer/types.odin @@ -0,0 +1,149 @@ +package avplayer + +import "core:c" +import sce "../common" + +SceAvPlayerHandle :: distinct c.int +#assert(size_of(SceAvPlayerHandle) == 4) + +// TODO: should be c.int +SceAvPlayerErrorCode :: enum i64 { + INVALID_PARAM = 0x806A0001, + OUT_OF_MEMORY = 0x806A0003 +} + +SceAvPlayerTrickSpeeds :: enum c.int { + REWIND_32X = -3200, //!< Rewind 32x + REWIND_16X = -1600, //!< Rewind 16x + REWIND_8X = -800, //!< Rewind 8x + NORMAL = 100, //!< Normal Speed + FAST_FORWARD_2X = 200, //!< Fast Forward 2x + FAST_FORWARD_4X = 400, //!< Fast Forward 4x + FAST_FORWARD_8X = 800, //!< Fast Forward 8x + FAST_FORWARD_16X = 1600, //!< Fast Forward 16x + FAST_FORWARD_32X = 3200 //!< Fast Forward 32x +} + +SceAvPlayerStreamType :: enum c.int { + VIDEO, //!< Video stream type + AUDIO, //!< Audio stream type + TIMEDTEXT //!< Timed text (subtitles) stream type +} + +SceAvPlayerAlloc :: #type ^proc(arg: rawptr, alignment: c.uint32_t, size: c.uint32_t) -> rawptr +SceAvPlayerFree :: #type ^proc(arg: rawptr, ptr: rawptr) +SceAvPlayerAllocFrame :: #type ^proc(arg: rawptr, alignment: c.uint32_t, size: c.uint32_t) -> rawptr +SceAvPlayerFreeFrame :: #type ^proc(arg: rawptr, ptr: rawptr) + +SceAvPlayerOpenFile :: #type ^proc(p: rawptr, filename: cstring) -> c.int +SceAvPlayerCloseFile :: #type ^proc(p: rawptr) -> c.int +SceAvPlayerReadOffsetFile :: #type ^proc(p: rawptr, buffer: [^]c.uint8_t, position: c.uint64_t, length: c.uint32_t) -> c.int +SceAvPlayerSizeFile :: #type ^proc(p: rawptr) -> c.uint64_t + +SceAvPlayerEventCallback :: #type ^proc(p: rawptr, argEventId: c.int32_t, argSourceId: c.int32_t, argEventData: rawptr) + +SceAvPlayerMemReplacement :: struct { + objectPointer: rawptr, + allocate: SceAvPlayerAlloc, //!< Memory allocator for generic data + deallocate: SceAvPlayerFree, //!< Memory deallocator for generic data + allocateTexture: SceAvPlayerAllocFrame, //!< Memory allocator for video frames + deallocateTexture: SceAvPlayerFreeFrame, //!< Memory deallocator for video frames +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAvPlayerMemReplacement) == 0x14) +} + +SceAvPlayerFileReplacement :: struct { + objectPointer: rawptr, + open: SceAvPlayerOpenFile, //!< File open + close: SceAvPlayerCloseFile, //!< File close + readOffset: SceAvPlayerReadOffsetFile, //!< File read from offset + size: SceAvPlayerSizeFile, //!< File size +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAvPlayerFileReplacement) == 0x14) +} + +SceAvPlayerEventReplacement:: struct { + objectPointer: rawptr, + eventCallback: SceAvPlayerEventCallback, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAvPlayerEventReplacement) == 8) +} + +SceAvPlayerInitData :: struct { + memoryReplacement: SceAvPlayerMemReplacement, //!< Memory allocator replacement + fileReplacement: SceAvPlayerFileReplacement, //!< File I/O replacement + eventReplacement: SceAvPlayerEventReplacement, //!< Event callback replacement + debugLevel: c.int32_t, + basePriority: c.uint32_t, //!< Base priority of the thread running the video player + numOutputVideoFrameBuffers: c.int32_t, + autoStart: sce.Bool, //!< Flag indicating whether the video player should start playback automatically + reserved: [3]c.uint8_t, //!< Reserved data + defaultLanguage: cstring, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAvPlayerInitData) == 0x48) +} + +SceAvPlayerAudio :: struct { + channelCount: c.uint16_t, //!< The number of audio channels of the audio frame. + reserved: [2]c.uint8_t, //!< Reserved data. + sampleRate: c.uint32_t, //!< The samplerate of the audio frame in Hz. + size: c.uint32_t, //!< The size of the audio frame in bytes. + languageCode: c.uint32_t, //!< The language code of the audio frame. +} +#assert(size_of(SceAvPlayerAudio) == 0x10) + +SceAvPlayerVideo :: struct { + width: c.uint32_t, //!< The width of the video frame in pixels. + height: c.uint32_t, //!< The height of the video frame in pixels. + aspectRatio: c.float, //!< The aspect ratio of the video frame. + languageCode: c.uint32_t, //!< The language code of the video frame. +} +#assert(size_of(SceAvPlayerVideo) == 0x10) + +SceAvPlayerTextPosition :: struct { + top: c.uint16_t, + left: c.uint16_t, + bottom: c.uint16_t, + right: c.uint16_t, +} +#assert(size_of(SceAvPlayerTextPosition) == 8) + +SceAvPlayerTimedText :: struct { + languageCode: c.uint32_t, //!< The language code of the subtitles. + textSize: c.uint16_t, //!< The size of the subtitles. + fontSize: c.uint16_t, //!< The size of the subtitles. + position: SceAvPlayerTextPosition, //!< The position of the subtitles. +} +#assert(size_of(SceAvPlayerTimedText) == 0x10) + +SceAvPlayerStreamDetails :: struct #raw_union { + reserved: [4]c.uint32_t, //!< Reserved data. + audio: SceAvPlayerAudio, //!< Audio details. + video: SceAvPlayerVideo, //!< Video details. + subs: SceAvPlayerTimedText, //!< Subtitles details. +} +#assert(size_of(SceAvPlayerStreamDetails) == 0x10) + +SceAvPlayerFrameInfo :: struct { + pData: [^]c.uint8_t, //!< Pointer to the frame data. + reserved: c.uint32_t, //!< Reserved data + timeStamp: c.uint64_t, //!< Timestamp of the frame in milliseconds + details: SceAvPlayerStreamDetails, //!< The frame details. +} +when size_of(rawptr) == 4 { + #assert(size_of(SceAvPlayerFrameInfo) == 0x20) +} + +SceAvPlayerStreamInfo :: struct { + type: c.uint32_t, //!< Type of the stream (One of ::SceAvPlayerStreamType) + reserved: c.uint32_t, //!< Reserved data + details: SceAvPlayerStreamDetails, //!< The stream details. + duration: c.uint64_t, //!< Total duration of the stream in milliseconds. + startTime: c.uint64_t, //!< Starting time of the stream in milliseconds. +} +#assert(size_of(SceAvPlayerStreamInfo) == 0x28) + diff --git a/BgAppUtil/BgAppUtil.odin b/BgAppUtil/BgAppUtil.odin new file mode 100644 index 0000000..d446bc6 --- /dev/null +++ b/BgAppUtil/BgAppUtil.odin @@ -0,0 +1,24 @@ +package bgapputil + +import "core:c" + +foreign import bgapputil "system:SceBgAppUtil_stub" + +/** + * Error Codes + */ +SceBgAppUtilErrorCode :: enum c.int { + SCE_BGAPP_UTIL_ERROR_INVALID_ARG = −2146409214 //0x80106502 +} + +@(link_prefix = "sceBgAppUtil") +foreign bgapputil { + /** + * Start BG application (eboot2.bin) + * + * @param[in] mode - must be 1 + * + * @return 0 on success, <0 otherwise. + */ + StartBgApp :: proc(mode: c.int) -> c.int --- +} diff --git a/Camera/Camera.odin b/Camera/Camera.odin new file mode 100644 index 0000000..3f83d9c --- /dev/null +++ b/Camera/Camera.odin @@ -0,0 +1,407 @@ +package camera + +import "core:c" +import sce "../common" + +foreign import camera "SceCamera_stub" + +@(link_prefix = "sceCamera") +foreign camera { + /** + * Open a camera device. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] pInfo - Pointer to an already set ::SceCameraInfo struct. + * + * @return SCE_OK, <0 on error. + */ + Open :: proc(devnum: c.int, pInfo: ^SceCameraInfo) -> c.int --- + + /** + * Close a camera device. + * + * @param[in] devnum - One of ::SceCameraDevice. + * + * @return SCE_OK, <0 on error. + */ + CameraClose :: proc(devnum: c.int) -> c.int --- + + /** + * Start camera streaming. + * + * @param[in] devnum - One of ::SceCameraDevice. + * + * @return SCE_OK, <0 on error. + */ + Start :: proc(devnum: c.int) -> c.int --- + + /** + * Stop camera streaming. + * + * @param[in] devnum - One of ::SceCameraDevice. + * + * @return SCE_OK, <0 on error. + */ + Stop :: proc(devnum: c.int) -> c.int --- + + /** + * Read image data from current streaming. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] pRead - Pointer to an already set ::SceCameraRead. + * + * @return SCE_OK, <0 on error. + */ + Read :: proc(devnum: c.int, pRead: ^SceCameraRead) -> c.int --- + + /** + * Check if camera device is active. + * + * @param[in] devnum - One of ::SceCameraDevice. + * + * @return 1 if camera is active, 0 if inactive , <0 on error. + */ + IsActive :: proc(devnum: c.int) -> c.int --- + + /** + * Get camera saturation value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result. (See ::SceCameraSaturation) + * + * @return SCE_OK , <0 on error. + */ + GetSaturation :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera saturation value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - One of ::SceCameraSaturation. + * + * @return SCE_OK , <0 on error. + */ + SetSaturation :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera brightness value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetBrightness :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera brightness value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - Brightness value. + * + * @return SCE_OK , <0 on error. + * + * @note Brightness value must be between 0 and 255. + */ + SetBrightness :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera contrast value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetContrast :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera contrast value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - Contrast value. + * + * @return SCE_OK , <0 on error. + * + * @note Contrast value must be between 0 and 255. + */ + SetContrast :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera sharpness value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result. (See ::SceCameraSharpness) + * + * @return SCE_OK , <0 on error. + */ + GetSharpness :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera sharpness value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - One of ::SceCameraSharpness. + * + * @return SCE_OK , <0 on error. + */ + SetSharpness :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera reverse mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraReverse) + * + * @return SCE_OK , <0 on error. + */ + GetReverse :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera reverse mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraReverse. + * + * @return SCE_OK , <0 on error. + */ + SetReverse :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get active camera effects. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetEffect :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Active a camera effect. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraEffect. + * + * @return SCE_OK , <0 on error. + */ + SetEffect :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera exposure compensation value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result (See ::SceCameraExposureCompensation). + * + * @return SCE_OK , <0 on error. + */ + GetEV :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera exposure compensation value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - One of ::SceCameraExposureCompensation. + * + * @return SCE_OK , <0 on error. + */ + SetEV :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera zoom value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLevel - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetZoom :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + + /** + * Set camera zoom value. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] level - Camera zoom value. + * + * @return SCE_OK , <0 on error. + */ + SetZoom :: proc(devnum: c.int, level: c.int) -> c.int --- + + /** + * Get camera anti-flickering mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraAntiFlicker) + * + * @return SCE_OK , <0 on error. + */ + GetAntiFlicker :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera exposure anti-flickering mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraAntiFlicker. + * + * @return SCE_OK , <0 on error. + */ + SetAntiFlicker :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera ISO speed mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraISO) + * + * @return SCE_OK , <0 on error. + */ + GetISO :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera ISO speed mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraISO. + * + * @return SCE_OK , <0 on error. + */ + SetISO :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera gain mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraGain) + * + * @return SCE_OK , <0 on error. + */ + GetGain :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera gain mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraGain. + * + * @return SCE_OK , <0 on error. + */ + SetGain :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera white balance mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraWhiteBalance) + * + * @return SCE_OK , <0 on error. + */ + GetWhiteBalance :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera white balance mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraWhiteBalance. + * + * @return SCE_OK , <0 on error. + */ + SetWhiteBalance :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera backlight compensation mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraBacklight) + * + * @return SCE_OK , <0 on error. + */ + GetBacklight :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera backlight mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraBacklight. + * + * @return SCE_OK , <0 on error. + */ + SetBacklight :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get nightmode mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. (See ::SceCameraNightmode) + * + * @return SCE_OK , <0 on error. + */ + GetNightmode :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set camera nightmoge mode. + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - One of ::SceCameraNightmode. + * + * @return SCE_OK , <0 on error. + */ + SetNightmode :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get exposure ceiling mode. (?) + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetExposureCeiling :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set exposure ceiling mode. (?) + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - Exposure ceiling mode value. (?) + * + * @return SCE_OK , <0 on error. + */ + SetExposureCeiling :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get auto control hold mode. (?) + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pMode - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + GetAutoControlHold :: proc(devnum: c.int, pMode: ^c.int) -> c.int --- + + /** + * Set auto control hold mode. (?) + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[in] mode - Auto control hold mode value. (?) + * + * @return SCE_OK , <0 on error. + */ + SetAutoControlHold :: proc(devnum: c.int, mode: c.int) -> c.int --- + + /** + * Get camera device location. (?) + * + * @param[in] devnum - One of ::SceCameraDevice. + * @param[out] pLocation - Pointer to a variable where to save the result. + * + * @return SCE_OK , <0 on error. + */ + + GetDeviceLocation :: proc(devnum: c.int, pLocation: ^sce.FVector3) -> c.int --- + + GetImageQuality :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + SetImageQuality :: proc(devnum: c.int, level: c.int) -> c.int --- + GetNoiseReduction :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + SetNoiseReduction :: proc(devnum: c.int, level: c.int) -> c.int --- + GetSharpnessOff :: proc(devnum: c.int, pLevel: ^c.int) -> c.int --- + SetSharpnessOff :: proc(devnum: c.int, level: c.int) -> c.int --- +} diff --git a/Camera/types.odin b/Camera/types.odin new file mode 100644 index 0000000..701832f --- /dev/null +++ b/Camera/types.odin @@ -0,0 +1,235 @@ +package camera + +import "core:c" +import sce "../common" + +// TODO: should be c.int +/** Camera error codes. */ +SceCameraErrorCode :: enum i64 { + PARAM = 0x802E0000, + ALREADY_INIT = 0x802E0001, + NOT_INIT = 0x802E0002, + ALREADY_OPEN = 0x802E0003, + NOT_OPEN = 0x802E0004, + ALREADY_START = 0x802E0005, + NOT_START = 0x802E0006, + FORMAT_UNKNOWN = 0x802E0007, + RESOLUTION_UNKNOWN = 0x802E0008, + BAD_FRAMERATE = 0x802E0009, + TIMEOUT = 0x802E000A, + EXCLUSIVE = 0x802E000B, + ATTRIBUTE_UNKNOWN = 0x802E000C, + MAX_PROCESS = 0x802E000D, + NOT_ACTIVE = 0x802E000E, + ALREADY_READ = 0x802E000F, + NOT_MOUNTED = 0x802E0010, + DATA_RANGE_UNKNOWN = 0x802E0011, + OTHER_ALREADY_START = 0x802E0012, + FATAL = 0x802E00FF, +} + +/** Enumeration for the camera device types. */ +SceCameraDevice :: enum c.int { + FRONT = 0, //!< Front camera + BACK = 1 //!< Retro camera +} + +/** Enumeration for the camera process priorities. */ +SceCameraPriority :: enum c.int { + SHARE = 0, //!< Share mode + EXCLUSIVE = 1 //!< Exclusive mode +} + +/** Enumeration for the camera output formats. */ +SceCameraFormat :: enum c.int { + INVALID = 0, //!< Invalid format + YUV422_PLANE = 1, //!< YUV422 planes + YUV422_PACKED = 2, //!< YUV422 pixels packed + YUV420_PLANE = 3, //!< YUV420 planes + ARGB = 4, //!< ARGB pixels + ABGR = 5, //!< ABGR pixels + RAW8 = 6 //!< 8 bit raw data +} + +/** Enumeration for the camera resolutions. */ +SceCameraResolution :: enum c.int { + RESOLUTION_0_0 = 0, //!< Invalid resolution + RESOLUTION_640_480 = 1, //!< VGA resolution + RESOLUTION_320_240 = 2, //!< QVGA resolution + RESOLUTION_160_120 = 3, //!< QQVGA resolution + RESOLUTION_352_288 = 4, //!< CIF resolution + RESOLUTION_176_144 = 5, //!< QCIF resolution + RESOLUTION_480_272 = 6, //!< PSP resolution + RESOLUTION_640_360 = 8 //!< NGP resolution +} + +/** Enumeration for the camera framerates. */ +SceCameraFrameRate :: enum c.int { + FRAMERATE_3_FPS = 3, //!< 3.75 fps + FRAMERATE_5_FPS = 5, //!< 5 fps + FRAMERATE_7_FPS = 7, //!< 7.5 fps + FRAMERATE_10_FPS = 10, //!< 10 fps + FRAMERATE_15_FPS = 15, //!< 15 fps + FRAMERATE_20_FPS = 20, //!< 20 fps + FRAMERATE_30_FPS = 30, //!< 30 fps + FRAMERATE_60_FPS = 60, //!< 60 fps + FRAMERATE_120_FPS = 120 //!< 120 fps (@note Resolution must be QVGA or lower) +} + +/** Enumeration for the camera exposure compensations. */ +SceCameraExposureCompensation :: enum c.int { + EV_NEGATIVE_20 = -20, //!< -2.0 + EV_NEGATIVE_17 = -17, //!< -1.7 + EV_NEGATIVE_15 = -15, //!< -1.5 + EV_NEGATIVE_13 = -13, //!< -1.3 + EV_NEGATIVE_10 = -10, //!< -1.0 + EV_NEGATIVE_7 = -7, //!< -0.7 + EV_NEGATIVE_5 = -5, //!< -0.5 + EV_NEGATIVE_3 = -3, //!< -0.3 + EV_POSITIVE_0 = 0, //!< +0.0 + EV_POSITIVE_3 = 3, //!< +0.3 + EV_POSITIVE_5 = 5, //!< +0.5 + EV_POSITIVE_7 = 7, //!< +0.7 + EV_POSITIVE_10 = 10, //!< +1.0 + EV_POSITIVE_13 = 13, //!< +1.3 + EV_POSITIVE_15 = 15, //!< +1.5 + EV_POSITIVE_17 = 17, //!< +1.7 + EV_POSITIVE_20 = 20 //!< +2.0 +} + +/** Enumeration for the camera effects. */ +SceCameraEffect :: enum c.int { + NORMAL = 0, + NEGATIVE = 1, + BLACKWHITE = 2, + SEPIA = 3, + BLUE = 4, + RED = 5, + GREEN = 6 +} + +/** Enumeration for the camera reverse modes. */ +SceCameraReverse :: enum c.int { + OFF = 0, //!< Reverse mode off + MIRROR = 1, //!< Mirror mode + FLIP = 2, //!< Flip mode + MIRROR_FLIP = (MIRROR | FLIP) //!< Mirror + Flip mode +} + +/** Enumeration for the camera saturations. */ +SceCameraSaturation :: enum c.int { + SATURATION_0 = 0, //!< 0.0 + SATURATION_5 = 5, //!< 0.5 + SATURATION_10 = 10, //!< 1.0 + SATURATION_20 = 20, //!< 2.0 + SATURATION_30 = 30, //!< 3.0 + SATURATION_40 = 40 //!< 4.0 +} + +/** Enumeration for the camera sharpnesses. */ +SceCameraSharpness :: enum c.int { + SHARPNESS_100 = 1, //!< 100% + SHARPNESS_200 = 2, //!< 200% + SHARPNESS_300 = 3, //!< 300% + SHARPNESS_400 = 4 //!< 400% +} + +/** Enumeration for the camera anti-flickering modes. */ +SceCameraAntiFlicker :: enum c.int { + ANTIFLICKER_AUTO = 1, //!< Automatic mode + ANTIFLICKER_50HZ = 2, //!< 50 Hz mode + ANTIFLICKER_60HZ = 3 //!< 50 Hz mode +} + +/** Enumeration for the camera ISO speed modes. */ +SceCameraISO :: enum c.int { + ISO_AUTO = 1, //!< Automatic mode + ISO_100 = 100, //!< ISO100/21� + ISO_200 = 200, //!< ISO200/24� + ISO_400 = 400 //!< ISO400/27� +} + +/** Enumeration for the camera gain modes. */ +SceCameraGain :: enum c.int { + GAIN_AUTO = 0, + GAIN_1 = 1, + GAIN_2 = 2, + GAIN_3 = 3, + GAIN_4 = 4, + GAIN_5 = 5, + GAIN_6 = 6, + GAIN_7 = 7, + GAIN_8 = 8, + GAIN_9 = 9, + GAIN_10 = 10, + GAIN_11 = 11, + GAIN_12 = 12, + GAIN_13 = 13, + GAIN_14 = 14, + GAIN_15 = 15, + GAIN_16 = 16 +} + +/** Enumeration for the camera white balance modes. */ +SceCameraWhiteBalance :: enum c.int { + AUTO = 0, //!< Automatic mode + DAY = 1, //!< Daylight mode + CWF = 2, //!< Cool White Fluorescent mode + SLSA = 4 //!< Standard Light Source A mode +} + +/** Enumeration for the camera backlight modes. */ +SceCameraBacklight :: enum c.int { + OFF = 0, //!< Disabled + ON = 1 //!< Enabled +} + +/** Enumeration for the camera nightmode modes. */ +SceCameraNightmode :: enum c.int { + OFF = 0, //!< Disabled + LESS10 = 1, //!< 10 lux or below + LESS100 = 2, //!< 100 lux or below + OVER100 = 3 //!< 100 lux or over +} + +SceCameraInfo :: struct { + size: sce.Size, //!< sizeof(SceCameraInfo) + priority: c.uint16_t, //!< Process priority (one of ::SceCameraPriority) + format: c.uint16_t, //!< Output format (One or more ::SceCameraFormat) + resolution: c.uint16_t, //!< Resolution (one of ::SceCameraResolution) + framerate: c.uint16_t, //!< Framerate (one of ::SceCameraFrameRate) + width: c.uint16_t, + height: c.uint16_t, + range: c.uint16_t, + pad: c.uint16_t, //!< Structure padding + sizeIBase: sce.Size, + sizeUBase: sce.Size, + sizeVBase: sce.Size, + pIBase: rawptr, + pUBase: rawptr, + pVBase: rawptr, + pitch: c.uint16_t, + buffer: c.uint16_t, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCameraInfo) == 0x30) +} + +SceCameraRead :: struct { + size: sce.Size, //!< sizeof(SceCameraRead) + mode: c.int, + pad: c.int, + status: c.int, + frame: c.uint64_t, + timestamp: c.uint64_t, + sizeIBase: sce.Size, + sizeUBase: sce.Size, + sizeVBase: sce.Size, + pIBase: rawptr, + pUBase: rawptr, + pVBase: rawptr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCameraRead) == 0x38) +} + diff --git a/Clib/Clib.odin b/Clib/Clib.odin new file mode 100644 index 0000000..5aeb0ce --- /dev/null +++ b/Clib/Clib.odin @@ -0,0 +1,70 @@ +package libkernel + +import "core:c" +import sce "../common" + +foreign import libkernel "system:SceLibKernel_stub" + +SceClibMspace :: distinct rawptr + +SceClibMspaceStats :: struct { + capacity: sce.Size, //!< Capacity of the Mspace + unk: sce.Size, //!< Unknown, value is equal to capacity + peak_in_use: sce.Size, //!< Peak memory allocated + current_in_use: sce.Size, //!< Current memory allocated +} +#assert(size_of(SceClibMspaceStats) == 0x10) + +@(link_prefix = "sceClib") +foreign libkernel { + Abort :: proc() --- + + LookCtypeTable :: proc(ch: c.char) -> c.char --- + + Tolower :: proc(ch: c.char) -> c.int --- + Toupper :: proc(ch: c.char) -> c.int --- + + Printf :: proc(fmt: cstring, #c_vararg args: ..any) -> c.int --- + Dprintf :: proc(fd: sce.UID, fmt: cstring, #c_vararg args: ..any) -> c.int --- + + Snprintf :: proc(dst: cstring, dst_max_size: sce.Size, fmt: cstring, #c_vararg args: ..any) -> c.int --- + Vsnprintf :: proc(dst: cstring, dst_max_size: sce.Size, fmt: cstring, args: c.va_list) -> c.int --- + + Strncpy :: proc(dst: cstring, src: cstring, len: sce.Size) -> cstring --- + Strncat :: proc(dst: cstring, src: cstring, len: sce.Size) -> cstring --- + + Strchr :: proc(s: cstring, ch: c.int) -> cstring --- + Strrchr :: proc(src: cstring, ch: c.int) -> cstring --- + Strstr :: proc(s1, s2: cstring) -> cstring --- + + Strcmp :: proc(s1, s2: cstring) -> c.int --- + Strncmp :: proc(s1, s2: cstring, len: sce.Size) -> c.int --- + Strncasecmp :: proc(s1, s2: cstring, len: sce.Size) -> c.int --- + + Strnlen :: proc(s1: cstring, max_len: sce.Size) -> sce.Size --- + + Memset :: proc(dst: rawptr, ch: c.int, len: sce.Size) -> rawptr --- + Memcpy :: proc(dst: rawptr, src: rawptr, len: sce.Size) -> rawptr --- + Memcpy_safe :: proc(dst: rawptr, src: rawptr, len: sce.Size) -> rawptr --- + Memmove :: proc(dst: rawptr, src: rawptr, len: sce.Size) -> rawptr --- + + Memcmp :: proc(s1: rawptr, s2: rawptr, len: sce.Size) -> c.int --- + + Memchr :: proc(src: rawptr, ch: c.int, len: sce.Size) -> rawptr --- + + MspaceCreate :: proc(memblock: rawptr, size: sce.Size) -> SceClibMspace --- + MspaceDestroy :: proc(mspace: SceClibMspace) --- + + MspaceMallocUsableSize :: proc(ptr: rawptr) -> sce.Size --- + MspaceIsHeapEmpty :: proc(mspace: SceClibMspace) -> sce.Bool --- + + MspaceMallocStats :: proc(mspace: SceClibMspace, stats: ^SceClibMspaceStats) --- + MspaceMallocStatsFast :: proc(mspace: SceClibMspace, stats: ^SceClibMspaceStats) --- + + MspaceMalloc :: proc(mspace: SceClibMspace, size: sce.Size) -> rawptr --- + MspaceCalloc :: proc(mspace: SceClibMspace, num: sce.Size , size: sce.Size) -> rawptr --- + MspaceRealloc :: proc(mspace: SceClibMspace, ptr: rawptr, size: sce.Size) -> rawptr --- + MspaceReallocalign :: proc(mspace: SceClibMspace, ptr: rawptr, size: sce.Size, alignment: sce.Size) -> rawptr --- + MspaceMemalign :: proc(mspace: SceClibMspace, alignment: sce.Size, size: sce.Size) -> rawptr --- + MspaceFree :: proc(mspace: SceClibMspace, ptr: rawptr) --- +} diff --git a/CommonDialog/CommonDialog.odin b/CommonDialog/CommonDialog.odin new file mode 100644 index 0000000..b85f06d --- /dev/null +++ b/CommonDialog/CommonDialog.odin @@ -0,0 +1,84 @@ +package commondialog + +import "core:c" +import sce "../common" +import sceClib "../Clib" + +foreign import commondialog "system:SceCommonDialog_stub" + +_sceCommonDialogSetMagicNumber :: #force_inline proc "c" (param: ^SceCommonDialogParam) { + param := param + param.magic = SCE_COMMON_DIALOG_MAGIC_NUMBER + (cast(^sce.UInt32)¶m)^ +} + +sceCommonDialogConfigParamInit :: #force_inline proc "c" (param: ^SceCommonDialogConfigParam) { + sceClib.Memset(param, 0x0, size_of(SceCommonDialogConfigParam)) + param.language = sce.SceSystemParamLang.MAX_VALUE + param.enterButtonAssign = sce.SceSystemParamEnterButtonAssign.MAX_VALUE + param.sdkVersion = sce.PSP2_SDK_VERSION +} + +sceMsgDialogParamInit :: #force_inline proc "c" (param: ^SceMsgDialogParam) { + sceClib.Memset(param, 0x0, size_of(SceMsgDialogParam)) + _sceCommonDialogSetMagicNumber(¶m.commonParam) + param.sdkVersion = sce.PSP2_SDK_VERSION +} + +sceNetCheckDialogParamInit :: #force_inline proc "c" (param: ^SceNetCheckDialogParam) { + sceClib.Memset(param, 0x0, size_of(SceNetCheckDialogParam)) + _sceCommonDialogSetMagicNumber(¶m.commonParam) + param.sdkVersion = sce.PSP2_SDK_VERSION + param.defaultAgeRestriction = SCE_NETCHECK_DIALOG_INITIAL_AGE_RESTRICTION +} + +foreign commondialog { + sceCommonDialogSetConfigParam :: proc(configParam: ^SceCommonDialogConfigParam) -> c.int --- + sceCommonDialogUpdate :: proc(updateParam: ^SceCommonDialogUpdateParam) -> c.int --- + + sceMsgDialogInit :: proc(#by_ptr param: SceMsgDialogParam) -> c.int --- + sceMsgDialogGetStatus :: proc() -> SceCommonDialogStatus --- + sceMsgDialogAbort :: proc() -> c.int --- + sceMsgDialogGetResult :: proc(result: ^SceMsgDialogResult) -> c.int --- + sceMsgDialogTerm :: proc() -> c.int --- + sceMsgDialogClose :: proc() -> c.int --- + + /** + * Increases the rate of the progress bar in the message dialog + * + * @param target - Target progress bar + * @param delta - Progress rate to increase (%) + * + * @return 0 on success, < 0 on error. + * @note - If NULL is provided as FrameBuf pointer, output is blacked out. + */ + sceMsgDialogProgressBarInc :: proc(target: SceMsgDialogProgressBarTarget, delta: sce.UInt32) -> c.int --- + + /** + * Set the progress rate of the progress bar in the message dialog immediately + * + * @param target - Target progress bar + * @param delta - Progress rate to increase (%) + * + * @return 0 on success, < 0 on error. + * @note - If NULL is provided as FrameBuf pointer, output is blacked out. + */ + sceMsgDialogProgressBarSetValue :: proc(target: SceMsgDialogProgressBarTarget, rate: sce.UInt32) -> c.int --- + + /** + * Set the string displayed in the progress bar of the message dialog immediately + * + * @param target - Target progress bar + * @param barMsg - The string displayed in the progress bar + * + * @return 0 on success, < 0 on error. + * @note - If NULL is provided as FrameBuf pointer, output is blacked out. + */ + sceMsgDialogProgressBarSetMsg :: proc(target: SceMsgDialogProgressBarTarget, barMsg: cstring) -> c.int --- + + sceNetCheckDialogInit :: proc(param: ^SceNetCheckDialogParam) -> sce.Int32 --- + sceNetCheckDialogGetStatus :: proc() -> SceCommonDialogStatus --- + sceNetCheckDialogAbort :: proc() -> sce.Int32 --- + sceNetCheckDialogGetResult :: proc(result: ^SceNetCheckDialogResult) -> sce.Int32 --- + sceNetCheckDialogGetPS3ConnectInfo :: proc(info: ^SceNetCheckDialogPS3ConnectInfo) -> sce.Int32 --- + sceNetCheckDialogTerm :: proc() -> sce.Int32 --- +} diff --git a/CommonDialog/types.odin b/CommonDialog/types.odin new file mode 100644 index 0000000..ecf8773 --- /dev/null +++ b/CommonDialog/types.odin @@ -0,0 +1,353 @@ +package commondialog + +import "core:c" +import sce "../common" +import sceGxm "../Gxm" +import sceNet "../Net" +import scePspnet "../PspnetAdhoc" + +SCE_COMMON_DIALOG_MAGIC_NUMBER :: 0xC0D1A109 + +/* Errors */ +// TODO: should be c.int +SceCommonDialogErrorCode :: enum i64 { + BUSY = 0x80020401, + NULL = 0x80020402, + INVALID_ARGUMENT = 0x80020403, + NOT_RUNNING = 0x80020404, + NOT_SUPPORTED = 0x80020405, + ILLEGAL_CALLER_THREAD = 0x80020406, + NOT_CONFIGURED = 0x80020407, + NOT_AVAILABLE = 0x80020408, + NOT_FINISHED = 0x80020410, + NOT_IN_USE = 0x80020411, + INVALID_COLOR_FORMAT = 0x80020420, + INVALID_SURFACE_RESOLUTION = 0x80020421, + INVALID_SURFACE_STRIDE = 0x80020422, + INVALID_SURFACE_TYPE = 0x80020423, + WITHIN_SCENE = 0x80020424, + IME_IN_USE = 0x80020430, + INVALID_LANGUAGE = 0x80020431, + INVALID_ENTER_BUTTON_ASSIGN = 0x80020432, + INVALID_INFOBAR_PARAM = 0x80020433, + INVALID_BG_COLOR = 0x80020434, + INVALID_DIMMER_COLOR = 0x80020435, + GXM_IS_UNINITIALIZED = 0x80020436, + UNEXPECTED_FATAL = 0x8002047F +} + +SceCommonDialogConfigParam :: struct { + sdkVersion: sce.UInt32, + language: sce.SceSystemParamLang, + enterButtonAssign: sce.SceSystemParamEnterButtonAssign, + reserved: [32]sce.UInt8, +} +#assert(size_of(SceCommonDialogConfigParam) == 0x2C) + +SceCommonDialogStatus :: enum c.int { + NONE = 0, + RUNNING = 1, + FINISHED = 2 +} + +SceCommonDialogResult :: enum c.int { + OK, + USER_CANCELED, + ABORTED +} + +SceCommonDialogRenderTargetInfo :: struct { + depthSurfaceData: sce.PVoid, + colorSurfaceData: sce.PVoid, + surfaceType: sceGxm.SceGxmColorSurfaceType, + colorFormat: sceGxm.SceGxmColorFormat, + width: sce.UInt32, + height: sce.UInt32, + strideInPixels: sce.UInt32, + reserved: [32]sce.UInt8, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCommonDialogRenderTargetInfo) == 0x3C) +} + +SceCommonDialogUpdateParam :: struct { + renderTarget: SceCommonDialogRenderTargetInfo, + displaySyncObject: ^sceGxm.SceGxmSyncObject, + reserved: [32]sce.UInt8, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCommonDialogUpdateParam) == 0x60) +} + +SceCommonDialogInfobarParam :: struct { + visibility: sce.Int32, + color: sce.Int32, + transparency: sce.Int32, + reserved: [32]sce.UInt8, +} +#assert(size_of(SceCommonDialogInfobarParam) == 0x2C) + +SceCommonDialogColor :: struct { + r: sce.UInt8, + g: sce.UInt8, + b: sce.UInt8, + a: sce.UInt8, +} +#assert(size_of(SceCommonDialogColor) == 4) + +SceCommonDialogBgColor :: SceCommonDialogColor +#assert(size_of(SceCommonDialogBgColor) == 4) + +SceCommonDialogParam :: struct { + infobarParam: ^SceCommonDialogInfobarParam, + bgColor: ^SceCommonDialogColor, + dimmerColor: ^SceCommonDialogColor, + reserved: [60]sce.UInt8, + magic: sce.UInt32, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCommonDialogParam) == 0x4C) +} + + +// TODO: +SceMsgDialogErrorCode :: enum c.uint { + //! Illegal parameter + SCE_MSG_DIALOG_ERROR_PARAM = 0x80100A01 +} + +//! Max length of a user message +SCE_MSG_DIALOG_USER_MSG_SIZE :: 512 + +SceMsgDialogMode :: enum c.int { + INVALID = 0, + USER_MSG = 1, + SYSTEM_MSG = 2, + ERROR_CODE = 3, + PROGRESS_BAR = 4 +} + +SceMsgDialogSystemMessageType :: enum c.int { + INVALID = 0, + //! Displays "Please wait." + WAIT = 1, + //! Displays "There is not enough free space on the memory card." + NOSPACE = 2, + //! Displays "Move away from the source of interference, or adjust the compass by moving your PS Vita system as shown below." + MAGNETIC_CALIBRATION = 3, + //! Displays "Please wait." in a small message dialog + WAIT_SMALL = 5, + //! Displays "Please wait..." with a cancel button + WAIT_CANCEL = 6, + //! Displays "Cannot continue the application. No memory card is inserted." + NEED_MC_CONTINUE = 7, + //! Displays "Cannot perform this operation. No memory card is inserted." + NEED_MC_OPERATION = 8, + //! Displays "You must enable the microphone." + TRC_MIC_DISABLED = 100, + //! Displays "You must use Wi-Fi to do this." + TRC_WIFI_REQUIRED_OPERATION = 101, + //! Displays "You must use Wi-Fi to use this application." + TRC_WIFI_REQUIRED_APPLICATION = 102, + //! Displays "No content is available yet." + TRC_EMPTY_STORE = 103 +} + +SceMsgDialogButtonType :: enum c.int { + TYPE_OK = 0, + TYPE_YESNO = 1, + TYPE_NONE = 2, + TYPE_OK_CANCEL = 3, + TYPE_CANCEL = 4, + TYPE_3BUTTONS = 5 +} + +SceMsgDialogButtonId :: enum c.int { + INVALID = 0, + OK = 1, + YES = 1, + NO = 2, + RETRY = 3, + BUTTON1 = 1, + BUTTON2 = 2, + BUTTON3 = 3 +} + +SceMsgDialogProgressBarType :: enum c.int { + PERCENTAGE = 0 +} + +SceMsgDialogProgressBarTarget :: enum c.int { + DEFAULT = 0 +} + +SceMsgDialogEnvFlag :: enum c.int { + DEFAULT = 0 +} + +SceMsgDialogFontSize :: enum c.int { + DEFAULT = 0, + SMALL = 1 +} + +SceMsgDialogButtonsParam :: struct { + msg1: cstring, //!< Text of the first button + fontSize1: sce.Int32, //!< Font size of the first button (one of ::SceMsgDialogFontSize) + msg2: cstring, //!< Text of the second button + fontSize2: sce.Int32, //!< Font size of the second button (one of ::SceMsgDialogFontSize) + msg3: cstring, //!< Text of the third button + fontSize3: sce.Int32, //!< Font size of the third button (one of ::SceMsgDialogFontSize) + reserved: [32]sce.Char8, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceMsgDialogButtonsParam) == 0x38) +} + +SceMsgDialogUserMessageParam :: struct { + buttonType: sce.Int32, //!< Type of button set (one of ::SceMsgDialogButtonType) + msg: cstring, //!< Displayed message + buttonParam: ^SceMsgDialogButtonsParam, //!< Buttons parameters + reserved: [28]sce.Char8, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceMsgDialogUserMessageParam) == 0x28) +} + +SceMsgDialogSystemMessageParam :: struct { + sysMsgType: sce.Int32, //!< System message type (one of ::SceMsgDialogSystemMessageType) + value: sce.Int32, //!< Additional value + reserved: [32]sce.Char8, //!< Reserved range +} +#assert(size_of(SceMsgDialogSystemMessageParam) == 0x28) + +SceMsgDialogErrorCodeParam :: struct { + errorCode: sce.Int32, //!< Displayed error code + reserved: [32]sce.Char8, //!< Reserved range +} +#assert(size_of(SceMsgDialogErrorCodeParam) == 0x24) + +SceMsgDialogProgressBarParam :: struct { + barType: sce.Int32, //!< Progress bar type (one of ::SceMsgDialogProgressBarType) + sysMsgParam: SceMsgDialogSystemMessageParam, //!< Displayed system message + msg: cstring, //!< Displayed user message + reserved: [8]sce.Int32, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceMsgDialogProgressBarParam) == 0x50) +} + +SceMsgDialogParam :: struct { + sdkVersion: sce.UInt32, //!< Required to use MsgDialog. Just use NULL + commonParam: SceCommonDialogParam, //!< Common parameter + mode: sce.Int32, //!< Mode of function (one of ::SceMsgDialogMode) + userMsgParam: ^SceMsgDialogUserMessageParam, //!< Parameter for user message + sysMsgParam: ^SceMsgDialogSystemMessageParam, //!< Parameter for system prepared message + errorCodeParam: ^SceMsgDialogErrorCodeParam, //!< Parameter for display error code + progBarParam: ^SceMsgDialogProgressBarParam, //!< Parameter for progress bar + flag: sce.Int32, //!< Settings for dialog environment (one of ::SceMsgDialogEnvFlag) + reserved: [32]sce.Char8, //!< Reserved range +} +when size_of(rawptr) == 4 { + #assert(size_of(SceMsgDialogParam) == 0x88) +} + +SceMsgDialogResult :: struct { + mode: sce.Int32, //!< Mode of function (one of ::SceMsgDialogMode) + result: sce.Int32, //!< Result of executing function + buttonId: sce.Int32, //!< Id of button user selected (one of ::SceMsgDialogButtonId) + reserved: [32]sce.Char8, //!< Reserved range +} +#assert(size_of(SceMsgDialogResult) == 0x2C) + + +// TODO: +SceNetCheckDialoErrorCode :: enum c.uint { + PARAM = 0x80100C01, + INVALID_MODE = 0x80100C02, + LACK_OF_LIBHTTP_POOL_SIZE = 0x80100C03, + LACK_OF_LIBSSL_POOL_SIZE = 0x80100C04, + LATEST_PATCH_PKG_EXIST = 0x80100C05, + SIGN_OUT = 0x80100C06, + INVALID_PSPADHOC_PARAM = 0x80100C07, + INVALID_TIMEOUT_PARAM = 0x80100C08, + PSN_AGE_RESTRICTION = 0x80100C09 +} + +SCE_NETCHECK_DIALOG_LEAST_HTTP_POOL_SIZE :: (36 * 1024) +SCE_NETCHECK_DIALOG_LEAST_SSL_POOL_SIZE :: (96 * 1024) +SCE_NETCHECK_DIALOG_INITIAL_AGE_RESTRICTION :: (-1) +SCE_NETCHECK_DIALOG_COUNTRY_CODE_LEN :: (2) +SCE_NETCHECK_DIALOG_AGE_RESTRICTION_COUNT_MAX :: (200) + +SceNetCheckDialogMode :: enum c.int { + INVALID = 0, + ADHOC_CONN = 1, + PSN = 2, + PSN_ONLINE = 3, + PS3_CONNECT = 4, + PSP_ADHOC_CONN = 5, + PSP_ADHOC_CREATE = 6, + PSP_ADHOC_JOIN = 7 +} + +SceNetCheckDialogPS3ConnectAction :: enum c.int { + ENTER = 0, + LEAVE = 1 +} + +SceNpCommunicationId :: struct { + data: [9]c.char, + term: c.char, + num: sce.UChar8, + dummy: c.char, +} +#assert(size_of(SceNpCommunicationId) == 0xC) + +SceNetCheckDialogPS3ConnectParam :: struct { + action: sce.Int32, + ssid: [32 + 1]c.char, + wpaKey: [64 + 1]c.char, + titleId: [9 + 1]c.char, +} +#assert(size_of(SceNetCheckDialogPS3ConnectParam) == 0x70) + +SceNetCheckDialogAgeRestriction :: struct { + countryCode: [SCE_NETCHECK_DIALOG_COUNTRY_CODE_LEN]c.char, + age: sce.Int8, + padding: sce.Int8, +} +#assert(size_of(SceNetCheckDialogAgeRestriction) == 4) + +SceNetCheckDialogParam :: struct { + sdkVersion: sce.UInt32, + commonParam: SceCommonDialogParam, + mode: sce.Int32, + npCommunicationId: SceNpCommunicationId, + ps3ConnectParam: ^SceNetCheckDialogPS3ConnectParam, + groupName: ^scePspnet.SceNetAdhocctlGroupName, + timeoutUs: sce.UInt32, + defaultAgeRestriction: sce.Int8, + padding: [3]sce.Int8, + ageRestrictionCount: sce.Int32, + ageRestriction: ^SceNetCheckDialogAgeRestriction, + reserved: [104]sce.UInt8, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetCheckDialogParam) == 0xE0) +} + +SceNetCheckDialogResult :: struct { + result: sce.Int32, + psnModeSucceeded: sce.Bool, + reserved: [124]sce.UInt8, +} +#assert(size_of(SceNetCheckDialogResult) == 0x84) + +SceNetCheckDialogPS3ConnectInfo :: struct { + inaddr: sceNet.SceNetInAddr, + nickname: [128]sce.UInt8, + macAddress: [6]sce.UInt8, + reserved: [6]sce.UInt8, +} +#assert(size_of(SceNetCheckDialogPS3ConnectInfo) == 0x90) + diff --git a/Compat/Compat.odin b/Compat/Compat.odin new file mode 100644 index 0000000..4a96cbb --- /dev/null +++ b/Compat/Compat.odin @@ -0,0 +1,299 @@ +package compat + +import "core:c" +import sce "../common" +import sceIo "../Io" + +foreign import compat "system:SceCompat_stub" + +SceCompatCacheMode :: enum c.int { + NONE = 0, + INVALIDATE = 1, + WRITEBACK = 2 +} + +SceCompatPeripheralMode :: enum c.int { + POWER_IS_SUSPEND_REQUIRED = 1, + POWER_GET_BATTERY_LIFETIME = 2, + POWER_GET_BATTERY_PERCENT = 3, + HPREMOTE_IS_HEADPHONE_EXIST = 4 +} + +SceCompatCdram :: struct { + cached_cdram: rawptr, + uncached_cdram: rawptr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceCompatCdram) == 8) +} + +SceCtrlDataPsp :: struct { + TimeStamp: c.uint, + Buttons: c.uint, + Lx: c.uchar, + Ly: c.uchar, + Rx: c.uchar, + Ry: c.uchar, + Rsrv: [4]c.uchar, +} +#assert(size_of(SceCtrlDataPsp) == 0x10) + + +@(link_prefix = "sceCompat") +foreign compat { + /** + * Init compat + * + * @param[in] unk - Unknown, pass 0 + * + * @return 0 on success, < 0 on error. + */ + InitEx :: proc(unk: c.int) -> c.int --- + + /** + * Uninit compat + * + * @return 0 on success, < 0 on error. + */ + Uninit :: proc() -> c.int --- + + /** + * Start compat + * + * @return 0 on success, < 0 on error. + */ + Start :: proc() -> c.int --- + + /** + * Stop compat + * + * @return 0 on success, < 0 on error. + */ + Stop :: proc() -> c.int --- + + /** + * Allocate cdram with hole + * + * @param[out] cdram - A pointer to a ::SceCompatCdram structure. + * + * @return 0 on success, < 0 on error. + */ + AllocCdramWithHole :: proc(cdram: ^SceCompatCdram) -> c.int --- + + /** + * Framebuffer init + * + * @param[in] framebuffer - Pointer to framebuffer + * + * @return 0 on success, < 0 on error. + */ + FrameBufferInit :: proc(framebuffer: rawptr) -> c.int --- + + /** + * Set suspend semaphores + * + * @param[in] semaid1 - Semaphore id 1 + * @param[in] semaid2 - Semaphore id 2 + * + * @return 0 on success, < 0 on error. + */ + SetSuspendSema :: proc(semaid1: sce.UID, semaid2: sce.UID) -> c.int --- + + /** + * Suspend/resume compat + * + * @param[in] unk - Unknown, pass 1 + * + * @return 0 on success, < 0 on error. + */ + SuspendResume :: proc(unk: c.int) -> c.int --- + + /** + * Cache operation + * + * @param[in] mode - One of ::SceCompatCacheMode + * @param[in] addr - Address + * @param[in] size - Size + * + * @return 0 on success, < 0 on error. + */ + Cache :: proc(mode: SceCompatCacheMode, addr: rawptr, size: sce.Size) -> c.int --- + + /** + * Wait for special request + * + * @param[in] unk - Unknown, pass 1 + * + * @return 0 on success, < 0 on error. + */ + WaitSpecialRequest :: proc(unk: c.int) -> c.int --- + + /** + * Interrupt code + * + * @param[in] intr_code - Interrupt code + * + * @return 0 on success, < 0 on error. + */ + Interrupt :: proc(intr_code: c.int) -> c.int --- + + /** + * LCDC sync + * + * @return 0 on success, < 0 on error. + */ + LCDCSync :: proc() -> c.int --- + + /** + * Get primary head + * + * @return 0 on success, < 0 on error. + */ + GetPrimaryHead :: proc() -> c.int --- + + /** + * Get peripheral state + * + * @param[in] mode - One of ::SceCompatPeripheralMode + * + * @return state on success, < 0 on error. + */ + GetPeripheralState :: proc(mode: SceCompatPeripheralMode) -> c.int --- + + /** + * Get compat status + * + * @return status on success, < 0 on error. + */ + GetStatus :: proc() -> c.int --- + + /** + * Get update state + * + * @return state on success, < 0 on error. + */ + GetUpdateState :: proc() -> c.int --- + + /** + * Set update state + * + * @param[in] state - State + * + * @return 0 on success, < 0 on error. + */ + SetUpdateState :: proc(state: c.int) -> c.int --- + + /** + * Set display config + * + * @param[in] unk0 - Unknown + * @param[in] unk1 - Unknown + * + * @return 0 on success, < 0 on error. + */ + SetDisplayConfig :: proc(unk0: c.int, unk1: c.int) -> c.int --- + + /** + * Set RIF name + * + * @param[in] rif - RIF name (max. 36 chars) + * + * @return 0 on success, < 0 on error. + */ + SetRif :: proc(rif: cstring) -> c.int --- + + /** + * Get PSP system software version + * + * @return version on success, < 0 on error. + */ + GetPspSystemSoftwareVersion :: proc() -> c.int --- + + /** + * Get color space setting availability + * + * @return 1 if true, 0 if false, < 0 on error. + */ + AvailableColorSpaceSetting :: proc() -> c.int --- + + /** + * Check if pocket station application is available + * + * @return 1 if true, 0 if false, < 0 on error. + */ + CheckPocketStation :: proc() -> c.int --- + + /** + * Check if current title is a pocket station game + * + * @return 1 if true, 0 if false, < 0 on error. + */ + IsPocketStationTitle :: proc() -> c.int --- + + /** + * Wait for command and get request + * + * @param[in] mode - Mode + * @param[in] id - ID + * + * @return pointer to request in PspEmu RAM on success, < 0 on error. + */ + WaitAndGetRequest :: proc(mode: c.int, id: c.int) -> c.int --- + + /** + * Read from shared sram + * + * @param[in] location - Location + * @param[out] value - Pointer to a int buffer to hold the value + * + * @return 0 on success, < 0 on error. + */ + ReadShared32 :: proc(location: c.int, value: ^c.int) -> c.int --- + + /** + * Write to shared sram + * + * @param[in] location - Location + * @param[in] value - Value + * + * @return 0 on success, < 0 on error. + */ + WriteShared32 :: proc(location: c.int, value: c.int) -> c.int --- + + /** + * Write shared control + * + * @param[in] info - A pointer to a ::SceCtrlDataPsp structure. + * + * @return 0 on success, < 0 on error. + */ + WriteSharedCtrl :: proc(pad_data: ^SceCtrlDataPsp) -> c.int --- + + /** + * Get title list + * + * @param[out] buf - A 100 bytes buffer for the title list + * @param[in] length - Must be 100 + * + * @return 0 on success, < 0 on error. + */ + GetTitleList :: proc(buf: rawptr, length: sce.Size) -> c.int --- + + /** + * Get Memory Card device information + * + * @param[out] info - A pointer to a ::SceIoDevInfo structure. + * + * @return 0 on success, < 0 on error. + */ + GetDevInf :: proc(info: ^sceIo.SceIoDevInfo) -> c.int --- + + /** + * Get current secure tick + * + * @param[out] tick - A pointer to a ::SceRtcTick structure. + * + * @return 0 on success, < 0 on error. + */ + GetCurrentSecureTick :: proc(tick: ^sce.RtcTick) -> c.int --- +} diff --git a/Ctrl/Ctrl.odin b/Ctrl/Ctrl.odin new file mode 100644 index 0000000..af257e7 --- /dev/null +++ b/Ctrl/Ctrl.odin @@ -0,0 +1,275 @@ +package ctrl + +import "core:c" +import sce "../common" + +foreign import ctrl "system:SceCtrl_stub" + +@(link_prefix = "sceCtrl") +foreign ctrl { + /** + * Set the controller mode. + * + * @param[in] mode - One of ::SceCtrlPadInputMode. + * + * @return The previous mode, <0 on error. + */ + sceCtrlSetSamplingMode :: proc(mode: SceCtrlPadInputMode) -> c.int --- + + /** + * Set the controller extend mode. + * + * @param[in] mode - One of ::SceCtrlPadInputMode. + * + * @return The previous mode, <0 on error. + */ + sceCtrlSetSamplingModeExt :: proc(mode: SceCtrlPadInputMode) -> c.int --- + + /** + * Get the current controller mode. + * + * @param[out] pMode - Return value, see ::SceCtrlPadInputMode. + * + * @return The current mode, <0 on error. + */ + sceCtrlGetSamplingMode :: proc(pMode: ^SceCtrlPadInputMode) -> c.int --- + + /** + * Get the controller state information (polling, positive logic). + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferPositive :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the wireless controller state information (polling, positive logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * + * @param[in] port - use 0 - 5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferPositive2 :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the controller state information (polling, positive logic). + * + * This function will return button presses, even if they're intercepted by common dialog/IME. + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferPositiveExt :: proc(port: c.int, pad_data: ^SceCtrlData, count: int) -> c.int --- + + /** + * Get the wireless controller state information (polling, positive logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * This function will return button presses, even if they're intercepted by common dialog/IME. + * + * @param[in] port - use 0 - 5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferPositiveExt2 :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the controller state information (polling, negative logic). + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferNegative :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the wireless controller state information (polling, negative logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * + * @param[in] port - use 0-5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlPeekBufferNegative2 :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the controller state information (blocking, positive logic). + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferPositive :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the wireless controller state information (blocking, positive logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * + * @param[in] port - use 0-5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferPositive2 :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the controller extended state information (blocking, positive logic). + * + * This function will return button presses, even if they're intercepted by common dialog/IME. + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferPositiveExt :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the wireless controller extended state information (blocking, positive logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * This function will return button presses, even if they're intercepted by common dialog/IME. + * + * @param[in] port - use 0-5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferPositiveExt2 :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the controller state information (blocking, negative logic). + * + * @param[in] port - use 0. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferNegative :: proc(port: c.int, pad_data: ^SceCtrlData, count: c.int) -> c.int --- + + /** + * Get the wireless controller state information (blocking, negative logic). + * + * This function will bind L/R trigger value to L1/R1 instead of LTRIGGER/RTRIGGER + * + * @param[in] port - use 0-5. + * @param[out] *pad_data - see ::SceCtrlData. + * @param[in] count - Buffers count. Up to 64 buffers can be requested. + * + * @return Buffers count, between 1 and 'count'. <0 on error. + */ + sceCtrlReadBufferNegative2 :: proc(port: c.int, pad_data: ^SceCtrlData , count: c.int) -> c.int --- + + /** + * Set rules for button rapid fire + * + * @param[in] port - use 0. + * @param[in] idx - rule index between 0-15 + * @param[in] pRule - structure ::SceCtrlRapidFireRule. + * + * @return 0, <0 on error. + */ + sceCtrlSetRapidFire :: proc(port: c.int, idx: c.int, pRule: ^SceCtrlRapidFireRule) -> c.int --- + + /** + * Clear rules for button rapid fire + * + * @param[in] port - use 0. + * @param[in] idx - rule index between 0-15 + * + * @return 0, <0 on error. + */ + sceCtrlClearRapidFire :: proc(port: c.int, idx: c.int) -> c.int --- + + /** + * Control the actuator (vibrate) on paired controllers. + * + * @param[in] port - use 1 for the first paired controller, etc. + * @param[in] state - see ::SceCtrlActuator + * + * @return 0, <0 on error. + */ + sceCtrlSetActuator :: proc(port: c.int, pState: ^SceCtrlActuator) -> c.int --- + + /** + * Control the light bar on paired controllers. + * + * @param[in] port - use 1 for the first paired controller, etc. + * @param[in] r - red intensity + * @param[in] g - green intensity + * @param[in] b - blue intensity + * + * @return 0, <0 on error. + */ + sceCtrlSetLightBar :: proc(port: c.int, r: sce.UInt8, g: sce.UInt8, b: sce.UInt8) -> c.int --- + + /** + * Get controller port information. + * + * @param[out] info - see ::SceCtrlPortInfo + * @return 0, <0 on error + */ + sceCtrlGetControllerPortInfo :: proc(info: ^SceCtrlPortInfo) -> c.int --- + + /** + * Get controller battery information. + * + * @param[in] port - use 1 for the first paired controller, etc. + * @param[out] batt - battery level, between 0-5, 0xEE charging, 0xEF charged + * + * @return 0, <0 on error. + */ + sceCtrlGetBatteryInfo :: proc(port: c.int, batt: ^sce.UInt8) -> c.int --- + + /** + * Sets intercept + * + * If true, allows the current thread to intercept controls. The use case + * might be, for example, a game plugin that wishes to capture input without + * having the input sent to the game thread. + * @param[in] intercept Boolean value + * + * @return 0, < 0 on error + */ + sceCtrlSetButtonIntercept :: proc(intercept: c.int) -> c.int --- + + /** + * Gets intercept + * + * @param[out] intercept Boolean value + * + * @return 0, < 0 on error + */ + sceCtrlGetButtonIntercept :: proc(intercept: ^int) -> c.int --- + + /** + * Check if multi controller is supported + * + * @return 1 if yes, 0 if no + */ + sceCtrlIsMultiControllerSupported :: proc() -> c.int --- +} diff --git a/Ctrl/types.odin b/Ctrl/types.odin new file mode 100644 index 0000000..66a3c6f --- /dev/null +++ b/Ctrl/types.odin @@ -0,0 +1,134 @@ +package ctrl + +import "core:c" + +// TODO: this should be a c.int +SceCtrlErrorCode :: enum i64 { + INVALID_ARG = 0x80340001, + PRIV_REQUIRED = 0x80340002, + NO_DEVICE = 0x80340020, + NOT_SUPPORTED = 0x80340021, + INVALID_MODE = 0x80340022, + FATAL = 0x803400FF, +} + +/** Enumeration for the digital controller buttons. + * @note - L1/R1/L3/R3 only can bind using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2 + * @note - Values bigger than 0x00010000 can be intercepted only with shell privileges + * @note - Vita's L Trigger and R Trigger are mapped to L1 and R1 when using ::sceCtrlPeekBufferPositiveExt2 and ::sceCtrlReadBufferPositiveExt2 + */ +SceCtrlButtons :: enum c.int { + SELECT = 0x00000001, //!< Select button. + L3 = 0x00000002, //!< L3 button. + R3 = 0x00000004, //!< R3 button. + START = 0x00000008, //!< Start button. + UP = 0x00000010, //!< Up D-Pad button. + RIGHT = 0x00000020, //!< Right D-Pad button. + DOWN = 0x00000040, //!< Down D-Pad button. + LEFT = 0x00000080, //!< Left D-Pad button. + LTRIGGER = 0x00000100, //!< Left trigger. + L2 = LTRIGGER, //!< L2 button. + RTRIGGER = 0x00000200, //!< Right trigger. + R2 = RTRIGGER, //!< R2 button. + L1 = 0x00000400, //!< L1 button. + R1 = 0x00000800, //!< R1 button. + TRIANGLE = 0x00001000, //!< Triangle button. + CIRCLE = 0x00002000, //!< Circle button. + CROSS = 0x00004000, //!< Cross button. + SQUARE = 0x00008000, //!< Square button. + INTERCEPTED = 0x00010000, //!< Input not available because intercepted by another application + PSBUTTON = INTERCEPTED, //!< Playstation (Home) button. + HEADPHONE = 0x00080000, //!< Headphone plugged in. + VOLUP = 0x00100000, //!< Volume up button. + VOLDOWN = 0x00200000, //!< Volume down button. + POWER = 0x40000000, //!< Power button. +} + +/** Enumeration for the controller types. */ +SceCtrlExternalInputMode :: enum c.int { + UNPAIRED = 0, //!< Unpaired controller + PHY = 1, //!< Physical controller for VITA + VIRT = 2, //!< Virtual controller for PSTV + DS3 = 4, //!< DualShock 3 + DS4 = 8 //!< DualShock 4 +} + +/** Controller mode. */ +SceCtrlPadInputMode :: enum c.int { + /** Digital buttons only. */ + DIGITAL = 0, + /** Digital buttons + Analog support. */ + ANALOG = 1, + /** Same as ::SCE_CTRL_MODE_ANALOG, but with larger range for analog sticks. */ + ANALOG_WIDE = 2 +} + +/** Returned controller data */ +SceCtrlData :: struct { + /** The current read frame. */ + timeStamp: c.uint64_t, + /** Bit mask containing zero or more of ::SceCtrlButtons. */ + buttons: c.uint, + /** Left analogue stick, X axis. */ + lx: c.uchar, + /** Left analogue stick, Y axis. */ + ly: c.uchar, + /** Right analogue stick, X axis. */ + rx: c.uchar, + /** Right analogue stick, Y axis. */ + ry: c.uchar, + /** Up button */ + up: c.uint8_t, + /** Right button */ + right: c.uint8_t, + /** Down button */ + down: c.uint8_t, + /** Left button */ + left: c.uint8_t, + /** Left trigger (L2) */ + lt: c.uint8_t, + /** Right trigger (R2) */ + rt: c.uint8_t, + /** Left button (L1) */ + l1: c.uint8_t, + /** Right button (R1) */ + r1: c.uint8_t, + /** Triangle button */ + triangle: c.uint8_t, + /** Circle button */ + circle: c.uint8_t, + /** Cross button */ + cross: c.uint8_t, + /** Square button */ + square: c.uint8_t, + /** Reserved. */ + reserved: [4]c.uint8_t, +} +#assert(size_of(SceCtrlData) == 0x20) + +/** Structure to pass as argument to ::sceCtrlSetRapidFire */ +SceCtrlRapidFireRule :: struct { + Mask: c.uint, + Trigger: c.uint, + Target: c.uint, + Delay: c.uint, + Make: c.uint, + Break: c.uint, +} +#assert(size_of(SceCtrlRapidFireRule) == 0x18) + +/** Structure to pass as argument to ::sceCtrlSetActuator */ +SceCtrlActuator :: struct { + small: c.uchar, //!< Vibration strength of the small motor + large: c.uchar, //!< Vibration strength of the large motor + unk: [6]c.uint8_t , //!< Unknown +} +#assert(size_of(SceCtrlActuator) == 8) + +/** Structure to pass as argument to ::sceCtrlGetControllerPortInfo */ +SceCtrlPortInfo :: struct { + port: [5]c.uint8_t, //!< Controller type of each port (See ::SceCtrlExternalInputMode) + unk: [11]c.uint8_t, //!< Unknown +} +#assert(size_of(SceCtrlPortInfo) == 0x10) + diff --git a/Deci4p/Deci4p.odin b/Deci4p/Deci4p.odin new file mode 100644 index 0000000..7042137 --- /dev/null +++ b/Deci4p/Deci4p.odin @@ -0,0 +1,17 @@ +package deci4p + +import sce "../common" + +foreign import deci4p "system:SceDeci4pUserp_stub" + +@(link_prefix="sceKernelDeci4p") +foreign deci4p { + Open :: proc(protoname: cstring, protonum: sce.UInt32, bufsize: sce.Size) -> sce.UID --- + Close :: proc(socketid: sce.UID) -> sce.Int32 --- + DisableWatchpoint :: proc() -> sce.Int32 --- + EnableWatchpoint :: proc() -> sce.Int32 --- + IsProcessAttached :: proc() -> sce.Int32 --- + Read :: proc(socketid: sce.UID, buffer: rawptr, size: sce.Size, reserved: sce.UInt32) -> sce.Int32 --- + RegisterCallback :: proc(socketid: sce.UID, cbid: sce.UID) -> sce.Int32 --- + Write :: proc(socketid: sce.UID, buffer: rawptr, size: sce.Size, reserved: sce.UInt32) -> sce.Int32 --- +} diff --git a/Display/Display.odin b/Display/Display.odin new file mode 100644 index 0000000..54a0d57 --- /dev/null +++ b/Display/Display.odin @@ -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 --- +} diff --git a/Display/types.odin b/Display/types.odin new file mode 100644 index 0000000..163011e --- /dev/null +++ b/Display/types.odin @@ -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) +} + diff --git a/Dmac/Dmac.odin b/Dmac/Dmac.odin new file mode 100644 index 0000000..5add02e --- /dev/null +++ b/Dmac/Dmac.odin @@ -0,0 +1,114 @@ +package dmac + +import "core:c" +import sce "../common" +import "base:intrinsics" + +foreign import dmac "system:SceKernelDmacMgr_stub" +foreign import dmac5 "system:SceSblSsMgr_stub" + +@(link_prefix = "sceDmac") +foreign dmac { + /** + * DMA memcpy + * + * @param[in] dst - Destination + * @param[in] src - Source + * @param[in] size - Size + * + * @return < 0 on error. + */ + Memcpy :: proc(dst: rawptr, src: rawptr, size: sce.Size) -> c.int --- + + /** + * DMA memset + * + * @param[in] dst - Destination + * @param[in] ch - The character + * @param[in] size - Size + * + * @return < 0 on error. + */ + Memset :: proc(dst: rawptr, ch: c.int, size: sce.Size) -> c.int --- +} + +AesCbcEnc :: #force_inline proc(src: rawptr, dst: rawptr, length: sce.Size, key: rawptr, keysize: sce.Size, iv: rawptr) -> c.int { + param := SceSblDmac5EncDecParam{src = src, dst = dst, length = length, key = key, keysize = keysize, iv = iv} + + return EncDec( + ¶m, + 1 | 8 | (((auto_cast keysize << 2) - 0x100) & 0x300) + ) +} + +AesCbcDec :: #force_inline proc(src: rawptr, dst: rawptr, length: sce.Size, key: rawptr, keysize: sce.Size, iv: rawptr) -> c.int { + param := SceSblDmac5EncDecParam{src = src, dst = dst, length = length, key = key, keysize = keysize, iv = iv} + + return EncDec( + ¶m, + 2 | 8 | (((auto_cast keysize << 2) - 0x100) & 0x300) + ) +} + +AesCtrEnc :: #force_inline proc(src: rawptr, dst: rawptr, length: sce.Size, key: rawptr, keysize: sce.Size, iv: rawptr) -> c.int { + param := SceSblDmac5EncDecParam{src = src, dst = dst, length = length, key = key, keysize = keysize, iv = iv} + + return EncDec( + ¶m, + 1 | 0x20 | (((auto_cast keysize << 2) - 0x100) & 0x300) + ) +} + +AesCtrDec :: #force_inline proc(src: rawptr, dst: rawptr, length: sce.Size, key: rawptr, keysize: sce.Size, iv: rawptr) -> c.int { + param := SceSblDmac5EncDecParam{src = src, dst = dst, length = length, key = key, keysize = keysize, iv = iv} + + return EncDec( + ¶m, + 2 | 0x20 | (((auto_cast keysize << 2) - 0x100) & 0x300) + ) +} + +Sha256Digest :: #force_inline proc(src: rawptr, dst: rawptr, length: sce.Size) -> c.int { + ctx: SceSblDmac5HashTransformContext + param := SceSblDmac5HashTransformParam{src = src, dst = dst, length = length, key = c.NULL, keysize = 0, ctx = &ctx} + + ctx.state[0] = auto_cast intrinsics.byte_swap(u32(0x6a09e667)) + ctx.state[1] = auto_cast intrinsics.byte_swap(u32(0xbb67ae85)) + ctx.state[2] = auto_cast intrinsics.byte_swap(u32(0x3c6ef372)) + ctx.state[3] = auto_cast intrinsics.byte_swap(u32(0xa54ff53a)) + ctx.state[4] = auto_cast intrinsics.byte_swap(u32(0x510e527f)) + ctx.state[5] = auto_cast intrinsics.byte_swap(u32(0x9b05688c)) + ctx.state[6] = auto_cast intrinsics.byte_swap(u32(0x1f83d9ab)) + ctx.state[7] = auto_cast intrinsics.byte_swap(u32(0x5be0cd19)) + ctx.length = 0 + + return HashTransform( + ¶m, + 3 | 0x10, 0x800 + ) +} + +@(link_prefix = "sceSblDmac5") +foreign dmac5 { + /** + * @brief Execute DMAC5 encdec command + * + * @param[inout] param - The encdec param. + * @param[in] command - The DMAC5 encdec command. + * + * @return 0 on success, else < 0. + */ + EncDec :: proc(param: ^SceSblDmac5EncDecParam, command: sce.UInt32) -> c.int --- + + + /** + * @brief Execute DMAC5 hash transform command + * + * @param[inout] param - The encdec param. + * @param[in] command - The DMAC5 hash base command. + * @param[in] extra - The DMAC5 extra command. + * + * @return 0 on success, else < 0. + */ + HashTransform :: proc(param: ^SceSblDmac5HashTransformParam, command: sce.UInt32, extra: sce.UInt32) -> c.int --- +} diff --git a/Dmac/types.odin b/Dmac/types.odin new file mode 100644 index 0000000..7773165 --- /dev/null +++ b/Dmac/types.odin @@ -0,0 +1,35 @@ +package dmac + +import "core:c" +import sce "../common" + +SceSblDmac5EncDecParam :: struct { // size is 0x18-bytes + src: rawptr, // sce.Int32 --- + OptParamInitialize :: proc(optParam: ^SceFiberOptParam) -> sce.Int32 --- + Finalize :: proc(fiber: ^SceFiber) -> sce.Int32 --- + Run :: proc(fiber: ^SceFiber, argOnRunTo: sce.UInt32, argOnRun: ^sce.UInt32) -> sce.Int32 --- + Switch :: proc(fiber: ^SceFiber, argOnRunTo: sce.UInt32, argOnRun: ^sce.UInt32) -> sce.Int32 --- + GetSelf :: proc(fiber: SceFiber) -> sce.Int32 --- + ReturnToThread :: proc(argOnReturn: sce.UInt32, argOnRun: ^sce.UInt32) -> sce.Int32 --- + GetInfo :: proc(fiber: ^SceFiber, fiberInfo: ^SceFiberInfo) -> sce.Int32 --- +} + diff --git a/Fiber/types.odin b/Fiber/types.odin new file mode 100644 index 0000000..e06f31e --- /dev/null +++ b/Fiber/types.odin @@ -0,0 +1,44 @@ +package fiber + +import "core:c" +import sce "../common" + +// Error Codes + +// TODO: should be c.int +SceFiberErrorCode :: enum c.uint { + NULL = 0x80590001, + ALIGNMENT = 0x80590002, + RANGE = 0x80590003, + INVALID = 0x80590004, + PERMISSION = 0x80590005, + STATE = 0x80590006, + BUSY = 0x80590007, + AGAIN = 0x80590008, + FATAL = 0x80590009 +} + +SceFiber :: struct #align(8) { + reserved: [128]c.char, +} +#assert(size_of(SceFiber) == 0x80) + +SceFiberOptParam :: struct #align(8) { + reserved: [128]c.char, +} +#assert(size_of(SceFiberOptParam) == 0x80) + +SceFiberEntry :: #type proc(argOnInitialize: sce.UInt32, argOnRun: sce.UInt32) + +SceFiberInfo :: struct #align(8) { + entry: ^SceFiberEntry, + argOnInitialize: sce.UInt32, + addrContext: rawptr, + sizeContext: sce.Size, + name: [32]c.char, + padding: [80]c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceFiberInfo) == 0x170) +} + diff --git a/Fios2/Fios2.odin b/Fios2/Fios2.odin new file mode 100644 index 0000000..87801cc --- /dev/null +++ b/Fios2/Fios2.odin @@ -0,0 +1,37 @@ +package fios2 + +import "core:c" +import sce "../common" + +foreign import fios2 "system:SceFios2Kernel_stub" + +@(link_prefix = "_sceFiosKernelOverlay") +foreign fios2 { + Add :: proc(overlay: ^SceFiosKernelOverlay, out_id: ^SceFiosKernelOverlayID) -> c.int --- + AddForProcess :: proc(target_process: sce.UID, overlay: ^SceFiosKernelOverlay, out_id: ^SceFiosKernelOverlayID) -> c.int --- + DHChstatSync :: proc(dh: SceFiosKernelOverlayDH, new_stat: ^SceFiosNativeStat, cbit: c.uint) -> c.int --- + DHCloseSync :: proc(dh: SceFiosKernelOverlayDH) -> c.int --- + + DHOpenSync :: proc(out_dh: ^SceFiosKernelOverlayDH, path: cstring, from_order: sce.UInt8, args: ^SceFiosDHOpenSyncSyscallArgs) -> c.int --- + DHReadSync :: proc(dh: SceFiosKernelOverlayDH, out_entry: ^SceFiosNativeDirEntry) -> c.int --- + DHStatSync :: proc(dh: SceFiosKernelOverlayDH, out_stat: ^SceFiosNativeStat) -> c.int --- + DHSyncSync :: proc(dh: SceFiosKernelOverlayDH, flag: c.int) -> c.int --- + GetInfo :: proc(id: SceFiosKernelOverlayID, out_overlay: ^SceFiosKernelOverlay) -> c.int --- + GetInfoForProcess :: proc(target_process: sce.UID, id: SceFiosKernelOverlayID, out_overlay: ^SceFiosKernelOverlay) -> c.int --- + + GetList :: proc(pid: sce.UID, min_order: sce.UInt8, max_order: sce.UInt8, args: ^SceFiosGetListSyscallArgs) -> c.int --- + GetRecommendedScheduler :: proc(avail: c.int, partially_resolved_path: cstring, a3: ^sce.UInt64) -> c.int --- + Modify :: proc(id: SceFiosKernelOverlayID, new_value: ^SceFiosKernelOverlay) -> c.int --- + ModifyForProcess :: proc(target_process: sce.UID, id: SceFiosKernelOverlayID, new_value: ^SceFiosKernelOverlay) -> c.int --- + Remove :: proc(id: SceFiosKernelOverlayID) -> c.int --- + RemoveForProcess :: proc(target_process: sce.UID, id: SceFiosKernelOverlayID) -> c.int --- + + ResolveSync :: proc(pid: sce.UID, resolve_flag: c.int, in_path: cstring, args: ^SceFiosResolveSyncSyscallArgs) -> c.int --- + + ResolveWithRangeSync :: proc(pid: sce.UID, resolve_flag: c.int, in_path: cstring, args: ^SceFiosResolveWithRangeSyncSyscallArgs) -> c.int --- + ThreadIsDisabled :: proc() -> c.int --- + ThreadSetDisabled :: proc(disabled: sce.Int32) -> c.int --- + + @(link_name = "sceFiosKernelOverlayAddForProcess02") + AddForProcess02 :: proc(pid: sce.UID, overlay: ^SceFiosOverlay, outID: ^SceFiosOverlayID) -> c.int --- +} diff --git a/Fios2/types.odin b/Fios2/types.odin new file mode 100644 index 0000000..e88802d --- /dev/null +++ b/Fios2/types.odin @@ -0,0 +1,88 @@ +package fios2 + +import "core:c" +import sce "../common" + +SCE_FIOS2_OVERLAY_PATH_SIZE :: (292) +SCE_FIOS2_OVERLAY_PATH_MAX_LENGTH :: (SCE_FIOS2_OVERLAY_PATH_SIZE - 1) + +SceFiosKernelOverlayDH :: c.int32_t +SceFiosKernelOverlayID :: c.int32_t +SceFiosOverlayID :: c.int32_t + +// missing structs +SceFiosKernelOverlay :: struct{} +SceFiosNativeStat :: struct{} +SceFiosNativeDirEntry :: struct{} + +SceFiosDHOpenSyncSyscallArgs :: struct { + to_order: sce.UInt8, + padding: [2]c.int, +} +#assert(size_of(SceFiosDHOpenSyncSyscallArgs) == 0xC) + +SceFiosGetListSyscallArgs :: struct { + out_ids: ^SceFiosKernelOverlayID, + data_0x04: c.int, + data_0x08: c.int, + data_0x0C: sce.Size, + data_0x10: c.int, + data_0x14: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceFiosGetListSyscallArgs) == 0x18) +} + +SceFiosResolveSyncSyscallArgs :: struct { + out_path: cstring, + data_0x04: c.int, + data_0x08: c.int, + data_0x0C: c.int, + data_0x10: c.int, + data_0x14: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceFiosResolveSyncSyscallArgs) == 0x18) +} + +SceFiosResolveWithRangeSyncSyscallArgs :: struct { + out_path: cstring, + data_0x04: c.int, + data_0x08: sce.UInt8, + data_0x09: sce.UInt8, + data_0x0C: c.int, + data_0x10: c.int, + data_0x14: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceFiosResolveWithRangeSyncSyscallArgs) == 0x18) +} + +SceFiosOverlayType :: enum c.int { + // src replaces dst. All accesses to dst are redirected to src. + OPAQUE = 0, + + // src merges with dst. Reads check src first, then dst. Writes go to dst. + TRANSLUCENT = 1, + + // src merges with dst. Reads check both src and dst, and use whichever has the most recent modification time. + // If both src and dst have the same modification time, dst is used. + // If no file exists at src or dst, dst is used; if no file exists at dst, but a file exists at src, src is used. Writes go to dst. + NEWER = 2, + + // src merges with dst. Reads check src first, then dst. Writes go to src. + WRITABLE = 3 +} + +SceFiosOverlay :: struct { + type: c.uint8_t, // see SceFiosOverlayType + order: c.uint8_t, + dst_len: c.uint16_t, + src_len: c.uint16_t, + unk2: c.uint16_t, + pid: sce.UID, + id: SceFiosOverlayID, + dst: [SCE_FIOS2_OVERLAY_PATH_SIZE]c.char, + src: [SCE_FIOS2_OVERLAY_PATH_SIZE]c.char, // src path replaces dst path based on type policy +} +#assert(size_of(SceFiosOverlay) == 0x258) diff --git a/Gps/Gps.odin b/Gps/Gps.odin new file mode 100644 index 0000000..dff1e88 --- /dev/null +++ b/Gps/Gps.odin @@ -0,0 +1,27 @@ +package gps + +import "core:c" +import sce "../common" + +foreign import gps "system:SceGps_stub" + +// missing structs +SceGpsDeviceInfo :: struct{} +SceGpsSatelliteData :: struct{} +SceGpsPositionData :: struct{} +SceGpsStatus :: struct{} + +@(link_prefix = "_sceGps") +foreign gps { + Close :: proc() -> c.int --- + GetData :: proc(pos: ^SceGpsPositionData, sat: ^SceGpsSatelliteData) -> c.int --- + GetDeviceInfo :: proc(dev_info: ^SceGpsDeviceInfo) -> c.int --- + GetState :: proc(state: ^SceGpsStatus) -> c.int --- + Ioctl :: proc(ioctl_command: sce.UInt32, arg: rawptr, arg_size: sce.Size, a4: ^sce.Size) -> c.int --- + IsDevice :: proc() -> c.int --- + Open :: proc(cbid: sce.UID) -> c.int --- + ResumeCallback :: proc() -> c.int --- + SelectDevice :: proc(device_type: sce.UInt32) -> c.int --- + Start :: proc(mode: c.uint) -> c.int --- + Stop :: proc() -> c.int --- +} diff --git a/Gxm/Gxm.odin b/Gxm/Gxm.odin new file mode 100644 index 0000000..a9030e1 --- /dev/null +++ b/Gxm/Gxm.odin @@ -0,0 +1,306 @@ +package gxm + +import "core:c" +import "base:intrinsics" +import sce "../common" + +foreign import gxm "system:SceGxm_stub" + +/** + * Gets the start address of the texture data. + * + * @param gxt pointer to the GXT data + * @return A pointer to the start of the texture data + */ +sceGxtGetDataAddress :: proc(gxt: rawptr) -> rawptr { + header := cast(^SceGxtHeader)gxt + return cast(rawptr)((cast(uintptr)gxt) + auto_cast header.dataOffset) +} + + +@(link_prefix = "sceGxm") +foreign gxm { + Initialize :: proc(params: ^SceGxmInitializeParams) -> c.int --- + VshInitialize :: proc(params: ^SceGxmInitializeParams) -> c.int --- + Terminate :: proc() -> c.int --- + + GetNotificationRegion :: proc() -> ^c.uint --- + NotificationWait :: proc(notification: ^SceGxmNotification) -> c.int --- + + MapMemory :: proc(base: rawptr, size: sce.Size, attr: SceGxmMemoryAttribFlags) -> c.int --- + UnmapMemory :: proc(base: rawptr) -> c.int --- + + MapVertexUsseMemory :: proc(base: rawptr, size: sce.Size, offset: ^c.uint) -> c.int --- + UnmapVertexUsseMemory :: proc(base: rawptr) -> c.int --- + + MapFragmentUsseMemory :: proc(base: rawptr, size: sce.Size, offset: ^c.uint) -> c.int --- + UnmapFragmentUsseMemory :: proc(base: rawptr) -> c.int --- + + DisplayQueueAddEntry :: proc(oldBuffer: ^SceGxmSyncObject, newBuffer: ^SceGxmSyncObject, callbackData: rawptr) -> c.int --- + DisplayQueueFinish :: proc() -> c.int --- + + SyncObjectCreate :: proc(syncObject: ^^SceGxmSyncObject) -> c.int --- + SyncObjectDestroy :: proc(syncObject: ^SceGxmSyncObject) -> c.int --- + + CreateContext :: proc(params: ^SceGxmContextParams, _context: ^^SceGxmContext) -> c.int --- + DestroyContext :: proc(_context: ^SceGxmContext) -> c.int --- + + CreateDeferredContext :: proc(params: ^SceGxmDeferredContextParams, _context: ^^SceGxmContext) -> c.int --- + DestroyDeferredContext :: proc(_context: ^SceGxmContext) -> c.int --- + + SetValidationEnable :: proc(_context: ^SceGxmContext, enable: sce.Bool) --- + + SetVertexProgram :: proc(_context: ^SceGxmContext, vertexProgram: ^SceGxmVertexProgram) --- + SetFragmentProgram :: proc(_context: ^SceGxmContext, fragmentProgram: ^SceGxmFragmentProgram) --- + + ReserveVertexDefaultUniformBuffer :: proc(_context: ^SceGxmContext, uniformBuffer: ^rawptr) -> c.int --- + ReserveFragmentDefaultUniformBuffer :: proc(_context: ^SceGxmContext, uniformBuffer: ^rawptr) -> c.int --- + + SetVertexDefaultUniformBuffer :: proc(_context: ^SceGxmContext, uniformBuffer: rawptr) -> c.int --- + SetFragmentDefaultUniformBuffer :: proc(_context: ^SceGxmContext, uniformBuffer: rawptr) -> c.int --- + + SetVertexStream :: proc(_context: ^SceGxmContext, streamIndex: c.uint, streamData: rawptr) -> c.int --- + SetVertexTexture :: proc(_context: ^SceGxmContext, textureIndex: c.uint, texture: ^SceGxmTexture) -> c.int --- + SetFragmentTexture :: proc(_context: ^SceGxmContext, textureIndex: c.uint, texture: ^SceGxmTexture) -> c.int --- + SetVertexUniformBuffer :: proc(_context: ^SceGxmContext, bufferIndex: c.uint, bufferData: rawptr) -> c.int --- + SetFragmentUniformBuffer :: proc(_context: ^SceGxmContext, bufferIndex: c.uint, bufferData: rawptr) -> c.int --- + SetAuxiliarySurface :: proc(_context: ^SceGxmContext, surfaceIndex: c.uint, surface: ^SceGxmAuxiliarySurface) -> c.int --- + + SetPrecomputedFragmentState :: proc(_context: ^SceGxmContext, precomputedState: ^SceGxmPrecomputedFragmentState) --- + SetPrecomputedVertexState :: proc(_context: ^SceGxmContext, precomputedState: ^SceGxmPrecomputedVertexState) --- + + DrawPrecomputed :: proc(_context: ^SceGxmContext, precomputedDraw: ^SceGxmPrecomputedDraw) -> c.int --- + Draw :: proc(_context: ^SceGxmContext, primType: SceGxmPrimitiveType, indexType: SceGxmIndexFormat, indexData: rawptr, indexCount: c.uint) -> c.int --- + DrawInstanced :: proc(_context: ^SceGxmContext, primType: SceGxmPrimitiveType, indexType: SceGxmIndexFormat, indexData: rawptr, indexCount: c.uint, indexWrap: c.uint) -> c.int --- + SetVisibilityBuffer :: proc(_context: ^SceGxmContext, bufferBase: rawptr, stridePerCore: c.uint) -> c.int --- + + BeginScene :: proc(_context: ^SceGxmContext, flags: c.uint, renderTarget: ^SceGxmRenderTarget, validRegion: ^SceGxmValidRegion, vertexSyncObject: ^SceGxmSyncObject, fragmentSyncObject: ^SceGxmSyncObject, colorSurface: ^SceGxmColorSurface, depthStencil: ^SceGxmDepthStencilSurface) -> c.int --- + MidSceneFlush :: proc(_context: ^SceGxmContext, flags: c.uint, vertexSyncObject: ^SceGxmSyncObject, vertexNotification: ^SceGxmNotification) -> c.int --- + EndScene :: proc(_context: ^SceGxmContext, vertexNotification: ^SceGxmNotification, fragmentNotification: ^SceGxmNotification) -> c.int --- + + BeginCommandList :: proc(_context: ^SceGxmContext) -> c.int --- + ExecuteCommandList :: proc(_context: ^SceGxmContext, list: ^SceGxmCommandList) -> c.int --- + EndCommandList :: proc(_context: ^SceGxmContext, list: ^SceGxmCommandList) -> c.int --- + + SetFrontDepthFunc :: proc(_context: ^SceGxmContext, depthFunc: SceGxmDepthFunc) --- + SetBackDepthFunc :: proc(_context: ^SceGxmContext, depthFunc: SceGxmDepthFunc) --- + SetFrontFragmentProgramEnable :: proc(_context: ^SceGxmContext, enable: SceGxmFragmentProgramMode) --- + SetBackFragmentProgramEnable :: proc(_context: ^SceGxmContext, enable: SceGxmFragmentProgramMode) --- + SetFrontDepthWriteEnable :: proc(_context: ^SceGxmContext, enable: SceGxmDepthWriteMode) --- + SetBackDepthWriteEnable :: proc(_context: ^SceGxmContext, enable: SceGxmDepthWriteMode) --- + SetFrontLineFillLastPixelEnable :: proc(_context: ^SceGxmContext, enable: SceGxmLineFillLastPixelMode) --- + SetBackLineFillLastPixelEnable :: proc(_context: ^SceGxmContext, enable: SceGxmLineFillLastPixelMode) --- + SetFrontStencilRef :: proc(_context: ^SceGxmContext, sref: c.uint) --- + SetBackStencilRef :: proc(_context: ^SceGxmContext, sref: c.uint) --- + SetFrontPointLineWidth :: proc(_context: ^SceGxmContext, width: c.uint) --- + SetBackPointLineWidth :: proc(_context: ^SceGxmContext, width: c.uint) --- + SetFrontPolygonMode :: proc(_context: ^SceGxmContext, mode: SceGxmPolygonMode) --- + SetBackPolygonMode :: proc(_context: ^SceGxmContext, mode: SceGxmPolygonMode) --- + SetFrontStencilFunc :: proc(_context: ^SceGxmContext, func: SceGxmStencilFunc, stencilFail: SceGxmStencilOp, depthFail: SceGxmStencilOp, depthPass: SceGxmStencilOp, compareMask: c.uchar, writeMask: c.uchar) --- + SetBackStencilFunc :: proc(_context: ^SceGxmContext, func: SceGxmStencilFunc, stencilFail: SceGxmStencilOp, depthFail: SceGxmStencilOp, depthPass: SceGxmStencilOp, compareMask: c.uchar, writeMask: c.uchar) --- + SetFrontDepthBias :: proc(_context: ^SceGxmContext, factor: c.int, units: c.int) --- + SetBackDepthBias :: proc(_context: ^SceGxmContext, factor: c.int, units: c.int) --- + SetTwoSidedEnable :: proc(_context: ^SceGxmContext, enable: SceGxmTwoSidedMode) --- + SetViewport :: proc(_context: ^SceGxmContext, xOffset: c.float, xScale: c.float, yOffset: c.float, yScale: c.float, zOffset: c.float, zScale: c.float) --- + SetWClampValue :: proc(_context: ^SceGxmContext, clampValue: c.float) --- + SetWClampEnable :: proc(_context: ^SceGxmContext, enable: SceGxmWClampMode) --- + SetRegionClip :: proc(_context: ^SceGxmContext, mode: SceGxmRegionClipMode, xMin: c.uint, yMin: c.uint, xMax: c.uint, yMax: c.uint) --- + SetDefaultRegionClipAndViewport :: proc(_context: ^SceGxmContext, xMax: c.uint, yMax: c.uint) --- + SetCullMode :: proc(_context: ^SceGxmContext, mode: SceGxmCullMode) --- + SetViewportEnable :: proc(_context: ^SceGxmContext, enable: SceGxmViewportMode) --- + SetWBufferEnable :: proc(_context: ^SceGxmContext, enable: SceGxmWBufferMode) --- + SetFrontVisibilityTestIndex :: proc(_context: ^SceGxmContext, index: c.uint) --- + SetBackVisibilityTestIndex :: proc(_context: ^SceGxmContext, index: c.uint) --- + SetFrontVisibilityTestOp :: proc(_context: ^SceGxmContext, op: SceGxmVisibilityTestOp) --- + SetBackVisibilityTestOp :: proc(_context: ^SceGxmContext, op: SceGxmVisibilityTestOp) --- + SetFrontVisibilityTestEnable :: proc(_context: ^SceGxmContext, enable: SceGxmVisibilityTestMode) --- + SetBackVisibilityTestEnable :: proc(_context: ^SceGxmContext, enable: SceGxmVisibilityTestMode) --- + + SetYuvProfile :: proc(_context: ^SceGxmContext, index: c.uint, profile: SceGxmYuvProfile ) -> c.int --- + + Finish :: proc(_context: ^SceGxmContext) --- + + PushUserMarker :: proc(_context: ^SceGxmContext, tag: cstring) -> c.int --- + PopUserMarker :: proc(_context: ^SceGxmContext) -> c.int --- + SetUserMarker :: proc(_context: ^SceGxmContext, tag: cstring) -> c.int --- + + PadHeartbeat :: proc(displaySurface: ^SceGxmColorSurface, displaySyncObject: ^SceGxmSyncObject) -> c.int --- + + PadTriggerGpuPaTrace :: proc() -> c.int --- + + ColorSurfaceInit :: proc(surface: ^SceGxmColorSurface, colorFormat: SceGxmColorFormat, surfaceType: SceGxmColorSurfaceType, scaleMode: SceGxmColorSurfaceScaleMode, outputRegisterSize: SceGxmOutputRegisterSize, width: c.uint, height: c.uint, strideInPixels: c.uint, data: rawptr) -> c.int --- + ColorSurfaceInitDisabled :: proc(surface: ^SceGxmColorSurface) -> c.int --- + ColorSurfaceIsEnabled :: proc(surface: ^SceGxmColorSurface) -> sce.Bool --- + ColorSurfaceGetClip :: proc(surface: ^SceGxmColorSurface, xMin: ^c.uint, yMin: ^c.uint, xMax: ^c.uint, yMax: ^c.uint) --- + ColorSurfaceSetClip :: proc(surface: ^SceGxmColorSurface, xMin: c.uint, yMin: c.uint, xMax: c.uint, yMax: c.uint) --- + + ColorSurfaceGetScaleMode :: proc(surface: ^SceGxmColorSurface) -> SceGxmColorSurfaceScaleMode --- + ColorSurfaceSetScaleMode :: proc(surface: ^SceGxmColorSurface, scaleMode: SceGxmColorSurfaceScaleMode) --- + + ColorSurfaceGetData :: proc(surface: ^SceGxmColorSurface) -> rawptr --- + ColorSurfaceSetData :: proc(surface: ^SceGxmColorSurface, data: rawptr) -> c.int --- + + ColorSurfaceGetFormat :: proc(surface: ^SceGxmColorSurface) -> SceGxmColorFormat --- + ColorSurfaceSetFormat :: proc(surface: ^SceGxmColorSurface, format: SceGxmColorFormat) -> c.int --- + ColorSurfaceGetType :: proc(surface: ^SceGxmColorSurface) -> SceGxmColorSurfaceType --- + ColorSurfaceGetStrideInPixels :: proc(surface: ^SceGxmColorSurface) -> c.uint --- + + DepthStencilSurfaceInit :: proc(surface: ^SceGxmDepthStencilSurface, depthStencilFormat: SceGxmDepthStencilFormat, surfaceType: SceGxmDepthStencilSurfaceType, strideInSamples: c.uint, depthData: rawptr, stencilData: rawptr) -> c.int --- + DepthStencilSurfaceInitDisabled :: proc(surface: ^SceGxmDepthStencilSurface) -> c.int --- + DepthStencilSurfaceGetBackgroundDepth :: proc(surface: ^SceGxmDepthStencilSurface) -> c.float --- + DepthStencilSurfaceSetBackgroundDepth :: proc(surface: ^SceGxmDepthStencilSurface, backgroundDepth: c.float) --- + DepthStencilSurfaceGetBackgroundStencil :: proc(surface: ^SceGxmDepthStencilSurface) -> c.uchar --- + DepthStencilSurfaceSetBackgroundStencil :: proc(surface: ^SceGxmDepthStencilSurface, backgroundStencil: c.uchar) --- + DepthStencilSurfaceIsEnabled :: proc(surface: ^SceGxmDepthStencilSurface) -> sce.Bool --- + DepthStencilSurfaceSetForceLoadMode :: proc(surface: ^SceGxmDepthStencilSurface, forceLoad: SceGxmDepthStencilForceLoadMode) --- + DepthStencilSurfaceGetForceLoadMode :: proc(surface: ^SceGxmDepthStencilSurface) -> SceGxmDepthStencilForceLoadMode --- + DepthStencilSurfaceSetForceStoreMode :: proc(surface: ^SceGxmDepthStencilSurface, forceStore: SceGxmDepthStencilForceStoreMode ) --- + DepthStencilSurfaceGetForceStoreMode :: proc(surface: ^SceGxmDepthStencilSurface) -> SceGxmDepthStencilForceStoreMode --- + + ColorSurfaceGetGammaMode :: proc(surface: ^SceGxmColorSurface) -> SceGxmColorSurfaceGammaMode --- + ColorSurfaceSetGammaMode :: proc(surface: ^SceGxmColorSurface, gammaMode: SceGxmColorSurfaceGammaMode) -> c.int --- + ColorSurfaceGetDitherMode :: proc(surface: ^SceGxmColorSurface) -> SceGxmColorSurfaceDitherMode --- + ColorSurfaceSetDitherMode :: proc(surface: ^SceGxmColorSurface, ditherMode: SceGxmColorSurfaceDitherMode) -> c.int --- + + DepthStencilSurfaceGetFormat :: proc(surface: ^SceGxmDepthStencilSurface) -> SceGxmDepthStencilFormat --- + DepthStencilSurfaceGetStrideInSamples :: proc(surface: ^SceGxmDepthStencilSurface) -> c.uint --- + + ProgramCheck :: proc(program: ^SceGxmProgram) -> c.int --- + ProgramGetSize :: proc(program: ^SceGxmProgram) -> c.uint --- + ProgramGetType :: proc(program: ^SceGxmProgram) -> SceGxmProgramType --- + ProgramIsDiscardUsed :: proc(program: ^SceGxmProgram) -> sce.Bool --- + ProgramIsDepthReplaceUsed :: proc(program: ^SceGxmProgram) -> sce.Bool --- + ProgramIsSpriteCoordUsed :: proc(program: ^SceGxmProgram) -> sce.Bool --- + ProgramGetDefaultUniformBufferSize :: proc(program: ^SceGxmProgram) -> c.uint --- + ProgramGetParameterCount :: proc(program: ^SceGxmProgram) -> c.uint --- + + ProgramGetParameter :: proc(program: ^SceGxmProgram, index: c.uint) -> ^SceGxmProgramParameter --- + ProgramFindParameterByName :: proc(program: ^SceGxmProgram, name: cstring) -> ^SceGxmProgramParameter --- + ProgramFindParameterBySemantic :: proc(program: ^SceGxmProgram, semantic: SceGxmParameterSemantic, index: c.uint) -> ^SceGxmProgramParameter --- + ProgramParameterGetIndex :: proc(program: ^SceGxmProgram, parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterGetCategory :: proc(parameter: ^SceGxmProgramParameter) -> SceGxmParameterCategory --- + ProgramParameterGetName :: proc(parameter: ^SceGxmProgramParameter) -> cstring --- + ProgramParameterGetSemantic :: proc(parameter: ^SceGxmProgramParameter) -> SceGxmParameterSemantic --- + ProgramParameterGetSemanticIndex :: proc(parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterGetType :: proc(parameter: ^SceGxmProgramParameter) -> SceGxmParameterType --- + ProgramParameterGetComponentCount :: proc(parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterGetArraySize :: proc(parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterGetResourceIndex :: proc(parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterGetContainerIndex :: proc( parameter: ^SceGxmProgramParameter) -> c.uint --- + ProgramParameterIsSamplerCube :: proc(parameter: ^SceGxmProgramParameter) -> sce.Bool --- + + FragmentProgramGetProgram :: proc(fragmentProgram: ^SceGxmFragmentProgram) -> ^SceGxmProgram --- + VertexProgramGetProgram :: proc(vertexProgram: ^SceGxmVertexProgram) -> ^SceGxmProgram --- + + ShaderPatcherCreate :: proc(params: ^SceGxmShaderPatcherParams, shaderPatcher: ^^SceGxmShaderPatcher) -> c.int --- + ShaderPatcherSetUserData :: proc(shaderPatcher: ^SceGxmShaderPatcher, userData: rawptr) -> c.int --- + ShaderPatcherGetUserData :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> rawptr --- + ShaderPatcherDestroy :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> c.int --- + ShaderPatcherRegisterProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, programHeader: ^SceGxmProgram, programId: ^SceGxmShaderPatcherId) -> c.int --- + ShaderPatcherUnregisterProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, programId: SceGxmShaderPatcherId) -> c.int --- + ShaderPatcherForceUnregisterProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, programId: SceGxmShaderPatcherId) -> c.int --- + ShaderPatcherGetProgramFromId :: proc(programId: SceGxmShaderPatcherId) -> ^SceGxmProgram --- + ShaderPatcherSetAuxiliarySurface :: proc(shaderPatcher: ^SceGxmShaderPatcher, auxSurfaceIndex: c.uint, auxSurface: ^SceGxmAuxiliarySurface) -> c.int --- + ShaderPatcherCreateVertexProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, programId: SceGxmShaderPatcherId, attributes: ^SceGxmVertexAttribute, attributeCount: c.uint, streams: ^SceGxmVertexStream, streamCount: c.uint, vertexProgram: ^^SceGxmVertexProgram) -> c.int --- + ShaderPatcherCreateFragmentProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, programId: SceGxmShaderPatcherId, outputFormat: SceGxmOutputRegisterFormat, multisampleMode: SceGxmMultisampleMode, blendInfo: ^SceGxmBlendInfo, vertexProgram: ^SceGxmProgram, fragmentProgram: ^^SceGxmFragmentProgram) -> c.int --- + ShaderPatcherCreateMaskUpdateFragmentProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, fragmentProgram: ^^SceGxmFragmentProgram) -> c.int --- + ShaderPatcherAddRefVertexProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, vertexProgram: ^SceGxmVertexProgram) -> c.int --- + ShaderPatcherAddRefFragmentProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, fragmentProgram: ^SceGxmFragmentProgram) -> c.int --- + ShaderPatcherGetVertexProgramRefCount :: proc(shaderPatcher: ^SceGxmShaderPatcher, fragmentProgram: ^SceGxmVertexProgram, count: ^c.uint) -> c.int --- + ShaderPatcherGetFragmentProgramRefCount :: proc(shaderPatcher: ^SceGxmShaderPatcher, fragmentProgram: ^SceGxmFragmentProgram, count: ^c.uint) -> c.int --- + ShaderPatcherReleaseVertexProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, vertexProgram: ^SceGxmVertexProgram) -> c.int --- + ShaderPatcherReleaseFragmentProgram :: proc(shaderPatcher: ^SceGxmShaderPatcher, fragmentProgram: ^SceGxmFragmentProgram) -> c.int --- + ShaderPatcherGetHostMemAllocated :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> c.uint --- + ShaderPatcherGetBufferMemAllocated :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> c.uint --- + ShaderPatcherGetVertexUsseMemAllocated :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> c.uint --- + ShaderPatcherGetFragmentUsseMemAllocated :: proc(shaderPatcher: ^SceGxmShaderPatcher) -> c.uint --- + + TextureInitSwizzled :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, mipCount: c.uint) -> c.int --- + TextureInitSwizzledArbitrary :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, mipCount: c.uint) -> c.int --- + TextureInitLinear :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, mipCount: c.uint) -> c.int --- + TextureInitLinearStrided :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, byteStride: c.uint) -> c.int --- + TextureInitTiled :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, mipCount: c.uint) -> c.int --- + TextureInitCube :: proc(texture: ^SceGxmTexture, data: rawptr, texFormat: SceGxmTextureFormat, width: c.uint, height: c.uint, mipCount: c.uint) -> c.int --- + + TextureGetType :: proc(texture: ^SceGxmTexture) -> SceGxmTextureType --- + TextureValidate :: proc(texture: ^SceGxmTexture) -> c.int --- + + TextureSetMinFilter :: proc(texture: ^SceGxmTexture, minFilter: SceGxmTextureFilter) -> c.int --- + TextureGetMinFilter :: proc(texture: ^SceGxmTexture) -> SceGxmTextureFilter --- + + TextureSetMagFilter :: proc(texture: ^SceGxmTexture, magFilter: SceGxmTextureFilter) -> c.int --- + TextureGetMagFilter :: proc(texture: ^SceGxmTexture) -> SceGxmTextureFilter --- + + TextureSetMipFilter :: proc(texture: ^SceGxmTexture, mipFilter: SceGxmTextureMipFilter) -> c.int --- + TextureGetMipFilter :: proc(texture: ^SceGxmTexture) -> SceGxmTextureMipFilter --- + + TextureSetUAddrMode :: proc(texture: ^SceGxmTexture, addrMode: SceGxmTextureAddrMode) -> c.int --- + TextureGetUAddrMode :: proc(texture: ^SceGxmTexture) -> SceGxmTextureAddrMode --- + + TextureSetVAddrMode :: proc(texture: ^SceGxmTexture, addrMode: SceGxmTextureAddrMode) -> c.int --- + TextureGetVAddrMode :: proc(texture: ^SceGxmTexture) -> SceGxmTextureAddrMode --- + + TextureSetFormat :: proc(texture: ^SceGxmTexture, texFormat: SceGxmTextureFormat ) -> c.int --- + TextureGetFormat :: proc( texture: ^SceGxmTexture) -> SceGxmTextureFormat --- + + TextureSetLodBias :: proc(texture: ^SceGxmTexture, bias: c.uint) -> c.int --- + TextureGetLodBias :: proc( texture: ^SceGxmTexture) -> c.uint --- + + TextureSetStride :: proc(texture: ^SceGxmTexture, byteStride: c.uint) -> c.int --- + TextureGetStride :: proc( texture: ^SceGxmTexture) -> c.uint --- + + TextureSetWidth :: proc(texture: ^SceGxmTexture, width: c.uint) -> c.int --- + TextureGetWidth :: proc( texture: ^SceGxmTexture) -> c.uint --- + + TextureSetHeight :: proc(texture: ^SceGxmTexture, height: c.uint) -> c.int --- + TextureGetHeight :: proc( texture: ^SceGxmTexture) -> c.uint --- + + TextureSetData :: proc(texture: ^SceGxmTexture, data: rawptr) -> c.int --- + TextureGetData :: proc( texture: ^SceGxmTexture) -> rawptr --- + + TextureSetMipmapCount :: proc(texture: ^SceGxmTexture, mipCount: c.uint) -> c.int --- + TextureGetMipmapCount :: proc( texture: ^SceGxmTexture) -> c.uint --- + + TextureSetPalette :: proc(texture: ^SceGxmTexture, paletteData: rawptr) -> c.int --- + TextureGetPalette :: proc( texture: ^SceGxmTexture) -> rawptr --- + + TextureGetGammaMode :: proc( texture: ^SceGxmTexture) -> SceGxmTextureGammaMode --- + TextureSetGammaMode :: proc(texture: ^SceGxmTexture, gammaMode: SceGxmTextureGammaMode) -> c.int --- + + GetPrecomputedVertexStateSize :: proc( vertexProgram: ^SceGxmVertexProgram) -> c.uint --- + PrecomputedVertexStateInit :: proc(precomputedState: ^SceGxmPrecomputedVertexState, vertexProgram: ^SceGxmVertexProgram, memBlock: rawptr) -> c.int --- + PrecomputedVertexStateSetDefaultUniformBuffer :: proc(precomputedState: ^SceGxmPrecomputedVertexState, defaultBuffer: rawptr) --- + PrecomputedVertexStateGetDefaultUniformBuffer :: proc( precomputedState: ^SceGxmPrecomputedVertexState) -> rawptr --- + PrecomputedVertexStateSetAllTextures :: proc(precomputedState: ^SceGxmPrecomputedVertexState, textures: ^SceGxmTexture) -> c.int --- + PrecomputedVertexStateSetTexture :: proc(precomputedState: ^SceGxmPrecomputedVertexState, textureIndex: c.uint, texture: ^SceGxmTexture) -> c.int --- + PrecomputedVertexStateSetAllUniformBuffers :: proc(precomputedState: ^SceGxmPrecomputedVertexState, bufferDataArray: ^rawptr) -> c.int --- + PrecomputedVertexStateSetUniformBuffer :: proc(precomputedState: ^SceGxmPrecomputedVertexState, bufferIndex: c.uint, bufferData: rawptr) -> c.int --- + GetPrecomputedFragmentStateSize :: proc(fragmentProgram: ^SceGxmFragmentProgram) -> c.uint --- + PrecomputedFragmentStateInit :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, fragmentProgram: ^SceGxmFragmentProgram, memBlock: rawptr) -> c.int --- + PrecomputedFragmentStateSetDefaultUniformBuffer :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, defaultBuffer: rawptr) --- + PrecomputedFragmentStateGetDefaultUniformBuffer :: proc(precomputedState: ^SceGxmPrecomputedFragmentState) -> rawptr --- + PrecomputedFragmentStateSetAllTextures :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, textureArray: [^]SceGxmTexture) -> c.int --- + PrecomputedFragmentStateSetTexture :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, textureIndex: c.uint, texture: ^SceGxmTexture) -> c.int --- + PrecomputedFragmentStateSetAllUniformBuffers :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, bufferDataArray: ^rawptr) -> c.int --- + PrecomputedFragmentStateSetUniformBuffer :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, bufferIndex: c.uint, bufferData: rawptr) -> c.int --- + PrecomputedFragmentStateSetAllAuxiliarySurfaces :: proc(precomputedState: ^SceGxmPrecomputedFragmentState, auxSurfaceArray: ^SceGxmAuxiliarySurface) -> c.int --- + GetPrecomputedDrawSize :: proc( vertexProgram: ^SceGxmVertexProgram) -> c.uint --- + PrecomputedDrawInit :: proc(precomputedDraw: ^SceGxmPrecomputedDraw, vertexProgram: ^SceGxmVertexProgram, memBlock: rawptr) -> c.int --- + PrecomputedDrawSetAllVertexStreams :: proc(precomputedDraw: ^SceGxmPrecomputedDraw, streamDataArray: ^rawptr) -> c.int --- + PrecomputedDrawSetVertexStream :: proc(precomputedDraw: ^SceGxmPrecomputedDraw, streamIndex: c.uint, streamData: rawptr) -> c.int --- + PrecomputedDrawSetParams :: proc(precomputedDraw: ^SceGxmPrecomputedDraw, primType: SceGxmPrimitiveType, indexType: SceGxmIndexFormat, indexData: rawptr, indexCount: c.uint) --- + PrecomputedDrawSetParamsInstanced :: proc(precomputedDraw: ^SceGxmPrecomputedDraw, primType: SceGxmPrimitiveType, indexType: SceGxmIndexFormat, indexData: rawptr, indexCount: c.uint, indexWrap: c.uint) --- + + GetRenderTargetMemSize :: proc(params: ^SceGxmRenderTargetParams, driverMemSize: ^c.uint) -> c.int --- + CreateRenderTarget :: proc(params: ^SceGxmRenderTargetParams, renderTarget: ^^SceGxmRenderTarget) -> c.int --- + RenderTargetGetHostMem :: proc(renderTarget: ^SceGxmRenderTarget, hostMem: ^rawptr) -> c.int --- + RenderTargetGetDriverMemBlock :: proc(renderTarget: ^SceGxmRenderTarget, driverMemBlock: ^sce.UID) -> c.int --- + DestroyRenderTarget :: proc(renderTarget: ^SceGxmRenderTarget) -> c.int --- + + SetUniformDataF :: proc(uniformBuffer: rawptr, parameter: ^SceGxmProgramParameter, componentOffset: c.uint, componentCount: c.uint, sourceData: ^c.float) -> c.int --- + + TransferCopy :: proc(width: c.uint32_t, height: c.uint32_t, colorKeyValue: c.uint32_t, colorKeyMask: c.uint32_t, colorKeyMode: SceGxmTransferColorKeyMode, srcFormat: SceGxmTransferFormat, srcType: SceGxmTransferType, srcAddress: rawptr, srcX: c.uint32_t, srcY: c.uint32_t, srcStride: c.int32_t, destFormat: SceGxmTransferFormat, destType: SceGxmTransferType, destAddress: rawptr, destX: c.uint32_t, destY: c.uint32_t, destStride: c.int32_t, syncObject: ^SceGxmSyncObject, syncFlags: c.uint32_t, notification: ^SceGxmNotification) -> c.int --- + TransferDownscale :: proc(srcFormat: SceGxmTransferFormat, srcAddress: rawptr, srcX: c.uint, srcY: c.uint, srcWidth: c.uint, srcHeight: c.uint, srcStride: c.int, destFormat: SceGxmTransferFormat, destAddress: rawptr, destX: c.uint, destY: c.uint, destStride: c.int, syncObject: ^SceGxmSyncObject, syncFlags: c.uint, notification: ^SceGxmNotification) -> c.int --- + TransferFill :: proc(color: c.uint32_t, destFormat: SceGxmTransferFormat, destAddress: rawptr, destX: c.uint32_t, destY: c.uint32_t, destWidth: c.uint32_t, destHeight: c.uint32_t, destStride: c.int32_t, syncObject: ^SceGxmSyncObject, syncFlags: c.uint32_t, notification: ^SceGxmNotification) -> c.int --- + TransferFinish :: proc() -> c.int --- +} diff --git a/Gxm/types.odin b/Gxm/types.odin new file mode 100644 index 0000000..e6aa55e --- /dev/null +++ b/Gxm/types.odin @@ -0,0 +1,1429 @@ +package gxm + +import "core:c" +import sce "../common" + +// Error Codes + +// TODO: should be c.int +SceGxmErrorCode :: enum i64 { + UNINITIALIZED = 0x805B0000, + ALREADY_INITIALIZED = 0x805B0001, + OUT_OF_MEMORY = 0x805B0002, + INVALID_VALUE = 0x805B0003, + INVALID_POINTER = 0x805B0004, + INVALID_ALIGNMENT = 0x805B0005, + NOT_WITHIN_SCENE = 0x805B0006, + WITHIN_SCENE = 0x805B0007, + NULL_PROGRAM = 0x805B0008, + UNSUPPORTED = 0x805B0009, + PATCHER_INTERNAL = 0x805B000A, + RESERVE_FAILED = 0x805B000B, + PROGRAM_IN_USE = 0x805B000C, + INVALID_INDEX_COUNT = 0x805B000D, + INVALID_POLYGON_MODE = 0x805B000E, + INVALID_SAMPLER_RESULT_TYPE_PRECISION = 0x805B000F, + INVALID_SAMPLER_RESULT_TYPE_COMPONENT_COUNT = 0x805B0010, + UNIFORM_BUFFER_NOT_RESERVED = 0x805B0011, + INVALID_AUXILIARY_SURFACE = 0x805B0013, + INVALID_PRECOMPUTED_DRAW = 0x805B0014, + INVALID_PRECOMPUTED_VERTEX_STATE = 0x805B0015, + INVALID_PRECOMPUTED_FRAGMENT_STATE = 0x805B0016, + DRIVER = 0x805B0017, + INVALID_TEXTURE = 0x805B0018, + INVALID_TEXTURE_DATA_POINTER = 0x805B0019, + INVALID_TEXTURE_PALETTE_POINTER = 0x805B001A, + OUT_OF_RENDER_TARGETS = 0x805B0027 +} + +SceGxmDisplayQueueCallback :: #type proc(callbackData: rawptr) + +SceGxmInitializeParams :: struct { + flags: c.uint, + displayQueueMaxPendingCount: c.uint, + displayQueueCallback: ^SceGxmDisplayQueueCallback, + displayQueueCallbackDataSize: c.uint, + parameterBufferSize: sce.Size, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmInitializeParams) == 0x14) +} + +SceGxmMemoryAttribFlags :: enum c.int { + READ = 1, + WRITE = 2, + RW = (READ | WRITE) +} + +SceGxmAttributeFormat :: enum c.int { + U8, + S8, + U16, + S16, + U8N, + S8N, + U16N, + S16N, + F16, + F32, + UNTYPED +} + +SceGxmDepthStencilFormat :: enum c.uint { + DF32 = 0x00044000, + S8 = 0x00022000, + DF32_S8 = 0x00066000, + DF32M = 0x000CC000, + DF32M_S8 = 0x000EE000, + S8D24 = 0x01266000, + D16 = 0x02444000, +} + +SceGxmPrimitiveType :: enum c.uint { + TRIANGLES = 0x00000000, + LINES = 0x04000000, + POINTS = 0x08000000, + TRIANGLE_STRIP = 0x0C000000, + TRIANGLE_FAN = 0x10000000, + TRIANGLE_EDGES = 0x14000000, +} + +SceGxmEdgeEnableFlags :: enum c.uint { + EDGE_ENABLE_01 = 0x00000100, + EDGE_ENABLE_12 = 0x00000200, + EDGE_ENABLE_20 = 0x00000400, +} + +SceGxmRegionClipMode :: enum c.uint { + NONE = 0x00000000, + ALL = 0x40000000, + OUTSIDE = 0x80000000, + INSIDE = 0xC0000000, +} + +SceGxmDepthFunc :: enum c.uint { + NEVER = 0x00000000, + LESS = 0x00400000, + EQUAL = 0x00800000, + LESS_EQUAL = 0x00C00000, + GREATER = 0x01000000, + NOT_EQUAL = 0x01400000, + GREATER_EQUAL = 0x01800000, + ALWAYS = 0x01C00000, +} + +SceGxmStencilFunc :: enum c.uint { + NEVER = 0x00000000, + LESS = 0x02000000, + EQUAL = 0x04000000, + LESS_EQUAL = 0x06000000, + GREATER = 0x08000000, + NOT_EQUAL = 0x0A000000, + GREATER_EQUAL = 0x0C000000, + ALWAYS = 0x0E000000, +} + +SceGxmStencilOp :: enum c.uint { + KEEP = 0x00000000, + ZERO = 0x00000001, + REPLACE = 0x00000002, + INCR = 0x00000003, + DECR = 0x00000004, + INVERT = 0x00000005, + INCR_WRAP = 0x00000006, + DECR_WRAP = 0x00000007, +} + +SceGxmCullMode :: enum c.uint { + NONE = 0x00000000, + CW = 0x00000001, + CCW = 0x00000002, +} + +SceGxmPassType :: enum c.uint { + OPAQUE = 0x00000000, + TRANSLUCENT = 0x02000000, + DISCARD = 0x04000000, + MASK_UPDATE = 0x06000000, + DEPTH_REPLACE = 0x0A000000, +} + +SceGxmPolygonMode :: enum c.uint { + TRIANGLE_FILL = 0x00000000, + LINE = 0x00008000, + POINT_10UV = 0x00010000, + POINT = 0x00018000, + POINT_01UV = 0x00020000, + TRIANGLE_LINE = 0x00028000, + TRIANGLE_POINT = 0x00030000, +} + +SceGxmColorSwizzle4Mode :: enum c.uint { + ABGR = 0x00000000, + ARGB = 0x00100000, + RGBA = 0x00200000, + BGRA = 0x00300000, +} + +SceGxmColorSwizzle3Mode :: enum c.uint { + BGR = 0x00000000, + RGB = 0x00100000, +} + +SceGxmColorSwizzle2Mode :: enum c.uint { + GR = 0x00000000, + RG = 0x00100000, + RA = 0x00200000, + AR = 0x00300000, +} + +SceGxmColorSwizzle1Mode :: enum c.uint { + R = 0x00000000, + G = 0x00100000, + A = 0x00100000, +} + +SceGxmColorBaseFormat :: enum c.uint { + U8U8U8U8 = 0x00000000, + U8U8U8 = 0x10000000, + U5U6U5 = 0x30000000, + U1U5U5U5 = 0x40000000, + U4U4U4U4 = 0x50000000, + U8U3U3U2 = 0x60000000, + F16 = 0xF0000000, + F16F16 = 0x00800000, + F32 = 0x10800000, + S16 = 0x20800000, + S16S16 = 0x30800000, + U16 = 0x40800000, + U16U16 = 0x50800000, + U2U10U10U10 = 0x60800000, + U8 = 0x80800000, + S8 = 0x90800000, + S5S5U6 = 0xA0800000, + U8U8 = 0xB0800000, + S8S8 = 0xC0800000, + U8S8S8U8 = 0xD0800000, + S8S8S8S8 = 0xE0800000, + F16F16F16F16 = 0x01000000, + F32F32 = 0x11000000, + F11F11F10 = 0x21000000, + SE5M9M9M9 = 0x31000000, + U2F10F10F10 = 0x41000000, +} + +//! Supported color formats +SceGxmColorFormat :: enum c.uint { + U8U8U8U8_ABGR = c.uint(SceGxmColorBaseFormat.U8U8U8U8) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U8U8U8U8_ARGB = c.uint(SceGxmColorBaseFormat.U8U8U8U8) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + U8U8U8U8_RGBA = c.uint(SceGxmColorBaseFormat.U8U8U8U8) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + U8U8U8U8_BGRA = c.uint(SceGxmColorBaseFormat.U8U8U8U8) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + U8U8U8_BGR = c.uint(SceGxmColorBaseFormat.U8U8U8) | c.uint(SceGxmColorSwizzle3Mode.BGR), + U8U8U8_RGB = c.uint(SceGxmColorBaseFormat.U8U8U8) | c.uint(SceGxmColorSwizzle3Mode.RGB), + + U5U6U5_BGR = c.uint(SceGxmColorBaseFormat.U5U6U5) | c.uint(SceGxmColorSwizzle3Mode.BGR), + U5U6U5_RGB = c.uint(SceGxmColorBaseFormat.U5U6U5) | c.uint(SceGxmColorSwizzle3Mode.RGB), + + U1U5U5U5_ABGR = c.uint(SceGxmColorBaseFormat.U1U5U5U5) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U1U5U5U5_ARGB = c.uint(SceGxmColorBaseFormat.U1U5U5U5) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + U5U5U5U1_RGBA = c.uint(SceGxmColorBaseFormat.U1U5U5U5) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + U5U5U5U1_BGRA = c.uint(SceGxmColorBaseFormat.U1U5U5U5) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + U4U4U4U4_ABGR = c.uint(SceGxmColorBaseFormat.U4U4U4U4) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U4U4U4U4_ARGB = c.uint(SceGxmColorBaseFormat.U4U4U4U4) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + U4U4U4U4_RGBA = c.uint(SceGxmColorBaseFormat.U4U4U4U4) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + U4U4U4U4_BGRA = c.uint(SceGxmColorBaseFormat.U4U4U4U4) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + U8U3U3U2_ARGB = c.uint(c.uint(SceGxmColorBaseFormat.U8U3U3U2)), + + F16_R = c.uint(SceGxmColorBaseFormat.F16) | c.uint(SceGxmColorSwizzle1Mode.R), + F16_G = c.uint(SceGxmColorBaseFormat.F16) | c.uint(SceGxmColorSwizzle1Mode.G), + + F16F16_GR = c.uint(SceGxmColorBaseFormat.F16F16) | c.uint(SceGxmColorSwizzle2Mode.GR), + F16F16_RG = c.uint(SceGxmColorBaseFormat.F16F16) | c.uint(SceGxmColorSwizzle2Mode.RG), + + F32_R = c.uint(SceGxmColorBaseFormat.F32) | c.uint(SceGxmColorSwizzle1Mode.R), + + S16_R = c.uint(SceGxmColorBaseFormat.S16) | c.uint(SceGxmColorSwizzle1Mode.R), + S16_G = c.uint(SceGxmColorBaseFormat.S16) | c.uint(SceGxmColorSwizzle1Mode.G), + + S16S16_GR = c.uint(SceGxmColorBaseFormat.S16S16) | c.uint(SceGxmColorSwizzle2Mode.GR), + S16S16_RG = c.uint(SceGxmColorBaseFormat.S16S16) | c.uint(SceGxmColorSwizzle2Mode.RG), + + U16_R = c.uint(SceGxmColorBaseFormat.U16) | c.uint(SceGxmColorSwizzle1Mode.R), + U16_G = c.uint(SceGxmColorBaseFormat.U16) | c.uint(SceGxmColorSwizzle1Mode.G), + + U16U16_GR = c.uint(SceGxmColorBaseFormat.U16U16) | c.uint(SceGxmColorSwizzle2Mode.GR), + U16U16_RG = c.uint(SceGxmColorBaseFormat.U16U16) | c.uint(SceGxmColorSwizzle2Mode.RG), + + U2U10U10U10_ABGR = c.uint(SceGxmColorBaseFormat.U2U10U10U10) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U2U10U10U10_ARGB = c.uint(SceGxmColorBaseFormat.U2U10U10U10) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + U10U10U10U2_RGBA = c.uint(SceGxmColorBaseFormat.U2U10U10U10) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + U10U10U10U2_BGRA = c.uint(SceGxmColorBaseFormat.U2U10U10U10) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + U8_R = c.uint(SceGxmColorBaseFormat.U8) | c.uint(SceGxmColorSwizzle1Mode.R), + U8_A = c.uint(SceGxmColorBaseFormat.U8) | c.uint(SceGxmColorSwizzle1Mode.A), + + S8_R = c.uint(SceGxmColorBaseFormat.S8) | c.uint(SceGxmColorSwizzle1Mode.R), + S8_A = c.uint(SceGxmColorBaseFormat.S8) | c.uint(SceGxmColorSwizzle1Mode.A), + + U6S5S5_BGR = c.uint(SceGxmColorBaseFormat.S5S5U6) | c.uint(SceGxmColorSwizzle3Mode.BGR), + S5S5U6_RGB = c.uint(SceGxmColorBaseFormat.S5S5U6) | c.uint(SceGxmColorSwizzle3Mode.RGB), + + U8U8_GR = c.uint(SceGxmColorBaseFormat.U8U8) | c.uint(SceGxmColorSwizzle2Mode.GR), + U8U8_RG = c.uint(SceGxmColorBaseFormat.U8U8) | c.uint(SceGxmColorSwizzle2Mode.RG), + U8U8_RA = c.uint(SceGxmColorBaseFormat.U8U8) | c.uint(SceGxmColorSwizzle2Mode.RA), + U8U8_AR = c.uint(SceGxmColorBaseFormat.U8U8) | c.uint(SceGxmColorSwizzle2Mode.AR), + + S8S8_GR = c.uint(SceGxmColorBaseFormat.S8S8) | c.uint(SceGxmColorSwizzle2Mode.GR), + S8S8_RG = c.uint(SceGxmColorBaseFormat.S8S8) | c.uint(SceGxmColorSwizzle2Mode.RG), + S8S8_RA = c.uint(SceGxmColorBaseFormat.S8S8) | c.uint(SceGxmColorSwizzle2Mode.RA), + S8S8_AR = c.uint(SceGxmColorBaseFormat.S8S8) | c.uint(SceGxmColorSwizzle2Mode.AR), + + U8S8S8U8_ABGR = c.uint(SceGxmColorBaseFormat.U8S8S8U8) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U8U8S8S8_ARGB = c.uint(SceGxmColorBaseFormat.U8S8S8U8) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + U8S8S8U8_RGBA = c.uint(SceGxmColorBaseFormat.U8S8S8U8) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + S8S8U8U8_BGRA = c.uint(SceGxmColorBaseFormat.U8S8S8U8) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + S8S8S8S8_ABGR = c.uint(SceGxmColorBaseFormat.S8S8S8S8) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + S8S8S8S8_ARGB = c.uint(SceGxmColorBaseFormat.S8S8S8S8) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + S8S8S8S8_RGBA = c.uint(SceGxmColorBaseFormat.S8S8S8S8) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + S8S8S8S8_BGRA = c.uint(SceGxmColorBaseFormat.S8S8S8S8) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + F16F16F16F16_ABGR = c.uint(SceGxmColorBaseFormat.F16F16F16F16) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + F16F16F16F16_ARGB = c.uint(SceGxmColorBaseFormat.F16F16F16F16) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + F16F16F16F16_RGBA = c.uint(SceGxmColorBaseFormat.F16F16F16F16) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + F16F16F16F16_BGRA = c.uint(SceGxmColorBaseFormat.F16F16F16F16) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + F32F32_GR = c.uint(SceGxmColorBaseFormat.F32F32) | c.uint(SceGxmColorSwizzle2Mode.GR), + F32F32_RG = c.uint(SceGxmColorBaseFormat.F32F32) | c.uint(SceGxmColorSwizzle2Mode.RG), + + F10F11F11_BGR = c.uint(SceGxmColorBaseFormat.F11F11F10) | c.uint(SceGxmColorSwizzle3Mode.BGR), + F11F11F10_RGB = c.uint(SceGxmColorBaseFormat.F11F11F10) | c.uint(SceGxmColorSwizzle3Mode.RGB), + + SE5M9M9M9_BGR = c.uint(SceGxmColorBaseFormat.SE5M9M9M9) | c.uint(SceGxmColorSwizzle3Mode.BGR), + SE5M9M9M9_RGB = c.uint(SceGxmColorBaseFormat.SE5M9M9M9) | c.uint(SceGxmColorSwizzle3Mode.RGB), + + U2F10F10F10_ABGR = c.uint(SceGxmColorBaseFormat.U2F10F10F10) | c.uint(SceGxmColorSwizzle4Mode.ABGR), + U2F10F10F10_ARGB = c.uint(SceGxmColorBaseFormat.U2F10F10F10) | c.uint(SceGxmColorSwizzle4Mode.ARGB), + F10F10F10U2_RGBA = c.uint(SceGxmColorBaseFormat.U2F10F10F10) | c.uint(SceGxmColorSwizzle4Mode.RGBA), + F10F10F10U2_BGRA = c.uint(SceGxmColorBaseFormat.U2F10F10F10) | c.uint(SceGxmColorSwizzle4Mode.BGRA), + + // Legacy formats + + A8B8G8R8 = U8U8U8U8_ABGR, + A8R8G8B8 = U8U8U8U8_ARGB, + R5G6B5 = U5U6U5_RGB, + A1R5G5B5 = U1U5U5U5_ARGB, + A4R4G4B4 = U4U4U4U4_ARGB, + A8 = U8_A, +} + +SceGxmColorSurfaceType :: enum c.uint { + LINEAR = 0x00000000, + TILED = 0x04000000, + SWIZZLED = 0x08000000, +} + +SceGxmColorSurfaceGammaMode :: enum c.uint { + NONE = 0x00000000, + R = 0x00001000, + GR = 0x00003000, + BGR = 0x00001000, +} + +SceGxmColorSurfaceDitherMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00000008, +} + +SceGxmDepthStencilSurfaceType :: enum c.uint { + LINEAR = 0x00000000, + TILED = 0x00011000, +} + +SceGxmOutputRegisterFormat :: enum c.int { + DECLARED, + UCHAR4, + CHAR4, + USHORT2, + SHORT2, + HALF4, + HALF2, + FLOAT2, + FLOAT, +} + +SceGxmMultisampleMode :: enum c.int { + MULTISAMPLE_NONE, + MULTISAMPLE_2X, + MULTISAMPLE_4X +} + +SceGxmTextureSwizzle4Mode :: enum c.uint { + SWIZZLE4_ABGR = 0x00000000, + SWIZZLE4_ARGB = 0x00001000, + SWIZZLE4_RGBA = 0x00002000, + SWIZZLE4_BGRA = 0x00003000, + SWIZZLE4_1BGR = 0x00004000, + SWIZZLE4_1RGB = 0x00005000, + SWIZZLE4_RGB1 = 0x00006000, + SWIZZLE4_BGR1 = 0x00007000, +} + +SceGxmTextureSwizzle3Mode :: enum c.uint { + BGR = 0x00000000, + RGB = 0x00001000, +} + +SceGxmTextureSwizzle2Mode :: enum c.uint { + SWIZZLE2_GR = 0x00000000, + SWIZZLE2_00GR = 0x00001000, + SWIZZLE2_GRRR = 0x00002000, + SWIZZLE2_RGGG = 0x00003000, + SWIZZLE2_GRGR = 0x00004000, + SWIZZLE2_00RG = 0x00005000, +} + +SceGxmTextureSwizzle2ModeAlt :: enum c.uint { + SD = 0x00000000, + DS = 0x00001000, +} + +SceGxmTextureSwizzle1Mode :: enum c.uint { + SWIZZLE1_R = 0x00000000, + SWIZZLE1_000R = 0x00001000, + SWIZZLE1_111R = 0x00002000, + SWIZZLE1_RRRR = 0x00003000, + SWIZZLE1_0RRR = 0x00004000, + SWIZZLE1_1RRR = 0x00005000, + SWIZZLE1_R000 = 0x00006000, + SWIZZLE1_R111 = 0x00007000, +} + +SceGxmTextureSwizzleYUV422Mode :: enum c.uint { + YUYV_CSC0 = 0x00000000, + YVYU_CSC0 = 0x00001000, + UYVY_CSC0 = 0x00002000, + VYUY_CSC0 = 0x00003000, + YUYV_CSC1 = 0x00004000, + YVYU_CSC1 = 0x00005000, + UYVY_CSC1 = 0x00006000, + VYUY_CSC1 = 0x00007000, +} + +SceGxmTextureSwizzleYUV420Mode :: enum c.uint { + YUV_CSC0 = 0x00000000, + YVU_CSC0 = 0x00001000, + YUV_CSC1 = 0x00002000, + YVU_CSC1 = 0x00003000, +} + +SceGxmTextureBaseFormat :: enum c.uint { + U8 = 0x00000000, + S8 = 0x01000000, + U4U4U4U4 = 0x02000000, + U8U3U3U2 = 0x03000000, + U1U5U5U5 = 0x04000000, + U5U6U5 = 0x05000000, + S5S5U6 = 0x06000000, + U8U8 = 0x07000000, + S8S8 = 0x08000000, + U16 = 0x09000000, + S16 = 0x0A000000, + F16 = 0x0B000000, + U8U8U8U8 = 0x0C000000, + S8S8S8S8 = 0x0D000000, + U2U10U10U10 = 0x0E000000, + U16U16 = 0x0F000000, + S16S16 = 0x10000000, + F16F16 = 0x11000000, + F32 = 0x12000000, + F32M = 0x13000000, + X8S8S8U8 = 0x14000000, + X8U24 = 0x15000000, + U32 = 0x17000000, + S32 = 0x18000000, + SE5M9M9M9 = 0x19000000, + F11F11F10 = 0x1A000000, + F16F16F16F16 = 0x1B000000, + U16U16U16U16 = 0x1C000000, + S16S16S16S16 = 0x1D000000, + F32F32 = 0x1E000000, + U32U32 = 0x1F000000, + PVRT2BPP = 0x80000000, + PVRT4BPP = 0x81000000, + PVRTII2BPP = 0x82000000, + PVRTII4BPP = 0x83000000, + UBC1 = 0x85000000, + UBC2 = 0x86000000, + UBC3 = 0x87000000, + UBC4 = 0x88000000, + SBC4 = 0x89000000, + UBC5 = 0x8A000000, + SBC5 = 0x8B000000, + YUV420P2 = 0x90000000, + YUV420P3 = 0x91000000, + YUV422 = 0x92000000, + P4 = 0x94000000, + P8 = 0x95000000, + U8U8U8 = 0x98000000, + S8S8S8 = 0x99000000, + U2F10F10F10 = 0x9A000000, +} + +SceGxmTextureFormat :: enum c.uint { + // Supported formats + + U8_000R = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + U8_111R = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + U8_RRRR = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + U8_0RRR = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + U8_1RRR = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + U8_R000 = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + U8_R111 = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + U8_R = c.uint(SceGxmTextureBaseFormat.U8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + S8_000R = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + S8_111R = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + S8_RRRR = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + S8_0RRR = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + S8_1RRR = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + S8_R000 = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + S8_R111 = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + S8_R = c.uint(SceGxmTextureBaseFormat.S8) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + U4U4U4U4_ABGR = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U4U4U4U4_ARGB = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + U4U4U4U4_RGBA = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + U4U4U4U4_BGRA = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X4U4U4U4_1BGR = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X4U4U4U4_1RGB = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + U4U4U4X4_RGB1 = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + U4U4U4X4_BGR1 = c.uint(SceGxmTextureBaseFormat.U4U4U4U4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U8U3U3U2_ARGB = c.uint(SceGxmTextureBaseFormat.U8U3U3U2), + + U1U5U5U5_ABGR = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U1U5U5U5_ARGB = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + U5U5U5U1_RGBA = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + U5U5U5U1_BGRA = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X1U5U5U5_1BGR = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X1U5U5U5_1RGB = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + U5U5U5X1_RGB1 = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + U5U5U5X1_BGR1 = c.uint(SceGxmTextureBaseFormat.U1U5U5U5) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U5U6U5_BGR = c.uint(SceGxmTextureBaseFormat.U5U6U5) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + U5U6U5_RGB = c.uint(SceGxmTextureBaseFormat.U5U6U5) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + U6S5S5_BGR = c.uint(SceGxmTextureBaseFormat.S5S5U6) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + S5S5U6_RGB = c.uint(SceGxmTextureBaseFormat.S5S5U6) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + U8U8_00GR = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + U8U8_GRRR = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + U8U8_RGGG = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + U8U8_GRGR = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + U8U8_00RG = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + U8U8_GR = c.uint(SceGxmTextureBaseFormat.U8U8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + S8S8_00GR = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + S8S8_GRRR = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + S8S8_RGGG = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + S8S8_GRGR = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + S8S8_00RG = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + S8S8_GR = c.uint(SceGxmTextureBaseFormat.S8S8) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + U16_000R = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + U16_111R = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + U16_RRRR = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + U16_0RRR = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + U16_1RRR = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + U16_R000 = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + U16_R111 = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + U16_R = c.uint(SceGxmTextureBaseFormat.U16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + S16_000R = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + S16_111R = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + S16_RRRR = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + S16_0RRR = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + S16_1RRR = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + S16_R000 = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + S16_R111 = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + S16_R = c.uint(SceGxmTextureBaseFormat.S16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + F16_000R = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + F16_111R = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + F16_RRRR = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + F16_0RRR = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + F16_1RRR = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + F16_R000 = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + F16_R111 = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + F16_R = c.uint(SceGxmTextureBaseFormat.F16) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + U8U8U8U8_ABGR = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U8U8U8U8_ARGB = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + U8U8U8U8_RGBA = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + U8U8U8U8_BGRA = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X8U8U8U8_1BGR = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X8U8U8U8_1RGB = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + U8U8U8X8_RGB1 = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + U8U8U8X8_BGR1 = c.uint(SceGxmTextureBaseFormat.U8U8U8U8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + S8S8S8S8_ABGR = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + S8S8S8S8_ARGB = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + S8S8S8S8_RGBA = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + S8S8S8S8_BGRA = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X8S8S8S8_1BGR = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X8S8S8S8_1RGB = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + S8S8S8X8_RGB1 = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + S8S8S8X8_BGR1 = c.uint(SceGxmTextureBaseFormat.S8S8S8S8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U2U10U10U10_ABGR = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U2U10U10U10_ARGB = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + U10U10U10U2_RGBA = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + U10U10U10U2_BGRA = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X2U10U10U10_1BGR = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X2U10U10U10_1RGB = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + U10U10U10X2_RGB1 = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + U10U10U10X2_BGR1 = c.uint(SceGxmTextureBaseFormat.U2U10U10U10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U16U16_00GR = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + U16U16_GRRR = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + U16U16_RGGG = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + U16U16_GRGR = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + U16U16_00RG = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + U16U16_GR = c.uint(SceGxmTextureBaseFormat.U16U16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + S16S16_00GR = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + S16S16_GRRR = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + S16S16_RGGG = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + S16S16_GRGR = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + S16S16_00RG = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + S16S16_GR = c.uint(SceGxmTextureBaseFormat.S16S16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + F16F16_00GR = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + F16F16_GRRR = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + F16F16_RGGG = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + F16F16_GRGR = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + F16F16_00RG = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + F16F16_GR = c.uint(SceGxmTextureBaseFormat.F16F16) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + F32_000R = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + F32_111R = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + F32_RRRR = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + F32_0RRR = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + F32_1RRR = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + F32_R000 = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + F32_R111 = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + F32_R = c.uint(SceGxmTextureBaseFormat.F32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + F32M_000R = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + F32M_111R = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + F32M_RRRR = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + F32M_0RRR = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + F32M_1RRR = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + F32M_R000 = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + F32M_R111 = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + F32M_R = c.uint(SceGxmTextureBaseFormat.F32M) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + X8S8S8U8_1BGR = c.uint(SceGxmTextureBaseFormat.X8S8S8U8) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + X8U8S8S8_1RGB = c.uint(SceGxmTextureBaseFormat.X8S8S8U8) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + X8U24_SD = c.uint(SceGxmTextureBaseFormat.X8U24) | c.uint(SceGxmTextureSwizzle2ModeAlt.SD), + U24X8_DS = c.uint(SceGxmTextureBaseFormat.X8U24) | c.uint(SceGxmTextureSwizzle2ModeAlt.DS), + + U32_000R = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + U32_111R = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + U32_RRRR = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + U32_0RRR = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + U32_1RRR = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + U32_R000 = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + U32_R111 = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + U32_R = c.uint(SceGxmTextureBaseFormat.U32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + S32_000R = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + S32_111R = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + S32_RRRR = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + S32_0RRR = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + S32_1RRR = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + S32_R000 = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + S32_R111 = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + S32_R = c.uint(SceGxmTextureBaseFormat.S32) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + SE5M9M9M9_BGR = c.uint(SceGxmTextureBaseFormat.SE5M9M9M9) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + SE5M9M9M9_RGB = c.uint(SceGxmTextureBaseFormat.SE5M9M9M9) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + F10F11F11_BGR = c.uint(SceGxmTextureBaseFormat.F11F11F10) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + F11F11F10_RGB = c.uint(SceGxmTextureBaseFormat.F11F11F10) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + F16F16F16F16_ABGR = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + F16F16F16F16_ARGB = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + F16F16F16F16_RGBA = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + F16F16F16F16_BGRA = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X16F16F16F16_1BGR = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X16F16F16F16_1RGB = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + F16F16F16X16_RGB1 = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + F16F16F16X16_BGR1 = c.uint(SceGxmTextureBaseFormat.F16F16F16F16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U16U16U16U16_ABGR = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U16U16U16U16_ARGB = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + U16U16U16U16_RGBA = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + U16U16U16U16_BGRA = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X16U16U16U16_1BGR = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X16U16U16U16_1RGB = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + U16U16U16X16_RGB1 = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + U16U16U16X16_BGR1 = c.uint(SceGxmTextureBaseFormat.U16U16U16U16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + S16S16S16S16_ABGR = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + S16S16S16S16_ARGB = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + S16S16S16S16_RGBA = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + S16S16S16S16_BGRA = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X16S16S16S16_1BGR = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X16S16S16S16_1RGB = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + S16S16S16X16_RGB1 = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + S16S16S16X16_BGR1 = c.uint(SceGxmTextureBaseFormat.S16S16S16S16) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + F32F32_00GR = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + F32F32_GRRR = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + F32F32_RGGG = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + F32F32_GRGR = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + F32F32_00RG = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + F32F32_GR = c.uint(SceGxmTextureBaseFormat.F32F32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + U32U32_00GR = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + U32U32_GRRR = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + U32U32_RGGG = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + U32U32_GRGR = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + U32U32_00RG = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + U32U32_GR = c.uint(SceGxmTextureBaseFormat.U32U32) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + PVRT2BPP_ABGR = c.uint(SceGxmTextureBaseFormat.PVRT2BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + PVRT2BPP_1BGR = c.uint(SceGxmTextureBaseFormat.PVRT2BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + PVRT4BPP_ABGR = c.uint(SceGxmTextureBaseFormat.PVRT4BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + PVRT4BPP_1BGR = c.uint(SceGxmTextureBaseFormat.PVRT4BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + PVRTII2BPP_ABGR = c.uint(SceGxmTextureBaseFormat.PVRTII2BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + PVRTII2BPP_1BGR = c.uint(SceGxmTextureBaseFormat.PVRTII2BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + PVRTII4BPP_ABGR = c.uint(SceGxmTextureBaseFormat.PVRTII4BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + PVRTII4BPP_1BGR = c.uint(SceGxmTextureBaseFormat.PVRTII4BPP) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + UBC1_ABGR = c.uint(SceGxmTextureBaseFormat.UBC1) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + UBC1_1BGR = c.uint(SceGxmTextureBaseFormat.UBC1) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + UBC2_ABGR = c.uint(SceGxmTextureBaseFormat.UBC2) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + UBC2_1BGR = c.uint(SceGxmTextureBaseFormat.UBC2) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + UBC3_ABGR = c.uint(SceGxmTextureBaseFormat.UBC3) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + UBC3_1BGR = c.uint(SceGxmTextureBaseFormat.UBC3) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + + UBC4_000R = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + UBC4_111R = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + UBC4_RRRR = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + UBC4_0RRR = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + UBC4_1RRR = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + UBC4_R000 = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + UBC4_R111 = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + UBC4_R = c.uint(SceGxmTextureBaseFormat.UBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + SBC4_000R = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_000R), + SBC4_111R = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_111R), + SBC4_RRRR = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_RRRR), + SBC4_0RRR = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_0RRR), + SBC4_1RRR = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_1RRR), + SBC4_R000 = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R000), + SBC4_R111 = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R111), + SBC4_R = c.uint(SceGxmTextureBaseFormat.SBC4) | c.uint(SceGxmTextureSwizzle1Mode.SWIZZLE1_R), + + UBC5_00GR = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + UBC5_GRRR = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + UBC5_RGGG = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + UBC5_GRGR = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + UBC5_00RG = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + UBC5_GR = c.uint(SceGxmTextureBaseFormat.UBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + SBC5_00GR = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00GR), + SBC5_GRRR = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRRR), + SBC5_RGGG = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_RGGG), + SBC5_GRGR = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GRGR), + SBC5_00RG = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_00RG), + SBC5_GR = c.uint(SceGxmTextureBaseFormat.SBC5) | c.uint(SceGxmTextureSwizzle2Mode.SWIZZLE2_GR), + + YUV420P2_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV420P2) | c.uint(SceGxmTextureSwizzleYUV420Mode.YUV_CSC0), + YVU420P2_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV420P2) | c.uint(SceGxmTextureSwizzleYUV420Mode.YVU_CSC0), + YUV420P2_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV420P2) | c.uint(SceGxmTextureSwizzleYUV420Mode.YUV_CSC1), + YVU420P2_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV420P2) | c.uint(SceGxmTextureSwizzleYUV420Mode.YVU_CSC1), + + YUV420P3_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV420P3) | c.uint(SceGxmTextureSwizzleYUV420Mode.YUV_CSC0), + YVU420P3_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV420P3) | c.uint(SceGxmTextureSwizzleYUV420Mode.YVU_CSC0), + YUV420P3_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV420P3) | c.uint(SceGxmTextureSwizzleYUV420Mode.YUV_CSC1), + YVU420P3_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV420P3) | c.uint(SceGxmTextureSwizzleYUV420Mode.YVU_CSC1), + + YUYV422_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.YUYV_CSC0), + YVYU422_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.YVYU_CSC0), + UYVY422_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.UYVY_CSC0), + VYUY422_CSC0 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.VYUY_CSC0), + YUYV422_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.YUYV_CSC1), + YVYU422_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.YVYU_CSC1), + UYVY422_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.UYVY_CSC1), + VYUY422_CSC1 = c.uint(SceGxmTextureBaseFormat.YUV422) | c.uint(SceGxmTextureSwizzleYUV422Mode.VYUY_CSC1), + + P4_ABGR = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + P4_ARGB = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + P4_RGBA = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + P4_BGRA = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + P4_1BGR = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + P4_1RGB = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + P4_RGB1 = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + P4_BGR1 = c.uint(SceGxmTextureBaseFormat.P4) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + P8_ABGR = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + P8_ARGB = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + P8_RGBA = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + P8_BGRA = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + P8_1BGR = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + P8_1RGB = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + P8_RGB1 = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + P8_BGR1 = c.uint(SceGxmTextureBaseFormat.P8) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + U8U8U8_BGR = c.uint(SceGxmTextureBaseFormat.U8U8U8) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + U8U8U8_RGB = c.uint(SceGxmTextureBaseFormat.U8U8U8) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + S8S8S8_BGR = c.uint(SceGxmTextureBaseFormat.S8S8S8) | c.uint(SceGxmTextureSwizzle3Mode.BGR), + S8S8S8_RGB = c.uint(SceGxmTextureBaseFormat.S8S8S8) | c.uint(SceGxmTextureSwizzle3Mode.RGB), + + U2F10F10F10_ABGR = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ABGR), + U2F10F10F10_ARGB = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_ARGB), + F10F10F10U2_RGBA = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGBA), + F10F10F10U2_BGRA = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGRA), + X2F10F10F10_1BGR = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1BGR), + X2F10F10F10_1RGB = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_1RGB), + F10F10F10X2_RGB1 = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_RGB1), + F10F10F10X2_BGR1 = c.uint(SceGxmTextureBaseFormat.U2F10F10F10) | c.uint(SceGxmTextureSwizzle4Mode.SWIZZLE4_BGR1), + + // Legacy formats + + L8 = U8_1RRR, + A8 = U8_R000, + R8 = U8_000R, + A4R4G4B4 = U4U4U4U4_ARGB, + A1R5G5B5 = U1U5U5U5_ARGB, + R5G6B5 = U5U6U5_RGB, + A8L8 = U8U8_GRRR, + L8A8 = U8U8_RGGG, + G8R8 = U8U8_00GR, + L16 = U16_1RRR, + A16 = U16_R000, + R16 = U16_000R, + D16 = U16_R, + LF16 = F16_1RRR, + AF16 = F16_R000, + RF16 = F16_000R, + A8R8G8B8 = U8U8U8U8_ARGB, + A8B8G8R8 = U8U8U8U8_ABGR, + AF16LF16 = F16F16_GRRR, + LF16AF16 = F16F16_RGGG, + GF16RF16 = F16F16_00GR, + LF32M = F32M_1RRR, + AF32M = F32M_R000, + RF32M = F32M_000R, + DF32M = F32M_R, + VYUY = VYUY422_CSC0, + YVYU = YVYU422_CSC0, + UBC1 = UBC1_ABGR, + UBC2 = UBC2_ABGR, + UBC3 = UBC3_ABGR, + PVRT2BPP = PVRT2BPP_ABGR, + PVRT4BPP = PVRT4BPP_ABGR, + PVRTII2BPP = PVRTII2BPP_ABGR, + PVRTII4BPP = PVRTII4BPP_ABGR, +} + +SceGxmTextureType :: enum c.uint { + SWIZZLED = 0x00000000, + CUBE = 0x40000000, + LINEAR = 0x60000000, + TILED = 0x80000000, + SWIZZLED_ARBITRARY = 0xA0000000, + LINEAR_STRIDED = 0xC0000000, + CUBE_ARBITRARY = 0xE0000000, +} + +SceGxmTextureFilter :: enum c.uint { + POINT = 0x00000000, + LINEAR = 0x00000001, + MIPMAP_LINEAR = 0x00000002, + MIPMAP_POINT = 0x00000003, +} + +SceGxmTextureMipFilter :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00000200, +} + +SceGxmTextureAddrMode :: enum c.uint { + REPEAT = 0x00000000, + MIRROR = 0x00000001, + CLAMP = 0x00000002, + MIRROR_CLAMP = 0x00000003, + REPEAT_IGNORE_BORDER = 0x00000004, + CLAMP_FULL_BORDER = 0x00000005, + CLAMP_IGNORE_BORDER = 0x00000006, + CLAMP_HALF_BORDER = 0x00000007, +} + +SceGxmTextureGammaMode :: enum c.uint { + NONE = 0x00000000, + R = 0x08000000, + GR = 0x18000000, + BGR = 0x08000000, +} + +SceGxmTextureNormalizeMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x80000000, +} + +SceGxmIndexFormat :: enum c.uint { + U16 = 0x00000000, + U32 = 0x01000000, +} + +SceGxmIndexSource :: enum c.uint { + INDEX_16BIT = 0x00000000, + INDEX_32BIT = 0x00000001, + INSTANCE_16BIT = 0x00000002, + INSTANCE_32BIT = 0x00000003, +} + +SceGxmFragmentProgramMode :: enum c.uint { + DISABLED = 0x00200000, + ENABLED = 0x00000000, +} + +SceGxmDepthWriteMode :: enum c.uint { + DISABLED = 0x00100000, + ENABLED = 0x00000000, +} + +SceGxmLineFillLastPixelMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00080000, +} + +SceGxmTwoSidedMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00000800, +} + +SceGxmWClampMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00008000, +} + +SceGxmViewportMode :: enum c.uint { + DISABLED = 0x00010000, + ENABLED = 0x00000000, +} + +SceGxmWBufferMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00004000, +} + +SceGxmDepthStencilForceLoadMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00000002, +} + +SceGxmDepthStencilForceStoreMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00000004, +} + +SceGxmSceneFlags :: enum c.uint { + FRAGMENT_SET_DEPENDENCY = 0x00000001, + VERTEX_WAIT_FOR_DEPENDENCY = 0x00000002, + FRAGMENT_TRANSFER_SYNC = 0x00000004, + VERTEX_TRANSFER_SYNC = 0x00000008, +} + +SceGxmMidSceneFlags :: enum c.uint { + PRESERVE_DEFAULT_UNIFORM_BUFFERS = 0x00000001, +} + +SceGxmColorSurfaceScaleMode :: enum c.uint { + NONE = 0x00000000, + MSAA_DOWNSCALE = 0x00000001, +} + +SceGxmOutputRegisterSize :: enum c.uint { + REGISTER_SIZE_32BIT = 0x00000000, + REGISTER_SIZE_64BIT = 0x00000001, +} + +SceGxmVisibilityTestMode :: enum c.uint { + DISABLED = 0x00000000, + ENABLED = 0x00004000, +} + +SceGxmVisibilityTestOp :: enum c.uint { + INCREMENT = 0x00000000, + SET = 0x00040000, +} + +SceGxmYuvProfile :: enum c.int { + BT601_STANDARD, + BT709_STANDARD, + BT601_FULL_RANGE, + BT709_FULL_RANGE, +} + +SceGxmBlendFunc :: enum c.int { + NONE, + ADD, + SUBTRACT, + REVERSE_SUBTRACT, + MIN, + MAX +} + +SceGxmBlendFactor :: enum c.int { + ZERO, + ONE, + SRC_COLOR, + ONE_MINUS_SRC_COLOR, + SRC_ALPHA, + ONE_MINUS_SRC_ALPHA, + DST_COLOR, + ONE_MINUS_DST_COLOR, + DST_ALPHA, + ONE_MINUS_DST_ALPHA, + SRC_ALPHA_SATURATE, + DST_ALPHA_SATURATE +} + +SceGxmColorMask :: enum c.int { + NONE = 0, + A = (1 << 0), + R = (1 << 1), + G = (1 << 2), + B = (1 << 3), + ALL = (A | B | G | R) +} + +SceGxmTransferFormat :: enum c.uint { + U8_R = 0x00000000, + U4U4U4U4_ABGR = 0x00010000, + U1U5U5U5_ABGR = 0x00020000, + U5U6U5_BGR = 0x00030000, + U8U8_GR = 0x00040000, + U8U8U8_BGR = 0x00050000, + U8U8U8U8_ABGR = 0x00060000, + VYUY422 = 0x00070000, + YVYU422 = 0x00080000, + UYVY422 = 0x00090000, + YUYV422 = 0x000a0000, + U2U10U10U10_ABGR = 0x000d0000, + RAW16 = 0x000f0000, + RAW32 = 0x00110000, + RAW64 = 0x00120000, + RAW128 = 0x00130000, +} + +SceGxmTransferFlags :: enum c.uint { + FRAGMENT_SYNC = 0x00000001, + VERTEX_SYNC = 0x00000002, +} + +SceGxmTransferColorKeyMode :: enum c.int { + NONE = 0, + PASS = 1, + REJECT = 2 +} + +SceGxmTransferType :: enum c.uint { + LINEAR = 0x00000000, + TILED = 0x00400000, + SWIZZLED = 0x00800000, +} + +SceGxmBlendInfo :: bit_field c.int { + colorMask: c.uint8_t | 8, //!< Color Mask (One of ::SceGxmColorMask) + colorFunc: c.uint8_t | 4, //!< Color blend function (One of ::SceGxmBlendFunc) + alphaFunc: c.uint8_t | 4, //!< Alpha blend function (One of ::SceGxmBlendFunc) + colorSrc: c.uint8_t | 4, //!< Color source blend factor (One of ::SceGxmBlendFactor) + colorDst: c.uint8_t | 4, //!< Color destination blend factor (One of ::SceGxmBlendFactor) + alphaSrc: c.uint8_t | 4, //!< Alpha source blend factor (One of ::SceGxmBlendFactor) + alphaDst: c.uint8_t | 4, //!< Alpha destination blend factor (One of ::SceGxmBlendFactor) +} +#assert(size_of(SceGxmBlendInfo) == 4) + +SceGxmRenderTarget :: struct{} + +SceGxmSyncObject :: struct{} + +SceGxmVertexAttribute :: struct { + streamIndex: c.uint16_t, //!< Vertex stream index + offset: c.uint16_t, //!< Offset for the stream data in bytes + format: c.uint8_t, //!< Stream data type (One of ::SceGxmAttributeFormat) + componentCount: c.uint8_t, //!< Number of components for the stream data + regIndex: c.uint16_t, //!< The register index in the vertex shader to link stream to. +} +#assert(size_of(SceGxmVertexAttribute) == 8) + +SceGxmVertexStream :: struct { + stride: c.uint16_t, + indexSource: c.uint16_t, +} +#assert(size_of(SceGxmVertexStream) == 4) + +SceGxmTextureHi8Bytes :: struct { + // Control Word 0 + using _: struct #raw_union { + generic: bit_field c.int { // Non LINEAR_STRIDED textures + unk0 : c.uint32_t | 1, //!< Unknown field + stride_ext : c.uint32_t | 2, //!< Stride extension for a LINEAR_STRIDED texture + vaddr_mode : c.uint32_t | 3, //!< V Address Mode + uaddr_mode : c.uint32_t | 3, //!< U Address Mode + mip_filter : c.uint32_t | 1, //!< Mip filter for a non LINEAR_STRIDED texture + min_filter : c.uint32_t | 2, //!< Min filter for a non LINEAR_STRIDED texture) + mag_filter : c.uint32_t | 2, //!< Mag Filter (and Min filter if LINEAR_STRIDED texture) + unk1 : c.uint32_t | 3, //!< Unknown field + mip_count : c.uint32_t | 4, //!< Mip count for a non LINEAR_STRIDED texture + lod_bias : c.uint32_t | 6, //!< Level of Details value for a non LINEAR_STRIDED texture + gamma_mode : c.uint32_t | 2, //!< Gamma mode + unk2 : c.uint32_t | 2, //!< Unknown field + format0 : c.uint32_t | 1, //!< Texture format extension + }, + linear_strided: bit_field c.int { // LINEAR_STRIDED textures + unk0 : c.uint32_t | 1, //!< Unknown field + stride_ext : c.uint32_t | 2, //!< Stride extension for a LINEAR_STRIDED texture + vaddr_mode : c.uint32_t | 3, //!< V Address Mode + uaddr_mode : c.uint32_t | 3, //!< U Address Mode + stride_low : c.uint32_t | 3, //!< Internal stride lower bits for a LINEAR_STRIDED texture + mag_filter : c.uint32_t | 2, //!< Mag Filter (and Min filter if LINEAR_STRIDED texture) + unk1 : c.uint32_t | 3, //!< Unknown field + stride : c.uint32_t | 10, //!< Stride for a LINEAR_STRIDED texture + gamma_mode : c.uint32_t | 2, //!< Gamma mode + unk2 : c.uint32_t | 2, //!< Unknown field + format0 : c.uint32_t | 1, //!< Texture format extension + }, + }, + // Control Word 1 + using _ : struct #raw_union { + generic2: bit_field c.int { // Non SWIZZLED and non CUBE textures + height : c.uint32_t | 12, //!< Texture height for non SWIZZLED and non CUBE textures + width : c.uint32_t | 12, //!< Texture width for non SWIZZLED and non CUBE textures + base_format : c.uint32_t | 5, //!< Texture base format + type : c.uint32_t | 3, //!< Texture format type + }, + swizzled_cube: bit_field c.int { // SWIZZLED and CUBE textures + height_pot : c.uint32_t | 4, //!< Power of 2 height value for SWIZZLED and CUBE textures + reserved0 : c.uint32_t | 12, //!< Reserved field + width_pot : c.uint32_t | 4, //!< Power of 2 width value for SWIZZLED and CUBE textures + reserved1 : c.uint32_t | 4, //!< Reserved field + base_format : c.uint32_t | 5, //!< Texture base format + type : c.uint32_t | 3, //!< Texture format type + }, + }, +} +#assert(size_of(SceGxmTextureHi8Bytes) == 8) + +SceGxmTextureLo8Bytes :: bit_field c.longlong { + // Control Word 2 + lod_min0: c.uint32_t | 2, //!< Level of Details higher bits + data_addr: c.uint32_t | 30, //!< Texture data address + // Control Word 3 + palette_addr: c.uint32_t | 26, //!< Texture palette address + lod_min1: c.uint32_t | 2, //!< Level of Details lower bits + swizzle_format: c.uint32_t | 3, //!< Texture format swizzling + normalize_mode: c.uint32_t | 1, //!< Normalize mode +} +#assert(size_of(SceGxmTextureLo8Bytes) == 8) + +//! Texture struct +SceGxmTexture :: struct { + using hi: SceGxmTextureHi8Bytes, + using lo: SceGxmTextureLo8Bytes, +} + +#assert(size_of(SceGxmTexture) == 0x10) + +SceGxmCommandList :: struct { + words: [8]c.uint32_t, +} +#assert(size_of(SceGxmCommandList) == 0x20) + +SceGxmColorSurface :: struct { + pbeSidebandWord: c.uint, + pbeEmitWords: [6]c.uint, + outputRegisterSize: c.uint, + backgroundTex: SceGxmTexture, +} +#assert(size_of(SceGxmColorSurface) == 0x30) + +SceGxmDepthStencilSurface :: struct { + zlsControl: c.uint, + depthData: rawptr, + stencilData: rawptr, + backgroundDepth: c.float, + backgroundControl: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmDepthStencilSurface) == 0x14) +} + +//! Represents an auxiliary surface +SceGxmAuxiliarySurface :: struct { + colorFormat: c.uint32_t, //!< Format of auxiliary surface data from SceGxmColorFormat + type: c.uint32_t, //!< Memory layout of the surface data from SceGxmColorSurfaceType + width: c.uint32_t, //!< Surface width + height: c.uint32_t, //!< Surface height + stride: c.uint32_t, //!< Surface stride in bytes + data: rawptr, //!< A pointer to the surface data +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmAuxiliarySurface) == 0x18) +} + +SceGxmNotification :: struct { + address: ^c.uint, + value: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmNotification) == 8) +} + +SceGxmValidRegion :: struct { + xMax: c.uint32_t, + yMax: c.uint32_t, +} +#assert(size_of(SceGxmValidRegion) == 8) + +SceGxmContext :: struct{} + +SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE :: (2 * 1024) +SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE :: (16 * 1024 * 1024) +SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE :: (128 * 1024) +SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE :: (2 * 1024 * 1024) +SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE :: (512 * 1024) +SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE :: (16 * 1024) + +SceGxmContextParams :: struct { + hostMem: rawptr, + hostMemSize: sce.Size, + vdmRingBufferMem: rawptr, + vdmRingBufferMemSize: sce.Size, + vertexRingBufferMem: rawptr, + vertexRingBufferMemSize: sce.Size, + fragmentRingBufferMem: rawptr, + fragmentRingBufferMemSize: sce.Size, + fragmentUsseRingBufferMem: rawptr, + fragmentUsseRingBufferMemSize: sce.Size, + fragmentUsseRingBufferOffset: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmContextParams) == 0x2C) +} + +SceGxmDeferredContextParams :: struct { + hostMem: rawptr, + hostMemSize: sce.Size, + vdmCallback: #type ^proc(args: rawptr, requestedSize: sce.Size, size: ^sce.Size) -> rawptr, + vertexCallback: #type ^proc(args: rawptr, requestedSize: sce.Size, size: ^sce.Size) -> rawptr, + fragmentCallback: #type ^proc(args: rawptr, requestedSize: sce.Size, size: ^sce.Size) -> rawptr, + callbackData: rawptr, + vdmRingBufferMem: rawptr, + vdmRingBufferMemSize: sce.Size, + vertexRingBufferMem: rawptr, + vertexRingBufferMemSize: sce.Size, + fragmentRingBufferMem: rawptr, + fragmentRingBufferMemSize: sce.Size, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmDeferredContextParams) == 0x30) +} + +SceGxmVertexProgram :: struct{} + +SceGxmFragmentProgram :: struct{} + +SceGxmPrecomputedWordCount :: enum c.int { + VERTEX_STATE_WORD_COUNT = 7, + FRAGMENT_STATE_WORD_COUNT = 9, + DRAW_WORD_COUNT = 11, +} + +SceGxmPrecomputedVertexState :: struct { + data: [SceGxmPrecomputedWordCount.VERTEX_STATE_WORD_COUNT]c.uint, +} +#assert(size_of(SceGxmPrecomputedVertexState) == 0x1C) + +SceGxmPrecomputedFragmentState :: struct { + data: [SceGxmPrecomputedWordCount.FRAGMENT_STATE_WORD_COUNT]c.uint, +} +#assert(size_of(SceGxmPrecomputedFragmentState) == 0x24) + +SceGxmPrecomputedDraw :: struct { + data: [SceGxmPrecomputedWordCount.DRAW_WORD_COUNT]c.uint, +} +#assert(size_of(SceGxmPrecomputedDraw) == 0x2C) + +SCE_GXM_MAX_VERTEX_ATTRIBUTES :: 16 +SCE_GXM_MAX_VERTEX_STREAMS :: 16 +SCE_GXM_MAX_TEXTURE_UNITS :: 16 +SCE_GXM_MAX_UNIFORM_BUFFERS :: 14 +SCE_GXM_MAX_AUXILIARY_SURFACES :: 3 + +SCE_GXM_TILE_SHIFTX : c.uint : 5 +SCE_GXM_TILE_SHIFTY : c.uint : 5 +SCE_GXM_TILE_SIZEX : c.uint : (1 << SCE_GXM_TILE_SHIFTX) +SCE_GXM_TILE_SIZEY : c.uint : (1 << SCE_GXM_TILE_SHIFTY) + +SCE_GXM_COLOR_SURFACE_ALIGNMENT : c.uint : 4 +SCE_GXM_TEXTURE_ALIGNMENT : c.uint : 16 +SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT : c.uint : 16 +SCE_GXM_PALETTE_ALIGNMENT : c.uint : 64 + +SceGxmProgram :: struct{} + +SceGxmProgramParameter :: struct{} + +SceGxmProgramType :: enum c.int { + VERTEX_PROGRAM, + FRAGMENT_PROGRAM +} + +SceGxmParameterCategory :: enum c.int { + ATTRIBUTE, + UNIFORM, + SAMPLER, + AUXILIARY_SURFACE, + UNIFORM_BUFFER +} + +SceGxmParameterType :: enum c.int { + F32, + F16, + C10, + U32, + S32, + U16, + S16, + U8, + S8, + AGGREGATE +} + +SceGxmParameterSemantic :: enum c.int { + NONE, + ATTR, + BCOL, + BINORMAL, + BLENDINDICES, + BLENDWEIGHT, + COLOR, + DIFFUSE, + FOGCOORD, + NORMAL, + POINTSIZE, + POSITION, + SPECULAR, + TANGENT, + TEXCOORD +} + +SceGxmShaderPatcher :: struct{} + +SceGxmRegisteredProgram :: struct{} + +SceGxmShaderPatcherId :: ^SceGxmRegisteredProgram +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmShaderPatcherId) == 4) +} + +SceGxmShaderPatcherHostAllocCallback :: #type proc(userData: rawptr, size: sce.Size) -> rawptr +SceGxmShaderPatcherHostFreeCallback :: #type proc(userData: rawptr, mem: rawptr) +SceGxmShaderPatcherBufferAllocCallback :: #type proc(userData: rawptr, size: sce.Size) -> rawptr +SceGxmShaderPatcherBufferFreeCallback :: #type proc(userData: rawptr, mem: rawptr) +SceGxmShaderPatcherUsseAllocCallback :: #type proc(userData: rawptr, size: sce.Size, usseOffset: ^c.uint) -> rawptr +SceGxmShaderPatcherUsseFreeCallback :: #type proc(userData: rawptr, mem: rawptr) + +SceGxmShaderPatcherParams :: struct { + userData: rawptr, + hostAllocCallback: ^SceGxmShaderPatcherHostAllocCallback, + hostFreeCallback: ^SceGxmShaderPatcherHostFreeCallback, + bufferAllocCallback: ^SceGxmShaderPatcherBufferAllocCallback, + bufferFreeCallback: ^SceGxmShaderPatcherBufferFreeCallback, + bufferMem: rawptr, + bufferMemSize: sce.Size, + vertexUsseAllocCallback: ^SceGxmShaderPatcherUsseAllocCallback, + vertexUsseFreeCallback: ^SceGxmShaderPatcherUsseFreeCallback, + vertexUsseMem: rawptr, + vertexUsseMemSize: sce.Size, + vertexUsseOffset: c.uint, + fragmentUsseAllocCallback: ^SceGxmShaderPatcherUsseAllocCallback, + fragmentUsseFreeCallback: ^SceGxmShaderPatcherUsseFreeCallback, + fragmentUsseMem: rawptr, + fragmentUsseMemSize: sce.Size, + fragmentUsseOffset: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceGxmShaderPatcherParams) == 0x44) +} + +SceGxmRenderTargetFlags :: enum c.int { + CUSTOM_MULTISAMPLE_LOCATIONS = (1 << 0) +} + +SceGxmRenderTargetParams :: struct { + flags: c.uint32_t, //!< Bitwise combined flags from ::SceGxmRenderTargetFlags. + width: c.uint16_t, //!< The width of the render target in pixels. + height: c.uint16_t, //!< The height of the render target in pixels. + scenesPerFrame: c.uint16_t, //!< The expected number of scenes per frame, in the range [1,SCE_GXM_MAX_SCENES_PER_RENDERTARGET]. + multisampleMode: c.uint16_t, //!< A value from the #SceGxmMultisampleMode enum. + multisampleLocations: c.uint32_t, //!< If enabled in the flags, the multisample locations to use. + driverMemBlock: sce.UID, //!< The uncached LPDDR memblock for the render target GPU data structures or SCE_UID_INVALID_UID to specify memory should be allocated in libgxm. +} +#assert(size_of(SceGxmRenderTargetParams) == 0x14) + + +// TODO: should be c.int +/** GXT error codes */ +SceGxtErrorCode :: enum c.uint { + INVALID_VALUE = 0x805D0000, + INVALID_POINTER = 0x805D0001, + INVALID_ALIGNMENT = 0x805D0002 +} + +/** Header for a GXT file */ +SceGxtHeader :: struct { + tag: c.uint32_t, //!< GXT Identifier + version: c.uint32_t, //!< Version number + numTextures: c.uint32_t, //!< Number of textures + dataOffset: c.uint32_t, //!< Offset to the texture data + dataSize: c.uint32_t, //!< Total size of the texture data + numP4Palettes: c.uint32_t, //!< Number of 16 entry palettes + numP8Palettes: c.uint32_t, //!< Number of 256 entry palettes + pad: c.uint32_t, //!< Padding +} +#assert(size_of(SceGxtHeader) == 0x20) + +/** This structure contains information about each texture in the GXT file */ +SceGxtTextureInfo :: struct { + dataOffset: c.uint32_t, //!< Offset to the texture data + dataSize: c.uint32_t, //!< Size of the texture data + paletteIndex: c.uint32_t, //!< Index of the palette + flags: c.uint32_t, //!< Texture flags + type: c.uint32_t, //!< Texture type + format: c.uint32_t, //!< Texture format + width: c.uint16_t, //!< Texture width + height: c.uint16_t, //!< Texture height + mipCount: c.uint8_t, //!< Number of mipmaps + pad: [3]c.uint8_t, //!< Padding +} +#assert(size_of(SceGxtTextureInfo) == 0x20) + diff --git a/Hid/Hid.odin b/Hid/Hid.odin new file mode 100644 index 0000000..afbd470 --- /dev/null +++ b/Hid/Hid.odin @@ -0,0 +1,54 @@ +package hid + +import "core:c" +import sce "../common" + +foreign import hid "system:SceHid_stub" + +@(link_prefix = "sceHid") +foreign hid { + /** + * Enumerate hid keyboards. + * + * @param[out] handle Buffer to receive keyboard hid handles. + * @param[int] count Number of keyboards to enumerate + */ + KeyboardEnumerate :: proc(handle: [^]c.int, count: c.int) -> c.int --- + + + /** + * Get hid keyboard reports (blocking). + * + * @param[in] handle Hid handle. + * @param[in] reports Buffer to receive reports. + * @param[in] nReports Number of reports to receive. + */ + KeyboardRead :: proc(handle: sce.UInt32, reports: []^SceHidKeyboardReport, nReports: c.int) -> c.int --- + + /** + * Get hid keyboard reports (non-blocking). + * + * @param[in] handle Hid handle. + * @param[in] reports Buffer to receive reports. + * @param[in] nReports Number of reports to receive. + */ + KeyboardPeek :: proc(handle: sce.UInt32, reports: [^]SceHidKeyboardReport, nReports: c.int) -> c.int --- + + /** + * Enumerate hid mice. + * + * @param[out] handle Buffer to receive mouse hid handles. + * @param[int] count Number of mice to enumerate + */ + MouseEnumerate :: proc(handle: [^]c.int, count: c.int) -> c.int --- + + + /** + * Get hid mouse reports. + * + * @param[in] handle Hid handle. + * @param[in] reports Buffer to receive reports. + * @param[in] nReports Number of reports to receive. + */ + MouseRead :: proc(handle: sce.UInt32, reports: []^SceHidMouseReport, nReports: c.int) -> c.int --- +} diff --git a/Hid/types.odin b/Hid/types.odin new file mode 100644 index 0000000..7986573 --- /dev/null +++ b/Hid/types.odin @@ -0,0 +1,29 @@ +package hid + +import "core:c" +import sce "../common" + +SCE_HID_MAX_REPORT :: 16 +SCE_HID_MAX_DEVICE_COUNT :: 8 + +SceHidKeyboardReport :: struct { + reserved: sce.UInt8, + modifiers: [2]sce.UInt8, //modifiers[0] Standard modifiers Ctrl Shift Alt, modifiers[1] Caps Lock, ..? + keycodes: [6]sce.UInt8, + reserved2: [7]sce.UInt8, + timestamp: sce.UInt64, // microseconds +} +#assert(size_of(SceHidKeyboardReport) == 0x18) + +SceHidMouseReport :: struct { + buttons: sce.UInt8, + reserved: sce.UInt8, + rel_x: sce.Int16, + rel_y: sce.Int16, + wheel: sce.Int8, + tilt: sce.Int8, + timestamp: sce.UInt64, // microseconds +} +#assert(size_of(SceHidMouseReport) == 0x10) + + diff --git a/Http/Http.odin b/Http/Http.odin new file mode 100644 index 0000000..61d489a --- /dev/null +++ b/Http/Http.odin @@ -0,0 +1,84 @@ +package http + +import "core:c" + +foreign import http "system:SceHttp_stub" + +foreign http { + HttpInit :: proc(poolSize: c.uint) -> c.int --- + HttpTerm :: proc() -> c.int --- + HttpGetMemoryPoolStats :: proc(currentStat: ^SceHttpMemoryPoolStats) -> c.int --- + + HttpSetAuthInfoCallback :: proc(id: c.int, cbfunc: SceHttpAuthInfoCallback, userArg: rawptr) -> c.int --- + HttpSetAuthEnabled :: proc(id: c.int, enable: c.int) -> c.int --- + HttpGetAuthEnabled :: proc(id: c.int, enable: ^c.int) -> c.int --- + HttpSetRedirectCallback :: proc(id: c.int, cbfunc: SceHttpRedirectCallback, userArg: rawptr) -> c.int --- + HttpSetAutoRedirect :: proc(id: c.int, enable: c.int) -> c.int --- + HttpGetAutoRedirect :: proc(id: c.int, enable: ^c.int) -> c.int --- + HttpSetResolveTimeOut :: proc(id: c.int, usec: c.uint) -> c.int --- + HttpSetResolveRetry :: proc(id: c.int, retry: c.int) -> c.int --- + HttpSetConnectTimeOut :: proc(id: c.int, usec: c.uint) -> c.int --- + HttpSetSendTimeOut :: proc(id: c.int, usec: c.uint) -> c.int --- + HttpSetRecvTimeOut :: proc(id: c.int, usec: c.uint) -> c.int --- + + HttpSendRequest :: proc(reqId: c.int, postData: rawptr, size: c.uint) -> c.int --- + HttpAbortRequest :: proc(reqId: c.int) -> c.int --- + HttpGetResponseContentLength :: proc(reqId: c.int, contentLength: ^c.ulonglong) -> c.int --- + HttpGetStatusCode :: proc(reqId: c.int, statusCode: ^c.int) -> c.int --- + HttpGetAllResponseHeaders :: proc(reqId: c.int, header: ^[^]c.char, headerSize: ^c.uint) -> c.int --- // TODO: header is multipointer, cstring or double pointer to char?? + HttpReadData :: proc(reqId: c.int, data: rawptr, size: c.uint) -> c.int --- + HttpAddRequestHeader :: proc(id: c.int, name: cstring, value: cstring, mode: c.uint) -> c.int --- + HttpRemoveRequestHeader :: proc(id: c.int, name: cstring) -> c.int --- + + HttpParseResponseHeader :: proc(header: cstring, headerLen: c.uint, fieldStr: cstring, fieldValue: ^cstring, valueLen: ^c.uint) -> c.int --- + HttpParseStatusLine :: proc(statusLine: cstring, lineLen: c.uint, httpMajorVer: ^c.int, httpMinorVer: ^c.int, responseCode: ^c.int, reasonPhrase: ^cstring, phraseLen: ^c.uint) -> c.int --- + + HttpCreateTemplate :: proc(userAgent: cstring, httpVer: SceHttpVersion, autoProxyConf: SceHttpProxyMode) -> c.int --- + HttpDeleteTemplate :: proc(tmplId: c.int) -> c.int --- + HttpCreateConnection :: proc(tmplId: c.int, serverName: cstring, scheme: cstring, port: c.ushort, enableKeepalive: c.int) -> c.int --- + HttpCreateConnectionWithURL :: proc(tmplId: c.int, url: cstring, enableKeepalive: c.int) -> c.int --- + HttpDeleteConnection :: proc(connId: c.int) -> c.int --- + HttpCreateRequest :: proc(connId: c.int, method: c.int, path: cstring, contentLength: c.ulonglong) -> c.int --- + HttpCreateRequestWithURL :: proc(connId: c.int, method: c.int, url: cstring, contentLength: c.ulonglong) -> c.int --- + HttpDeleteRequest :: proc(reqId: c.int) -> c.int --- + HttpSetResponseHeaderMaxSize :: proc(id: c.int, headerSize: c.uint) -> c.int --- + HttpSetRequestContentLength :: proc(id: c.int, contentLength: c.ulonglong) -> c.int --- + + // uri + HttpUriEscape :: proc(out: cstring, require: ^c.uint, prepare: c.uint, _in: cstring) -> c.int --- + HttpUriUnescape :: proc(out: cstring, require: ^c.uint, prepare: c.uint, _in: cstring) -> c.int --- + HttpUriParse :: proc(out: ^SceHttpUriElement, srcUrl: cstring, pool: rawptr, require: ^c.uint, prepare: c.uint) -> c.int --- + HttpUriBuild :: proc(out: cstring, require: ^c.uint, prepare: c.uint, srcElement: ^SceHttpUriElement, option: c.uint) -> c.int --- + HttpUriMerge :: proc(mergedUrl: cstring, url: cstring, relativeUrl: cstring, require: ^c.uint, prepare: c.uint, option: c.uint) -> c.int --- + HttpUriSweepPath :: proc(dst: cstring, src: cstring, srcSize: c.uint) -> c.int --- + + // https + /** + * Register RootCA certificate for HTTPS authentication + * + * @param[in] caCertNum - Number of elements of the list referncing to RootCA certificate + * @param[in] caList - List referencing to RootCA certificate + * @param[in] cert - Client certificate + * @param[in] privKey - Private key + * + * @return 0 on success, < 0 on error. + * + * @note SCE_SYSMODULE_HTTPS module must be loaded with ::sceSysmoduleLoadModule to use this function. + */ + HttpsLoadCert :: proc(caCertNum: c.int, caList: [^]SceHttpsData, cert: ^SceHttpsData, privKey: ^SceHttpsData) -> c.int --- + HttpsUnloadCert :: proc() -> c.int --- + HttpsEnableOption :: proc(sslFlags: c.uint) -> c.int --- + HttpsDisableOption :: proc(sslFlags: c.uint) -> c.int --- + HttpsGetSslError :: proc(id: c.int, errNum: ^c.int, detail: ^c.uint) -> c.int --- + HttpsSetSslCallback :: proc(id: c.int, cbfunc: SceHttpsCallback, userArg: rawptr) -> c.int --- + HttpsGetCaList :: proc(caList: ^SceHttpsCaList) -> c.int --- + HttpsFreeCaList :: proc(caList: ^SceHttpsCaList) -> c.int --- + + // cookie + HttpSetCookieEnabled :: proc(id: c.int, enable: c.int) -> c.int --- + HttpGetCookieEnabled :: proc(id: c.int, enable: ^c.int) -> c.int --- + HttpGetCookie :: proc(url: cstring, cookie: cstring, cookieLength: ^c.uint, prepare: c.uint, secure: c.int) -> c.int --- + HttpAddCookie :: proc(url: cstring, cookie: cstring, cookieLength: c.uint) -> c.int --- + HttpSetCookieRecvCallback :: proc(id: c.int, cbfunc: SceHttpCookieRecvCallback, userArg: rawptr) -> c.int --- + HttpSetCookieSendCallback :: proc(id: c.int, cbfunc: SceHttpCookieSendCallback, userArg: rawptr) -> c.int --- +} diff --git a/Http/types.odin b/Http/types.odin new file mode 100644 index 0000000..3318439 --- /dev/null +++ b/Http/types.odin @@ -0,0 +1,270 @@ +package http + +import "base:builtin" +import "core:c" + +SCE_HTTP_DEFAULT_RESOLVER_TIMEOUT : c.uint : (1 * 1000 * 1000) +SCE_HTTP_DEFAULT_RESOLVER_RETRY : c.uint : (5) +SCE_HTTP_DEFAULT_CONNECT_TIMEOUT : c.uint : (30 * 1000 * 1000) +SCE_HTTP_DEFAULT_SEND_TIMEOUT : c.uint : (120 * 1000 * 1000) +SCE_HTTP_DEFAULT_RECV_TIMEOUT : c.uint : (120 * 1000 * 1000) +SCE_HTTP_DEFAULT_RECV_BLOCK_SIZE : c.uint : (1500) +SCE_HTTP_DEFAULT_RESPONSE_HEADER_MAX : c.uint : (5000) +SCE_HTTP_DEFAULT_REDIRECT_MAX : c.uint : (6) +SCE_HTTP_DEFAULT_TRY_AUTH_MAX : c.uint : (6) + +SCE_HTTP_INVALID_ID :: 0 + +// TODO: this should be a c.int +SceHttpErrorCode :: enum i64 { + BEFORE_INIT = 0x80431001, + ALREADY_INITED = 0x80431020, + BUSY = 0x80431021, + OUT_OF_MEMORY = 0x80431022, + NOT_FOUND = 0x80431025, + INVALID_VERSION = 0x8043106A, + INVALID_ID = 0x80431100, + OUT_OF_SIZE = 0x80431104, + INVALID_VALUE = 0x804311FE, + INVALID_URL = 0x80433060, + UNKNOWN_SCHEME = 0x80431061, + NETWORK = 0x80431063, + BAD_RESPONSE = 0x80431064, + BEFORE_SEND = 0x80431065, + AFTER_SEND = 0x80431066, + TIMEOUT = 0x80431068, + UNKOWN_AUTH_TYPE = 0x80431069, + UNKNOWN_METHOD = 0x8043106B, + READ_BY_HEAD_METHOD = 0x8043106F, + NOT_IN_COM = 0x80431070, + NO_CONTENT_LENGTH = 0x80431071, + CHUNK_ENC = 0x80431072, + TOO_LARGE_RESPONSE_HEADER = 0x80431073, + SSL = 0x80431075, + ABORTED = 0x80431080, + UNKNOWN = 0x80431081, + PARSE_HTTP_NOT_FOUND = 0x80432025, + PARSE_HTTP_INVALID_RESPONSE = 0x80432060, + PARSE_HTTP_INVALID_VALUE = 0x804321FE, + RESOLVER_EPACKET = 0x80436001, + RESOLVER_ENODNS = 0x80436002, + RESOLVER_ETIMEDOUT = 0x80436003, + RESOLVER_ENOSUPPORT = 0x80436004, + RESOLVER_EFORMAT = 0x80436005, + RESOLVER_ESERVERFAILURE = 0x80436006, + RESOLVER_ENOHOST = 0x80436007, + RESOLVER_ENOTIMPLEMENTED = 0x80436008, + RESOLVER_ESERVERREFUSED = 0x80436009, + RESOLVER_ENORECORD = 0x8043600A, +} + +// TODO: this should be a c.int +SceHttpsErrorCode :: enum u32 { + CERT = 0x80435060, + HANDSHAKE = 0x80435061, + IO = 0x80435062, + INTERNAL = 0x80435063, + PROXY = 0x80435064, +} + +SceHttpsSslErrorCode :: enum c.uint { + INTERNAL = (0x01), + INVALID_CERT = (0x02), + CN_CHECK = (0x04), + NOT_AFTER_CHECK = (0x08), + NOT_BEFORE_CHECK = (0x10), + UNKNOWN_CA = (0x20), +} + +SCE_HTTP_ENABLE :: (1) +SCE_HTTP_DISABLE :: (0) + +SCE_HTTP_USERNAME_MAX_SIZE :: 256 +SCE_HTTP_PASSWORD_MAX_SIZE :: 256 + +SceHttpStatusCode :: enum c.int { + CONTINUE = 100, + SWITCHING_PROTOCOLS = 101, + PROCESSING = 102, + OK = 200, + CREATED = 201, + ACCEPTED = 202, + NON_AUTHORITATIVE_INFORMATION = 203, + NO_CONTENT = 204, + RESET_CONTENT = 205, + PARTIAL_CONTENT = 206, + MULTI_STATUS = 207, + MULTIPLE_CHOICES = 300, + MOVED_PERMANENTLY = 301, + FOUND = 302, + SEE_OTHER = 303, + NOT_MODIFIED = 304, + USE_PROXY = 305, + TEMPORARY_REDIRECT = 307, + BAD_REQUEST = 400, + UNAUTHORIZED = 401, + PAYMENT_REQUIRED = 402, + FORBIDDDEN = 403, + NOT_FOUND = 404, + METHOD_NOT_ALLOWED = 405, + NOT_ACCEPTABLE = 406, + PROXY_AUTHENTICATION_REQUIRED = 407, + REQUEST_TIME_OUT = 408, + CONFLICT = 409, + GONE = 410, + LENGTH_REQUIRED = 411, + PRECONDITION_FAILED = 412, + REQUEST_ENTITY_TOO_LARGE = 413, + REQUEST_URI_TOO_LARGE = 414, + UNSUPPORTED_MEDIA_TYPE = 415, + REQUEST_RANGE_NOT_SATISFIBLE = 416, + EXPECTATION_FAILED = 417, + UNPROCESSABLE_ENTITY = 422, + LOCKED = 423, + FAILED_DEPENDENCY = 424, + UPGRADE_REQUIRED = 426, + INTERNAL_SERVER_ERROR = 500, + NOT_IMPLEMENTED = 501, + BAD_GATEWAY = 502, + SERVICE_UNAVAILABLE = 503, + GATEWAY_TIME_OUT = 504, + HTTP_VERSION_NOT_SUPPORTED = 505, + INSUFFICIENT_STORAGE = 507, +} + +SceHttpUriBuildType :: enum c.int { + WITH_SCHEME = 0x01, + WITH_HOSTNAME = 0x02, + WITH_PORT = 0x04, + WITH_PATH = 0x08, + WITH_USERNAME = 0x10, + WITH_PASSWORD = 0x20, + WITH_QUERY = 0x40, + WITH_FRAGMENT = 0x80, + WITH_ALL = 0xFFFF, +} + +SceHttpsFlag :: enum c.uint { + SERVER_VERIFY = (0x01), + CLIENT_VERIFY = (0x02), + CN_CHECK = (0x04), + NOT_AFTER_CHECK = (0x08), + NOT_BEFORE_CHECK = (0x10), + KNOWN_CA_CHECK = (0x20), +} + +SceHttpMemoryPoolStats :: struct { + poolSize: c.uint, + maxInuseSize: c.uint, + currentInuseSize: c.uint, + reserved: c.int, +} +#assert(size_of(SceHttpMemoryPoolStats) == 0x10) + +SceHttpMethods :: enum c.int { + GET, + POST, + HEAD, + OPTIONS, + PUT, + DELETE, + TRACE, + CONNECT, +} + +SceHttpUriElement :: struct { + opaque: c.int, // 4 + scheme: cstring, + username: cstring, + password: cstring, + hostname: cstring, + path: cstring, + query: cstring, + fragment: cstring, + port: c.ushort, // 2 + reserved: [10]c.uchar, // 10 +} +when size_of(builtin.rawptr) == 4 { + #assert(size_of(SceHttpUriElement) == 0x2C) +} + +SceHttpVersion :: enum c.int { + VERSION_1_0 = 1, + VERSION_1_1, +} + +SceHttpProxyMode :: enum c.int { + AUTO, + MANUAL, +} + +SceHttpAddHeaderMode :: enum c.int { + OVERWRITE, + ADD, +} + +SceHttpAuthType :: enum c.int { + BASIC, + DIGEST, + RESERVED0, + RESERVED1, + RESERVED2, +} + +SceHttpSslVersion :: enum c.int { + SSLV23, + SSLV2, + SSLV3, + TLSV1, +} + +SceHttpsData :: struct { + ptr: ^c.char, // TODO: multipointer or maybe cstring?? + size: c.uint, +} +when size_of(builtin.rawptr) == 4 { + #assert(size_of(SceHttpsData) == 8) +} + +SceHttpsCaList :: struct { + caCerts: ^rawptr, + caNum: c.int, +} +when size_of(builtin.rawptr) == 4 { + #assert(size_of(SceHttpsCaList) == 8) +} + +/* callbacks */ + +SceHttpAuthInfoCallback :: #type ^proc( + request: c.int, + authType: SceHttpAuthType, + realm: cstring, + username: cstring, + password: cstring, + needEntity: c.int, + entityBody: ^[^]c.uchar, + entitySize: ^c.uint,// TODO:?? + save: ^c.int, + userArg: rawptr, +) -> c.int + +SceHttpRedirectCallback :: #type ^proc( + request: c.int, + statusCode: c.int, + method: ^c.int, + location: cstring, + userArg: rawptr, +) -> c.int + +SceHttpsCallback :: #type ^proc(verifyEsrr: c.uint, sslCert: []rawptr, certNum: c.int, userArg: rawptr) -> c.int + +SceHttpCookieRecvCallback :: #type ^proc( + request: c.int, + url: cstring, + cookieHeader: cstring, + headerLen: c.uint, + userArg: rawptr, +) + +SceHttpCookieSendCallback :: #type ^proc(request: c.int, url: cstring, cookieHeader: cstring, userArg: rawptr) diff --git a/Ime/Ime.odin b/Ime/Ime.odin new file mode 100644 index 0000000..5d611e1 --- /dev/null +++ b/Ime/Ime.odin @@ -0,0 +1,36 @@ +package ime + +import "core:c" +import sce "../common" +import sceClib "../Clib" +import sceCommonDialog "../CommonDialog" + +foreign import ime "system:SceIme_stub" + +sceImeDialogParamInit :: #force_inline proc(param: ^SceImeDialogParam) { + sceClib.Memset(param, 0x0, size_of(SceImeDialogParam)) + sceCommonDialog._sceCommonDialogSetMagicNumber(¶m.commonParam) + param.sdkVersion = sce.PSP2_SDK_VERSION +} + +sceImeParamInit :: #force_inline proc(param: ^SceImeParam) { + sceClib.Memset(param, 0x0, size_of(SceImeParam)) + param.sdkVersion = sce.PSP2_SDK_VERSION +} + + +@(link_prefix = "sceIme") +foreign ime { + sceImeDialogInit :: proc(param: ^SceImeDialogParam) -> sce.Int32 --- + sceImeDialogGetStatus :: proc() -> sceCommonDialog.SceCommonDialogStatus --- + sceImeDialogAbort :: proc() -> sce.Int32 --- + sceImeDialogGetResult :: proc(result: ^SceImeDialogResult) -> sce.Int32 --- + sceImeDialogTerm :: proc() -> sce.Int32 --- + + sceImeOpen :: proc(param: ^SceImeParam) -> sce.Int32 --- + sceImeUpdate :: proc() -> sce.Int32 --- + sceImeSetText :: proc(text: [^]sce.WChar16, length: sce.UInt32) -> sce.Int32 --- + sceImeSetCaret :: proc(caret: ^SceImeCaret) -> sce.Int32 --- + sceImeSetPreeditGeometry :: proc(preedit: ^SceImePreeditGeometry) -> sce.Int32 --- + sceImeClose :: proc() -> sce.Int32 --- +} diff --git a/Ime/types.odin b/Ime/types.odin new file mode 100644 index 0000000..76aea0f --- /dev/null +++ b/Ime/types.odin @@ -0,0 +1,233 @@ +package ime + +import "core:c" +import sce "../common" +import sceCommonDialog "../CommonDialog" + +SCE_IME_DIALOG_MAX_TITLE_LENGTH :: 128 +SCE_IME_DIALOG_MAX_TEXT_LENGTH :: 2048 + +SCE_IME_WORK_BUFFER_SIZE :: (20*1024) + +SCE_IME_MAX_PREEDIT_LENGTH :: (30) +SCE_IME_MAX_TEXT_LENGTH :: (2048) + +// TODO: should be c.int +SceImeDialogErrorCode :: enum c.uint { + PARAM = 0x80102001, + INTERNAL = 0x80102002, + INVALID_DIALOG_MODE = 0x80102003, + INVALID_TEXT_BOX_MODE = 0x80102004, + INVALID_TITLE = 0x80102005 +} + +SceImeDialogDialogMode :: enum c.int { + DEFAULT = 0, + WITH_CANCEL = 1 +} + +SceImeDialogTextboxMode :: enum c.int { + DEFAULT = 0, + PASSWORD = 1, + WITH_CLEAR = 2 +} + +SceImeDialogButton :: enum c.int { + NONE = 0, + CLOSE = 1, + ENTER = 2 +} + +SceImeDialogParam :: struct { + sdkVersion: sce.UInt32, + + inputMethod: sce.UInt32, + supportedLanguages: sce.UInt64, //!< Dialog languages (One or more ::SceImeLanguage) + languagesForced: sce.Bool, + type: sce.UInt32, //!< Dialog type (One of ::SceImeType) + option: sce.UInt32, //!< Dialog options (One or more ::SceImeOption) + filter: SceImeTextFilter, + + dialogMode: sce.UInt32, //!< Dialog mode (One of ::SceImeDialogDialogMode) + textBoxMode: sce.UInt32, //!< Textbox mode (One of ::SceImeDialogTextboxMode) + title: [^]sce.WChar16, + maxTextLength: sce.UInt32, + initialText: [^]sce.WChar16, + inputTextBuffer: [^]sce.WChar16, + + commonParam: sceCommonDialog.SceCommonDialogParam, + + enterLabel: sce.UChar8, + reserved: [35]sce.Char8, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceImeDialogParam) == 0xA8) +} + +SceImeDialogResult :: struct { + result: sce.Int32, + button: sce.Int32, + reserved: [28]sce.Char8, +} +#assert(size_of(SceImeDialogResult) == 0x24) + +// TODO: should be c.int +SceImeErrorCode :: enum c.uint { + ALREADY_OPENED = 0x80100700, + NOT_OPENED = 0x80100701, + INVALID_POINTER = 0x80100702, + INVALID_PARAM = 0x80100703, + NO_MEMORY = 0x80100704, + CONNECTION_FAILED = 0x80100705, + INVALID_TEXT = 0x80100706, + TOO_MANY_REQUESTS = 0x80100707, + INVALID_SIZE = 0x80100710, + INVALID_INPUT_METHOD = 0x80100712, + INVALID_SUPPORTED_LANGUAGES = 0x80100713, + INVALID_TYPE = 0x80100714, + INVALID_OPTION = 0x80100715, + INVALID_WORK = 0x80100716, + INVALID_ARG = 0x80100717, + INVALID_HANDLER = 0x80100718, + INVALID_MAX_TEXT_LENGTH = 0x80100719, + INVALID_INPUT_TEXT_BUFFER = 0x8010071a, + INVALID_RESERVED = 0x8010071b, + INVALID_ENTER_LABEL = 0x8010071c, + INTERNAL = 0x80100750 +} + +SceImeLanguage :: enum c.ulonglong { + DANISH = 0x00000001, + GERMAN = 0x00000002, + ENGLISH = 0x00000004, + SPANISH = 0x00000008, + FRENCH = 0x00000010, + ITALIAN = 0x00000020, + DUTCH = 0x00000040, + NORWEGIAN = 0x00000080, + POLISH = 0x00000100, + PORTUGUESE = 0x00000200, + RUSSIAN = 0x00000400, + FINNISH = 0x00000800, + SWEDISH = 0x00001000, + JAPANESE = 0x00002000, + KOREAN = 0x00004000, + SIMPLIFIED_CHINESE = 0x00008000, + TRADITIONAL_CHINESE = 0x00010000, + PORTUGUESE_BR = 0x00020000, + ENGLISH_GB = 0x00040000, + TURKISH = 0x00080000, +} + +SceImeType :: enum c.int { + DEFAULT = 0, + BASIC_LATIN = 1, + NUMBER = 2, + EXTENDED_NUMBER = 3, + URL = 4, + MAIL = 5 +} + +SceImeEnterLabel :: enum c.int { + DEFAULT = 0, + SEND = 1, + SEARCH = 2, + GO = 3 +} + +SceImeOption :: enum c.int { + MULTILINE = 0x01, + NO_AUTO_CAPITALIZATION = 0x02, + NO_ASSISTANCE = 0x04 +} + +SceImeEvent :: enum c.int { + OPEN = 0, + UPDATE_TEXT = 1, + UPDATE_CARET = 2, + CHANGE_SIZE = 3, + PRESS_CLOSE = 4, + PRESS_ENTER = 5 +} + +SceImeRect :: struct { + x: sce.UInt32, + y: sce.UInt32, + width: sce.UInt32, + height: sce.UInt32, +} +#assert(size_of(SceImeRect) == 0x10) + +SceImeEditText :: struct { + preeditIndex: sce.UInt32, + preeditLength: sce.UInt32, + caretIndex: sce.UInt32, + str: [^]sce.WChar16, + editIndex: sce.UInt32, + editLengthChange: sce.Int32, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceImeEditText) == 0x18) +} + +SceImeEventParam :: struct #raw_union { + rect: SceImeRect, + text: SceImeEditText, + caretIndex: sce.UInt32, + reserved: [40]sce.UChar8, +} +#assert(size_of(SceImeEventParam) == 0x28) + +SceImeEventData :: struct #packed { + id: sce.UInt32, + param: SceImeEventParam, +} +#assert(size_of(SceImeEventData) == 0x2C) + +SceImeCaret :: struct { + x: sce.UInt32, + y: sce.UInt32, + height: sce.UInt32, + index: sce.UInt32, +} +#assert(size_of(SceImeCaret) == 0x10) + +SceImePreeditGeometry :: struct { + x: sce.UInt32, + y: sce.UInt32, + height: sce.UInt32, +} +#assert(size_of(SceImePreeditGeometry) == 0xC) + +SceImeTextFilter :: #type ^proc( + outText: [^]sce.WChar16, + outTextLength: ^sce.UInt32, + srcText: [^]sce.WChar16, + srcTextLength: sce.UInt32) -> sce.UInt32 +SceImeEventHandler :: #type ^proc(arg: rawptr, e: ^SceImeEventData) + +SceImeParam :: struct { + sdkVersion: sce.UInt32, + + inputMethod: sce.UInt32, + supportedLanguages: sce.UInt64, //!< Dialog languages (One or more ::SceImeLanguage) + languagesForced: sce.Bool, + type: sce.UInt32, //!< Dialog type (One of ::SceImeType) + option: sce.UInt32, //!< Dialog options (One or more ::SceImeOption) + + work: rawptr, + arg: rawptr, + handler: SceImeEventHandler, + filter: SceImeTextFilter, + + initialText: [^]sce.WChar16, + maxTextLength: sce.UInt32, + inputTextBuffer: [^]sce.WChar16, + + enterLabel: sce.UChar8, + reserved: [7]sce.UChar8, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceImeParam) == 0x40) +} + diff --git a/IncomingDialog/IncomingDialog.odin b/IncomingDialog/IncomingDialog.odin new file mode 100644 index 0000000..b8aca35 --- /dev/null +++ b/IncomingDialog/IncomingDialog.odin @@ -0,0 +1,45 @@ +package incomingdialog + +import "core:c" +import sce "../common" +import sceClib "../Clib" + +foreign import incomingdialog "system:SceIncomingDialog_stub" + +sceIncomingDialogParamInit :: #force_inline proc(dialogParam: ^SceIncomingDialogParam) { + sceClib.Memset(dialogParam, 0x0, size_of(SceIncomingDialogParam)) + dialogParam.sdkVersion = sce.PSP2_SDK_VERSION +} + +@(link_prefix = "sceIncomingDialog") +foreign incomingdialog { + /** + * Initialize incoming dialog library, init_type must be 1. + */ + Initialize :: proc(init_type: c.int) -> sce.Int32 --- + + /** + * Open incoming dialog. + */ + Open :: proc(dialogParam: ^SceIncomingDialogParam) -> sce.Int32 --- + + /** + * Returns current status of incoming dialog. + */ + GetStatus :: proc() -> sce.Int32 --- + + /** + * Force exit to LiveArea and show dialog window + */ + SwitchToDialog :: proc() -> sce.Int32 --- + + /** + * Close incoming dialog. + */ + Close :: proc() -> sce.Int32 --- + + /** + * Finish incoming dialog library + */ + Finish :: proc() -> sce.Int32 --- +} diff --git a/IncomingDialog/types.odin b/IncomingDialog/types.odin new file mode 100644 index 0000000..c394bad --- /dev/null +++ b/IncomingDialog/types.odin @@ -0,0 +1,42 @@ +package incomingdialog + +import "core:c" +import sce "../common" + +/** + * Dialog status + */ +SceIncomingDialogStatus :: enum c.int { + NOT_RUNNING, + ACCEPTED, + RUNNING, + REJECTED, + CLOSED, + BUSY, + TIMEOUT +} + +/** + * Error Codes + */ +// TODO: should be c.int +SceIncomingDialogErrorCode :: enum c.uint { + INVALID_ARG = 0x80106201 +} + +SceIncomingDialogParam :: struct { + sdkVersion: sce.Int32, + audioPath: [0x80]sce.Char8, //Path to audio file that will be played during dialog, .mp3, .at9, m4a. Can be NULL + titleid: [0x10]sce.Char8, //TitleId of the application to open when "accept" button has been pressed. Can be NULL + unk_BC: sce.Int32, //Can be set to 0 + dialogTimer: sce.UInt32, //Time to show dialog in seconds + reserved1: [0x3E]sce.Char8, + buttonRightText: [0x1F]sce.WChar16, //Text for "accept" button + separator0: sce.Int16, //must be 0 + buttonLeftText: [0x1F]sce.WChar16, //Text for "reject" button. If NULL, only "accept" button will be created + separator1: sce.Int16, //must be 0 + dialogText: [0x80]sce.WChar16, //Text for dialog window, also shared with notification + separator2: sce.Int16, //must be 0 +} +#assert(size_of(SceIncomingDialogParam) == 0x25C) + diff --git a/Io/Io.odin b/Io/Io.odin new file mode 100644 index 0000000..f2957ca --- /dev/null +++ b/Io/Io.odin @@ -0,0 +1,337 @@ +package io + +import "core:c" +import sce "../common" + +foreign import libkernel "system:SceLibKernel_stub" +foreign import iofilemgr "system:SceIofilemgr_stub" + +@(link_prefix = "sceIo") +foreign libkernel { + /** + * Send a devctl command to a device. + * + * @par Example: Sending a simple command to a device + * @code + * SceIoDevInfo info + * sceIoDevctl :: proc("ux00x3001: :",, NULL, 0, &info, sizeof(SceIoDevInfo)) + * @endcode + * + * @ :: procparam dev- String: for the device to send the devctl to (e.g. "ux0:") + * @param cmd - The command to send to the device + * @param indata - A data block to send to the device, if NULL sends no data + * @param inlen - Length of indata, if 0 sends no data + * @param outdata - A data block to receive the result of a command, if NULL receives no -> c.int --- + * @param outlen - Length of outdata, if 0 receives no data + * @return 0 on success, < 0 on error + */ + Devctl :: proc(dev: cstring, cmd: c.uint, indata: rawptr, inlen: c.int, outdata: rawptr, outlen: c.int) -> c.int --- + + /** + * Perform an ioctl on a device. + * + * @param fd - Opened file descriptor to ioctl to + * @param cmd - The command to send to the device + * @param indata - A data block to send to the device, if NULL :: procno: ^sends data + * @param - Length of indata, if 0 sends no data -> c.int --- + * @param outdata - A data block to receive the result of a command, if NULL receives no data + * @param outlen - Length of outdata, if 0 receives no data + * @return 0 on success, < 0 on error + */ + Ioctl :: proc(fd: sce.UID, cmd: c.uint, indata: rawptr, inlen: c.int, outdata: rawptr, outlen: c.int) -> c.int --- + + /** + * Perform an ioctl :: proc a device: c.in. asynchronous: ^) + -> c.int --- + * @param fd - Opened file descriptor to ioctl to + * @param cmd - The command to send to the device + * @param indata - A data block to send to the device, if NULL sends no data + * @param inlen - Length of indata, if 0 sends no data + * @param outdata - A data block to receive the result of a command, if NULL receives no data + * @param outlen - Length of outdata, if 0 receives no data + * @return 0 on success, < 0 on error + */ + IoctlAsync :: proc(fd: sce.UID, cmd: c.uint, indata: rawptr, inlen: c.int, outdata: rawptr, outlen: c.int) -> c.int --- + + /** + * Open a directory + * + * @par Example: + * @code + * int dfd + * dfd = sceIoDopen("device:/") + * if(dfd >= 0) + * { Do something with the file descriptor } + * @endcode + * @param dirname - The directory to open for reading. + * @return If >= 0 then a valid file descriptor, otherwise a Sony error code. + */ + Dopen :: proc(dirname: cstring) -> sce.UID --- + + /** + * Reads an entry from an opened file descriptor. + * + * @param fd - Already opened file descriptor (using ::sceIoDopen) + * @param dir - Pointer to a ::SceIoDirent structure to hold the file information + * + * @return Read status + * - 0 - No more directory entries left + * - > 0 - More directory entries to go + * - < 0 - Error + */ + Dread :: proc(fd: sce.UID, dir: ^SceIoDirent) -> c.int --- + + /** + * Close an opened directory file descriptor + * + * @param fd - Already opened file descriptor (using ::sceIoDopen) + * @return < 0 on error + */ + Dclose :: proc(fd: sce.UID) -> c.int --- + + /** + * Make a directory file + * + * @param dir - The path to the directory + * @param mode - Access mode (One or more ::SceIoAccessMode). + * @return Returns the value 0 if it's successful, otherwise -1 + */ + Mkdir :: proc(dir: cstring, mode: SceIoAccessMode) -> c.int --- + + /** + * Remove a directory file + * + * @param path - Removes a directory file pointed by the string path + * @return Returns the value 0 if it's successful, otherwise -1 + */ + Rmdir :: proc(path: cstring) -> c.int --- + + /** + * Get the status of a file. + * + * @param file - The path to the file. + * @param stat - A pointer to a ::SceIoStat structure. + * + * @return < 0 on error. + */ + Getstat :: proc(file: cstring, stat: ^SceIoStat) -> c.int --- + + /** + * Get the status of a file descriptor. + * + * @param fd - The file descriptor. + * @param stat - A pointer to a ::SceIoStat structure. + * + * @return < 0 on error. + */ + GetstatByFd :: proc(fd: sce.UID, stat: ^SceIoStat) -> c.int --- + + /** + * Change the status of a file. + * + * @param file - The path to the file. + * @param stat - A pointer to a ::SceIoStat structure. + * @param bits - Bitmask defining which bits to change. + * + * @return < 0 on error. + */ + Chstat :: proc(file: cstring, stat: ^SceIoStat, bits: c.int) -> c.int --- + + /** + * Change the status of a file descriptor. + * + * @param fd - The file descriptor. + * @param stat - A pointer to an io_stat_t structure. + * @param bits - Bitmask defining which bits to change. + * + * @return < 0 on error. + */ + ChstatByFd :: proc(fd: sce.UID, buf: ^SceIoStat, cbit: c.uint) -> c.int --- +} + +@(link_prefix = "sceIo") +foreign iofilemgr { + /** + * Open or create a file for reading or writing + * + * @par Example1: Open a file for reading + * @code + * if((fd = sceIoOpen("device:/path/to/file", SCE_O_RDONLY, 0777) < 0) { + * // error code in fd, for example no open filehandle left (0x80010018) + * } + * @endcode + * @par Example2: Open a file for writing, creating it if it doesn't exist + * @code + * if((fd = sceIoOpen("device:/path/to/file", SCE_O_WRONLY|SCE_O_CREAT, 0777) < 0) { + * // error code in fd, for example no open filehandle left (0x80010018) + * } + * @endcode + * + * @param file - Pointer to a string holding the name of the file to open. + * @param flags - Libc styled flags that are or'ed together (One or more ::SceIoMode). + * @param mode - One or more ::SceIoAccessMode flags or'ed together. Can also use Unix absolute permissions. + * @return > 0 is a valid file handle, < 0 on error. + */ + Open :: proc(file: cstring, flags: SceIoMode, mode: sce.Mode) -> sce.UID --- + + /** + * Delete a descriptor + * + * @code + * sceIoClose(fd) + * @endcode + * + * @param fd - File descriptor to close + * @return < 0 on error + */ + Close :: proc(fd: sce.UID) -> c.int --- + + /** + * Read input + * + * @par Example: + * @code + * bytes_read = sceIoRead(fd, data, 100) + * @endcode + * + * @param fd - Opened file descriptor to read from + * @param buf - Pointer to the buffer where the read data will be placed + * @param nbyte - Size of the read in bytes + * + * @return The number of bytes read + */ + Read :: proc(fd: sce.UID, buf: rawptr, nbyte: sce.Size) -> sce.SSize --- + + /** + * Read input at offset + * + * @par Example: + * @code + * bytes_read = sceIoPread(fd, data, 100, 0x1000) + * @endcode + * + * @param fd - Opened file descriptor to read from + * @param data - Pointer to the buffer where the read data will be placed + * @param size - Size of the read in bytes + * @param offset - Offset to read + * + * @return < 0 on error. + */ + Pread :: proc(fd: sce.UID, data: rawptr, size: sce.Size, offset: sce.Off) -> c.int --- + + /** + * Write output + * + * @par Example: + * @code + * bytes_written = sceIoWrite(fd, data, 100) + * @endcode + * + * @param fd - Opened file descriptor to write to + * @param buf - Pointer to the data to write + * @param nbyte - Size of data to write + * + * @return The number of bytes written + */ + Write :: proc(fd: sce.UID, buf: rawptr, nbyte: sce.Size) -> sce.SSize --- + + /** + * Write output at offset + * + * @par Example: + * @code + * bytes_written = sceIoPwrite(fd, data, 100, 0x1000) + * @endcode + * + * @param fd - Opened file descriptor to write to + * @param data - Pointer to the data to write + * @param size - Size of data to write + * @param offset - Offset to write + * + * @return The number of bytes written + */ + Pwrite :: proc(fd: sce.UID, data: rawptr, size: sce.Size, offset: sce.Off) -> c.int --- + + /** + * Reposition read/write file descriptor offset + * + * @par Example: + * @code + * pos = sceIoLseek(fd, -10, SCE_SEEK_END) + * @endcode + * + * @param fd - Opened file descriptor with which to seek + * @param offset - Relative offset from the start position given by whence + * @param whence - One of ::SceIoSeekMode. + * + * @return The position in the file after the seek. + */ + Lseek :: proc(fd: sce.UID, offset: sce.Off, whence: SceIoSeekMode) -> sce.Off --- + + /** + * Reposition read/write file descriptor offset (32bit mode) + * + * @par Example: + * @code + * pos = sceIoLseek32(fd, -10, SCE_SEEK_END) + * @endcode + * + * @param fd - Opened file descriptor with which to seek + * @param offset - Relative offset from the start position given by whence + * @param whence - One of ::SceIoSeekMode. + * + * @return The position in the file after the seek. + */ + Lseek32 :: proc(fd: sce.UID, offset: c.long, whence: SceIoSeekMode) -> c.long --- + + /** + * Remove directory entry + * + * @param file - Path to the file to remove + * @return < 0 on error + */ + Remove :: proc(file: cstring) -> c.int --- + + /** + * Change the name of a file + * + * @param oldname - The old filename + * @param newname - The new filename + * @return < 0 on error. + */ + Rename :: proc(oldname: cstring, newname: cstring) -> c.int --- + + /** + * Synchronize the file data on the device. + * + * @param device - The device to synchronize (e.g. msfat0:) + * @param unk - Unknown + */ + Sync :: proc(device: cstring, flag: c.int) -> c.int --- + + /** + * Synchronize the file data for one file + * + * @param fd - Opened file descriptor to sync + * @param flag - unknown + * + * @return < 0 on error. + */ + SyncByFd :: proc(fd: sce.UID, flag: c.int) -> c.int --- + + /** + * Cancel an asynchronous operation on a file descriptor. + * + * @param fd - The file descriptor to perform cancel on. + * + * @return < 0 on error. + */ + Cancel :: proc(fd: sce.UID) -> c.int --- + + GetPriority :: proc(fd: sce.UID) -> c.int --- + GetProcessDefaultPriority :: proc() -> c.int --- + GetThreadDefaultPriority :: proc() -> c.int --- + SetPriority :: proc(fd: sce.UID, priority: c.int) -> c.int --- + SetProcessDefaultPriority :: proc(priority: c.int) -> c.int --- + SetThreadDefaultPriority :: proc(priority: c.int) -> c.int --- +} diff --git a/Io/types.odin b/Io/types.odin new file mode 100644 index 0000000..d534c23 --- /dev/null +++ b/Io/types.odin @@ -0,0 +1,156 @@ +package io + +import "core:c" +import sce "../common" + +SceIoDevInfo :: struct { + max_size: sce.Off, + free_size: sce.Off, + cluster_size: sce.Size, + unk: rawptr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceIoDevInfo) == 0x18) +} + + +/* Note: Not all of these sceIoOpen() flags are not compatible with the + open() flags found in sys/unistd.h. */ +SceIoMode :: enum c.int { + O_RDONLY = 0x0001, //!< Read-only + O_WRONLY = 0x0002, //!< Write-only + O_RDWR = (O_RDONLY | O_WRONLY), //!< Read/Write + O_NBLOCK = 0x0004, //!< Non blocking + O_DIROPEN = 0x0008, //!< Internal use for ::sceIoDopen + O_RDLOCK = 0x0010, //!< Read locked (non-shared) + O_WRLOCK = 0x0020, //!< Write locked (non-shared) + O_APPEND = 0x0100, //!< Append + O_CREAT = 0x0200, //!< Create + O_TRUNC = 0x0400, //!< Truncate + O_EXCL = 0x0800, //!< Exclusive create + O_SCAN = 0x1000, //!< Scan type + O_RCOM = 0x2000, //!< Remote command entry + O_NOBUF = 0x4000, //!< Number device buffer + O_NOWAIT = 0x8000, //!< Asynchronous I/O + O_FDEXCL = 0x01000000, //!< Exclusive access + O_PWLOCK = 0x02000000, //!< Power control lock + O_FGAMEDATA = 0x40000000 //!< Gamedata access +} + +SceIoSeekMode :: enum c.int { + SET, //!< Starts from the begin of the file + CUR, //!< Starts from current position + END //!< Starts from the end of the file +} + +SceIoDevType :: enum c.int { + NULL = 0x00, //!< Dummy device + CHAR = 0x01, //!< Character device + BLOCK = 0x04, //!< Block device + FS = 0x10, //!< File system device + ALIAS = 0x20, //!< Alias name + MOUNTPT = 0x40 //!< Mount point +} + + +/** + * Access modes for st_mode in ::SceIoStat. + * + * @note + * System always requires RW access. + * For safe homebrew system software will force system permission field to RW. + * For unsafe homebrew, you need to set it yourself `( mode | SCE_S_IWSYS | SCE_S_IRSYS)` + * + */ +SceIoAccessMode :: enum c.int { + S_IXUSR = 000100, //!< User execute permission + S_IWUSR = 000200, //!< User write permission + S_IRUSR = 000400, //!< User read permission + S_IRWXU = 000700, //!< User access rights mask + + S_IXGRP = 000000, //!< Group execute permission. Ignored and reset to 0 by system + S_IWGRP = 000000, //!< Group write permission. Ignored and reset to 0 by system + S_IRGRP = 000000, //!< Group read permission. Ignored and reset to 0 by system + S_IRWXG = 000000, //!< Group access rights mask. Ignored and reset to 0 by system + + S_IXSYS = 000001, //!< System execute permission + S_IWSYS = 000002, //!< System write permission + S_IRSYS = 000004, //!< System read permission + S_IRWXS = 000007, //!< System access rights mask + + // Deprecated + S_IXOTH = 000001, //!< Others execute permission. Deprecated, use ::SCE_S_IXSYS + // Deprecated + S_IWOTH = 000002, //!< Others write permission. Deprecated, use ::SCE_S_IXSYS + // Deprecated + S_IROTH = 000004, //!< Others read permission. Deprecated, use ::SCE_S_IXSYS + // Deprecated + S_IRWXO = 000007, //!< Others access rights mask. Deprecated, use ::SCE_S_IRWXS + + // Deprecated + S_ISVTX = 000000, //!< Sticky. Deprecated + // Deprecated + S_ISGID = 000000, //!< Set GID. Deprecated + // Deprecated + S_ISUID = 000000, //!< Set UID. Deprecated + + S_IFDIR = 0010000, //!< Directory + S_IFREG = 0020000, //!< Regular file + S_IFLNK = 0040000, //!< Symbolic link + S_IFMT = 0170000, //!< Format bits mask +} + +// TODO: +// File mode checking macros +//#define SCE_S_ISLNK(m) (((m) & SCE_S_IFMT) == SCE_S_IFLNK) +//#define SCE_S_ISREG(m) (((m) & SCE_S_IFMT) == SCE_S_IFREG) +//#define SCE_S_ISDIR(m) (((m) & SCE_S_IFMT) == SCE_S_IFDIR) + +/** File modes, used for the st_attr parameter in ::SceIoStat. */ +SceIoFileMode :: enum c.int { + SO_IXOTH = 0x0001, //!< Hidden execute permission + SO_IWOTH = 0x0002, //!< Hidden write permission + SO_IROTH = 0x0004, //!< Hidden read permission + SO_IFLNK = 0x0008, //!< Symbolic link + SO_IFDIR = 0x0010, //!< Directory + SO_IFREG = 0x0020, //!< Regular file + SO_IFMT = 0x0038, //!< Format mask +} + +// TODO: +// File mode checking macros +//#define SCE_SO_ISLNK(m) (((m) & SCE_SO_IFMT) == SCE_SO_IFLNK) +//#define SCE_SO_ISREG(m) (((m) & SCE_SO_IFMT) == SCE_SO_IFREG) +//#define SCE_SO_ISDIR(m) (((m) & SCE_SO_IFMT) == SCE_SO_IFDIR) + +/** Structure to hold the status information about a file */ +SceIoStat :: struct { + st_mode: sce.Mode, //!< One or more ::SceIoAccessMode + st_attr: c.uint, //!< One or more ::SceIoFileMode + st_size: sce.Off, //!< Size of the file in bytes + st_ctime: sce.DateTime, //!< Creation time + st_atime: sce.DateTime, //!< Last access time + st_mtime: sce.DateTime, //!< Last modification time + st_private: [6]c.uint, //!< Device-specific data +} +#assert(size_of(SceIoStat) == 0x58) + +/** Defines for `sceIoChstat` and `sceIoChstatByFd` **/ +SCE_CST_MODE :: 0x0001 +SCE_CST_SIZE :: 0x0004 +SCE_CST_CT :: 0x0008 +SCE_CST_AT :: 0x0010 +SCE_CST_MT :: 0x0020 + + +/** Describes a single directory entry */ +SceIoDirent :: struct { + d_stat: SceIoStat, //!< File status + d_name: [256]c.char, //!< File name + d_private: rawptr, //!< Device-specific data + dummy: c.int, //!< Dummy data +} +when size_of(rawptr) == 4 { + #assert(size_of(SceIoDirent) == 0x160) +} + diff --git a/Jpeg/Jpeg.odin b/Jpeg/Jpeg.odin new file mode 100644 index 0000000..1ab5d2b --- /dev/null +++ b/Jpeg/Jpeg.odin @@ -0,0 +1,258 @@ +package jpeg + +import "core:c" +import sce "../common" + +foreign import jpeg "system:SceJpeg_stub" +foreign import jpegarm "system:SceJpegArm_stub" +foreign import jpegenc "system:SceJpegEnc_stub" +foreign import jpegencarm "system:SceJpegEncArm_stub" + +@(link_prefix = "sceJpeg") +foreign jpeg { + InitMJpeg :: proc(decoderCount: sce.Int32) -> c.int --- + + InitMJpegWithParam :: proc(params: ^SceJpegMJpegInitParam) -> c.int --- + + FinishMJpeg :: proc() -> c.int --- + + GetOutputInfo :: proc(jpegData: [^]sce.UInt8, + jpegSize: sce.Size, + format: sce.Int32, + mode: sce.Int32, + output: ^SceJpegOutputInfo) -> c.int --- + + DecodeMJpegYCbCr :: proc(jpegData: [^]sce.UInt8, + jpegSize: sce.Size, + mode: sce.Int32, + output: [^]sce.UInt8, + outputSize: sce.Size, + buffer: rawptr, + bufferSize: sce.Size) -> c.int --- + + MJpegCsc :: proc(rgba: [^]sce.UInt8, + yuv: [^]sce.UInt8, + yuvSize: sce.Size, + imageWidth: sce.Int32, + format: sce.Int32, + sampling: sce.Int32) -> c.int --- +} + +foreign jpegarm { + sceJpegArmDecodeMJpeg :: proc(pJpeg: [^]sce.UInt8, + isize: sce.Size, + decodeMode: sce.Int, + pRGBA: rawptr, + osize: sce.Size, + pCoefBuffer: rawptr, + coefBufferSize: sce.Size) -> c.int --- + + sceJpegArmDecodeMJpegYCbCr :: proc(pJpeg: [^]sce.UInt8, + isize: sce.Size, + decodeMode: sce.Int, + pYCbCr: [^]sce.UInt8, + osize: sce.Size, + pCoefBuffer: rawptr, + coefBufferSize: sce.Size) -> c.int --- + + sceJpegArmGetOutputInfo :: proc(pJpeg: [^]sce.UInt8, + isize: sce.Size, + decodeMode: sce.Int, + outputFormat: sce.Int, + pOutputInfo: ^SceJpegOutputInfo) -> c.int --- +} + +@(link_prefix = "sceJpegEncoder") +foreign jpegenc { + /** + * Initialize a jpeg encoder + * + * @param[in] _context - A pointer to a big enough allocated memory block + * @param[in] inWidth - Input width in pixels + * @param[in] inHeight - Input height in pixels + * @param[in] pixelformat - A valid ::SceJpegEncoderPixelFormat set of values + * @param[in] outBuffer - A physically continuous memory block 256 bytes aligned + * @param[in] outSize - Output size in bytes + * + * @return 0 on success, < 0 on error. + */ + Init :: proc(_context: SceJpegEncoderContext, inWidth: c.int, inHeight: c.int, pixelformat: SceJpegEncoderPixelFormat, outBuffer: rawptr, outSize: sce.Size) -> c.int --- + + /** + * Initialize a jpeg encoder with param + * + * @param[in] initParam - A pointer to the initialization parameters + * + * @return 0 on success, < 0 on error. + */ + InitWithParam :: proc(_context: SceJpegEncoderContext, initParam: ^SceJpegEncoderInitParam) -> c.int --- + + /** + * Terminate a jpeg encoder + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * + * @return 0 on success, < 0 on error. + */ + End :: proc(_context: SceJpegEncoderContext) -> c.int --- + + /** + * Execute a jpeg encode + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] inBuffer - A physically continuous memory block 256 bytes aligned + * + * @return encoded jpeg size on success, < 0 on error. + */ + Encode :: proc(_context: SceJpegEncoderContext, inBuffer: rawptr) -> c.int --- + + /** + * Set encoder compression ratio + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] ratio - A value between 0 and 255 (higher = better compression, lower = better speed) + * + * @return 0 on success, < 0 on error. + */ + SetCompressionRatio :: proc(_context: SceJpegEncoderContext, ratio: c.int) -> c.int --- + + + /** + * Set encoder output address + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] outBuffer - A physically continuous memory block 256 bytes aligned + * @param[in] outSize - Output buffer size in bytes + * + * @return 0 on success, < 0 on error. + */ + SetOutputAddr :: proc(_context: SceJpegEncoderContext, outBuffer: rawptr, outSize: sce.Size) -> c.int --- + + /** + * Execute a color conversion from ARGB to YCbCr + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] outBuffer - A physical continuous memory block 256 bytes aligned + * @param[in] inBuffer - A pointer to a valid ARGB buffer + * @param[in] inPitch - Input pitch value in pixels + * @param[in] inPixelFormat - A valid ::SceJpegEncoderPixelFormat set of values + * + * @return 0 on success, < 0 on error. + */ + Csc :: proc(_context: SceJpegEncoderContext, outBuffer: rawptr, inBuffer: rawptr, inPitch: c.int, inPixelFormat: SceJpegEncoderPixelFormat) -> c.int --- + + /** + * Return required free size to allocate a jpeg encoder + * + * @return Required free memory size in bytes, < 0 on error. + */ + GetContextSize :: proc() -> c.int --- + + /** + * Set encoder valid region (?) + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] inWidth - Input width in pixels + * @param[in] inHeight - Input height in pixels + * + * @return 0 on success, < 0 on error. + */ + SetValidRegion :: proc(_context: SceJpegEncoderContext, inWidth: c.int, inHeight: c.int) -> c.int --- + + /** + * Set header used for output file + * + * @param[in] _context - A pointer to an already initialized ::SceJpegEncoderContext + * @param[in] mode - One of ::SceJpegEncoderHeaderMode + * + * @return 0 on success, < 0 on error. + */ + SetHeaderMode :: proc(_context: SceJpegEncoderContext, mode: c.int) -> c.int --- +} + +foreign jpegencarm { + /** + * Get required size of _context memory. + * + * @return Required size of allocated memory. + */ + sceJpegArmEncoderGetContextSize :: proc() -> sce.Size --- + + /** + * Initialize a JPEG encoder. + * + * @param[in] _context - An allocated encoder _context of appropriate size. + * @param[in] inWidth - Input width in pixels. + * @param[in] inHeight - Input height in pixels. + * @param[in] pixelformat - One of ::SceJpegArmEncoderPixelFormat. + * @param[in] outBuffer - A sufficiently sized 8 byte aligned output buffer. + * @param[in] outSize - Output buffer size in bytes. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderInit :: proc(_context: SceJpegArmEncoderContext, inWidth: sce.UInt16, inHeight: sce.UInt16, pixelformat: SceJpegArmEncoderPixelFormat, outBuffer: rawptr, outSize: sce.Size) -> c.int --- + + /** + * Terminate a JPEG encoder. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderEnd :: proc(_context: SceJpegArmEncoderContext) -> c.int --- + + /** + * Execute a JPEG encode. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * @param[in] inBuffer - An 8 byte aligned memory block of color data. + * + * @return Encoded JPEG size on success, < 0 on error. + */ + sceJpegArmEncoderEncode :: proc(_context: SceJpegArmEncoderContext, inBuffer: rawptr) -> c.int --- + + /** + * Set the encoder compression ratio. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * @param[in] ratio - A value between 1 and 255 (higher = better compression, lower = better speed). + * + * See @ref SCE_JPEGENCARM_DEFAULT_COMP_RATIO for the default compression ratio. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderSetCompressionRatio :: proc(_context: SceJpegArmEncoderContext, ratio: sce.UInt8) -> c.int --- + + /** + * Set encoder output address. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * @param[in] outBuffer - A sufficiently sized 8 byte aligned output buffer. + * @param[in] outSize - Output buffer size in bytes. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderSetOutputAddr :: proc(_context: SceJpegArmEncoderContext, outBuffer: rawptr, outSize: sce.Size) -> c.int --- + + /** + * Set the region of the image to be encoded as JPEG. The encoded region starts + * from (0,0), which is the top left of the image, and expands outward by regionWidth and regionHeight. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * @param[in] regionWidth - Width of the region in pixels. + * @param[in] regionHeight - Height of the region in pixels. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderSetValidRegion :: proc(_context: SceJpegArmEncoderContext, regionWidth: sce.UInt16, regionHeight: sce.UInt16) -> c.int --- + + /** + * Set header used for output file. + * + * @param[in] _context - An already initialized ::SceJpegArmEncoderContext. + * @param[in] mode - One of ::SceJpegArmEncoderHeaderMode. + * + * @return 0 on success, < 0 on error. + */ + sceJpegArmEncoderSetHeaderMode :: proc(_context: SceJpegArmEncoderContext, mode: SceJpegArmEncoderHeaderMode) -> c.int --- +} diff --git a/Jpeg/types.odin b/Jpeg/types.odin new file mode 100644 index 0000000..49ed3ae --- /dev/null +++ b/Jpeg/types.odin @@ -0,0 +1,146 @@ +package jpeg + +import "core:c" +import sce "../common" + +SceJpegMJpegInitParam :: struct { + size: sce.Size, + decoderCount: sce.Int32, + options: sce.Int32, +} +#assert(size_of(SceJpegMJpegInitParam) == 0xC) + +SceJpegPitch :: struct { + x: sce.UInt32, + y: sce.UInt32, +} +#assert(size_of(SceJpegPitch) == 8) + +SceJpegOutputInfo :: struct { + colorSpace: sce.Int32, + width: sce.UInt16, + height: sce.UInt16, + outputSize: sce.UInt32, + unk_0xc: sce.UInt32, + unk_0x10: sce.UInt32, + pitch: [4]SceJpegPitch, +} +#assert(size_of(SceJpegOutputInfo) == 0x34) + + +SceJpegArmErrorCode :: enum c.int { + OK = 0 +} + + +SceJpegEncoderInitParamOption :: enum c.int { + NONE = 0, //!< Default option + LPDDR2_MEMORY = 1 //!< LPDDR2 memory will be used instead of CDRAM +} + +SceJpegEncoderInitParam :: struct { + size: sce.Size, //!< Size of this structure + inWidth: c.int, //!< Input width in pixels + inHeight: c.int, //!< Input height in pixels + pixelFormat: c.int, //!< A valid ::SceJpegEncoderPixelFormat set of values + outBuffer: rawptr, //!< A physically continuous memory block 256 bytes aligned + outSize: sce.Size, //!< Output size in bytes + option: c.int, //!< Additional options, OR of ::SceJpegEncoderInitParamOption +} +when size_of(rawptr) == 4 { + #assert(size_of(SceJpegEncoderInitParam) == 0x1C) +} + + +SCE_JPEGENCARM_MIN_COMP_RATIO :: 1 //!< Lowest compression ratio, best quality. +SCE_JPEGENCARM_DEFAULT_COMP_RATIO :: 64 //!< Default compression ratio. +SCE_JPEGENCARM_MAX_COMP_RATIO :: 255 //!< Highest compression ratio, lowest quality. + +/** + * Dynamically allocated encoder context. + * + * See @ref sceJpegArmEncoderGetContextSize() for required allocation size. + * The address must be 4 byte aligned. + */ +SceJpegArmEncoderContext :: rawptr +when size_of(rawptr) == 4 { + #assert(size_of(SceJpegArmEncoderContext) == 4) +} + +/** + * Error Codes + */ + // TODO: should be c.int +SceJpegEncArmErrorCode :: enum c.uint { + /** + * The image dimensions given are not supported, or are larger + * than those set at initialization. + */ + IMAGE_SIZE = 0x80650300, + /** + * The output buffer provided is not of sufficient size. + */ + INSUFFICIENT_BUFFER = 0x80650301, + /** + * The compression ratio given is not within the valid range. + */ + INVALID_COMP_RATIO = 0x80650302, + /** + * The pixelformat given is not one of ::SceJpegArmEncoderPixelFormat. + */ + INVALID_PIXELFORMAT = 0x80650303, + /** + * The headerMode given is not one of ::SceJpegArmEncoderHeaderMode. + */ + INVALID_HEADER_MODE = 0x80650304, + /** + * A null or badly aligned pointer was given. + */ + INVALID_POINTER = 0x80650305 +} + +/** + * Pixel Formats + */ +SceJpegArmEncoderPixelFormat :: enum c.int { + YCBCR420 = 8, //!< YCbCr420 format + YCBCR422 = 9 //!< YCbCr422 format +} + +/** + * JPEG Header Modes + */ +SceJpegArmEncoderHeaderMode :: enum c.int { + JPEG = 0, //!< JPEG header mode + MJPEG = 1 //!< MJPEG header mode +} + +SceJpegEncoderContext :: rawptr +when size_of(rawptr) == 4 { + #assert(size_of(SceJpegEncoderContext) == 4) +} + +// TODO: should be c.int +SceJpegEncErrorCode :: enum c.uint { + IMAGE_SIZE = 0x80650200, + INSUFFICIENT_BUFFER = 0x80650201, + INVALID_COMPRATIO = 0x80650202, + INVALID_PIXELFORMAT = 0x80650203, + INVALID_HEADER_MODE = 0x80650204, + INVALID_POINTER = 0x80650205, + NOT_PHY_CONTINUOUS_MEMORY = 0x80650206 +} + +SceJpegEncoderPixelFormat :: enum c.int { + ARGB8888 = 0, //!< ARGB8888 format + YCBCR420 = 8, //!< YCbCr420 format + YCBCR422 = 9, //!< YCbCr422 format + CSC_ARGB_YCBCR = 16 //!< ARGB to YCbCr color conversion flag +} + +SceJpegEncoderHeaderMode :: enum c.int { + JPEG = 0, //!< JPEG header mode + MJPEG = 1 //!< MJPEG header mode +} + + diff --git a/Kernel/Kernel.odin b/Kernel/Kernel.odin new file mode 100644 index 0000000..9ae991e --- /dev/null +++ b/Kernel/Kernel.odin @@ -0,0 +1,804 @@ +package kernel + +import "core:c" +import sce "../common" + +foreign import libkernel "system:SceLibKernel_stub" + +/** Message Pipe status info */ +SceKernelMppInfo :: struct { + size: sce.Size, + mppId: sce.UID, // Needs confirmation + name: [32]c.char, + attr: sce.UInt, + bufSize: c.int, + freeSize: c.int, + numSendWaitThreads: c.int, + numReceiveWaitThreads: c.int, +} +#assert(size_of(SceKernelMppInfo) == 0x3C) + +/** Additional options used when creating rwlock. */ +SceKernelRWLockOptParam :: struct { + /** Size of the ::SceKernelRWLockOptParam structure */ + size: sce.Size, +} +#assert(size_of(SceKernelRWLockOptParam) == 4) + +/** Current state of a rwlock. + * @see sceKernelGetRWLockInfo + */ +SceKernelRWLockInfo :: struct { + /** Size of the ::SceKernelRWLockInfo structure */ + size: sce.Size, + /** The UID of the rwlock */ + rwLockId: sce.UID, + /** NULL-terminated name of the rwlock */ + name: [32]c.char, + /** Attributes */ + attr: sce.UInt32, + /** The current lock count */ + lockCount: sce.Int32, + /** The UID of the current owner of the rwlock with write access, 0 when locked for reads */ + writeOwnerId: sce.UID, + /** The number of threads waiting on the rwlock for read access */ + numReadWaitThreads: sce.UInt32, + /** The number of threads waiting on the rwlock for write access */ + numWriteWaitThreads: sce.UInt32, +} +#assert(size_of(SceKernelRWLockInfo) == 0x3C) + +SceKernelSystemInfo :: struct { + size: sce.Size, + activeCpuMask: sce.UInt32, + + cpuInfo: [4]struct { + idleClock: sce.KernelSysClock, + comesOutOfIdleCount: sce.UInt32, + threadSwitchCount: sce.UInt32, + }, +} +#assert(size_of(SceKernelSystemInfo) == 0x48) + +@(link_prefix = "sceKernel") +foreign libkernel { + /** + * Fills the output buffer with random data. + * + * @param[out] output - Output buffer + * @param[in] size - Size of the output buffer, 64 bytes maximum + * + * @return 0 on success, < 0 on error. + */ + GetRandomNumber :: proc(output: rawptr, size: sce.Size) -> c.int --- + + /** + * Gets the status of a specified callback. + * + * @param cb - The UID of the callback to retrieve info for. + * @param status - Pointer to a status structure. The size parameter should be + * initialised before calling. + * + * @return < 0 on error. + */ + GetCallbackInfo :: proc(cb: sce.UID, infop: ^SceKernelCallbackInfo) -> c.int --- + + /** + * Creates a new condition variable + * + * @par Example: + * @code + * SceUID condId + * condId = sceKernelCreateCond("MyCond", 0, mutexId, NULL) + * @endcode + * + * @param name - Specifies the name of the condition variable + * @param attr - Condition variable attribute flags (normally set to 0) + * @param mutexId - Mutex to be related to the condition variable + * @param option - Condition variable options (normally set to 0) + * @return A condition variable id + */ + CreateCond :: proc(name: cstring, attr: sce.UInt, mutexId: sce.UID, option: ^SceKernelCondOptParam) -> sce.UID --- + + /** + * Waits for a signal of a condition variable + * + * @param condId - The condition variable id returned from ::sceKernelCreateCond + * @param timeout - Timeout in microseconds (assumed) + * @return < 0 On error. + */ + WaitCond :: proc(condId: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Waits for a signal of a condition variable (with callbacks) + * + * @param condId - The condition variable id returned from ::sceKernelCreateCond + * @param timeout - Timeout in microseconds (assumed) + * @return < 0 On error. + */ + WaitCondCB :: proc(condId: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Create an event flag. + * + * @param name - The name of the event flag. + * @param attr - Attributes from ::SceEventFlagAttributes + * @param bits - Initial bit pattern. + * @param opt - Options, set to NULL + * @return < 0 on error. >= 0 event flag id. + * + * @par Example: + * @code + * int evid + * evid = sceKernelCreateEventFlag("wait_event", 0, 0, NULL) + * @endcode + */ + CreateEventFlag :: proc(name: cstring, attr: c.int, bits: c.int, opt: ^SceKernelEventFlagOptParam) -> sce.UID --- + + /** + * Poll an event flag for a given bit pattern. + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag. + * @param bits - The bit pattern to poll for. + * @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together + * @param outBits - The bit pattern that was matched. + * @return < 0 On error + */ + PollEventFlag :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint) -> c.int --- + + /** + * Wait for an event flag for a given bit pattern. + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag. + * @param bits - The bit pattern to poll for. + * @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together + * @param outBits - The bit pattern that was matched. + * @param timeout - Timeout in microseconds + * @return < 0 On error + */ + WaitEventFlag :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint, timeout: ^sce.UInt) -> c.int --- + + /** + * Wait for an event flag for a given bit pattern with callback. + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag. + * @param bits - The bit pattern to poll for. + * @param wait - Wait type, one or more of ::SceEventFlagWaitTypes or'ed together + * @param outBits - The bit pattern that was matched. + * @param timeout - Timeout in microseconds + * @return < 0 On error + */ + WaitEventFlagCB :: proc(evid: c.int, bits: c.uint, wait: c.uint, outBits: ^c.uint, timeout: ^sce.UInt) -> c.int --- + + /** + * Get the status of an event flag. + * + * @param event - The UID of the event. + * @param status - A pointer to a ::SceKernelEventFlagInfo structure. + * + * @return < 0 on error. + */ + GetEventFlagInfo :: proc(event: sce.UID, info: ^SceKernelEventFlagInfo) -> c.int --- + + CreateLwCond :: proc(pWork: ^SceKernelLwCondWork, pName: cstring, attr: c.uint, pLwMutex: ^SceKernelLwMutexWork, pOptParam: ^SceKernelLwCondOptParam) -> c.int --- + DeleteLwCond :: proc(pWork: ^SceKernelLwCondWork) -> c.int --- + SignalLwCond :: proc(pWork: ^SceKernelLwCondWork) -> c.int --- + SignalLwCondAll :: proc(pWork: ^SceKernelLwCondWork) -> c.int --- + SignalLwCondTo :: proc(pWork: ^SceKernelLwCondWork, threadId: sce.UID) -> c.int --- + WaitLwCond :: proc(pWork: ^SceKernelLwCondWork, pTimeout: ^c.uint) -> c.int --- + + CreateLwMutex :: proc(pWork: ^SceKernelLwMutexWork, pName: cstring, attr: c.uint, initCount: c.int, pOptParam: ^SceKernelLwMutexOptParam) -> c.int --- + DeleteLwMutex :: proc(pWork: ^SceKernelLwMutexWork) -> c.int --- + LockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, lockCount: c.int, pTimeout: ^c.uint) -> c.int --- + TryLockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, lockCount: c.int) -> c.int --- + UnlockLwMutex :: proc(pWork: ^SceKernelLwMutexWork, unlockCount: c.int) -> c.int --- + + /** + * Create a message pipe + * + * @param name - Name of the pipe + * @param type - The type of memory attribute to use internally (set to 0x40) + * @param attr - Set to 12 + * @param bufSize - The size of the internal buffer in multiples of 0x1000 (4KB) + * @param opt - Message pipe options (set to NULL) + * + * @return The UID of the created pipe, < 0 on error + */ + CreateMsgPipe :: proc(name: cstring, type: c.int, attr: c.int, bufSize: c.uint, opt: rawptr) -> sce.UID --- + + /** + * Send a message to a pipe + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - async vs sync? use 0 for sync + * @param unk2 - Unknown - use NULL + * @param timeout - Timeout for send in us. use NULL to wait indefinitely + * + * @return 0 on success, < 0 on error + */ + SendMsgPipe :: proc(uid: sce.UID , message: rawptr, size: c.uint, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int --- + + /** + * Send a message to a pipe (with callback) + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - async vs sync? use 0 for sync + * @param unk2 - Unknown - use NULL + * @param timeout - Timeout for send in us. use NULL to wait indefinitely + * + * @return 0 on success, < 0 on error + */ + SendMsgPipeCB :: proc(uid: sce.UID, message: rawptr, size: c.uint, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int --- + + /** + * Try to send a message to a pipe + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - use 0 + * @param unk2 - Unknown - use NULL + * + * @return 0 on success, < 0 on error + */ + TrySendMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr) -> c.int --- + + /** + * Receive a message from a pipe + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - async vs sync? use 0 for sync + * @param unk2 - Unknown - use NULL + * @param timeout - Timeout for receive in us. use NULL to wait indefinitely + * + * @return 0 on success, < 0 on error + */ + ReceiveMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int --- + + /** + * Receive a message from a pipe (with callback) + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - async vs sync? use 0 for sync + * @param unk2 - Unknown - use NULL + * @param timeout - Timeout for receive in us. use NULL to wait indefinitely + * + * @return 0 on success, < 0 on error + */ + ReceiveMsgPipeCB :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr, timeout: ^c.uint) -> c.int --- + + /** + * Receive a message from a pipe + * + * @param uid - The UID of the pipe + * @param message - Pointer to the message + * @param size - Size of the message + * @param unk1 - Unknown - use 0 + * @param unk2 - Unknown - use NULL + * + * @return 0 on success, < 0 on error + */ + TryReceiveMsgPipe :: proc(uid: sce.UID, message: rawptr, size: sce.Size, unk1: c.int, unk2: rawptr) -> c.int --- + + + /** + * Cancel a message pipe + * + * @param uid - UID of the pipe to cancel + * @param psend - Receive number of sending threads, NULL is valid + * @param precv - Receive number of receiving threads, NULL is valid + * + * @return 0 on success, < 0 on error + */ + CancelMsgPipe :: proc(uid: sce.UID, psend: ^c.int, precv: ^c.int) -> c.int --- + + /** + * Get the status of a Message Pipe + * + * @param uid - The uid of the Message Pipe + * @param info - Pointer to a ::SceKernelMppInfo structure + * + * @return 0 on success, < 0 on error + */ + GetMsgPipeInfo :: proc(uid: sce.UID, info: ^SceKernelMppInfo) -> c.int --- + + /** + * Creates a new mutex + * + * @par Example: + * @code + * int mutexid + * mutexid = sceKernelCreateMutex("MyMutex", 0, 1, NULL) + * @endcode + * + * @param name - Specifies the name of the mutex + * @param attr - Mutex attribute flags (normally set to 0) + * @param initCount - Mutex initial value + * @param option - Mutex options (normally set to 0) + * @return A mutex id + */ + CreateMutex :: proc(name: cstring, attr: sce.UInt, initCount: c.int, option: ^SceKernelMutexOptParam) -> sce.UID --- + + /** + * Lock a mutex + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @param lockCount - The value to increment to the lock count of the mutex + * @param timeout - Timeout in microseconds (assumed) + * @return < 0 On error. + */ + LockMutex :: proc(mutexid: sce.UID, lockCount: c.int, timeout: ^c.uint) -> c.int --- + + /** + * Lock a mutex and handle callbacks if necessary. + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @param lockCount - The value to increment to the lock count of the mutex + * @param timeout - Timeout in microseconds (assumed) + * @return < 0 On error. + */ + LockMutexCB :: proc(mutexid: sce.UID, lockCount: c.int, timeout: ^c.uint) -> c.int --- + + /** + * Cancels a mutex + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @param newCount - The new lock count of the mutex + * @param numWaitThreads - Number of threads waiting for the mutex + * @return < 0 On error. + */ + CancelMutex :: proc(mutexid: sce.UID, newCount: c.int, numWaitThreads: ^c.int) -> c.int --- + + /** + * Retrieve information about a mutex. + * + * @param mutexid - UID of the mutex to retrieve info for. + * @param info - Pointer to a ::SceKernelMutexInfo struct to receive the info. + * + * @return < 0 on error. + */ + GetMutexInfo :: proc(mutexid: sce.UID, info: ^SceKernelMutexInfo) -> c.int --- + + /** + * Creates a new rwlock + * + * @par Example: + * @code + * int rwlock_id + * rwlock_id = sceKernelCreateRWLock("MyRWLock", 0, NULL) + * @endcode + * + * @param name - Specifies the name of the rwlock + * @param attr - RWLock attribute flags (normally set to 0) + * @param option - RWLock options (normally set to NULL) + * @return RWLock id on success, < 0 on error + */ + CreateRWLock :: proc(name: cstring, attr: sce.UInt32, opt_param: ^SceKernelRWLockOptParam) -> sce.UID --- + + /** + * Lock a rwlock with read access + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @param timeout - Timeout in microseconds, use NULL to disable it + * @return 0 on success, < 0 on error + */ + LockReadRWLock :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Lock a rwlock with write access + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @param timeout - Timeout in microseconds, use NULL to disable it + * @return 0 on success, < 0 on error + */ + LockWriteRWLock :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Lock a rwlock with read access and handle callbacks + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @param timeout - Timeout in microseconds, use NULL to disable it + * @return 0 on success, < 0 on error + */ + LockReadRWLockCB :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Lock a rwlock with write access and handle callbacks + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @param timeout - Timeout in microseconds, use NULL to disable it + * @return 0 on success, < 0 on error + */ + LockWriteRWLockCB :: proc(rwlock_id: sce.UID, timeout: ^c.uint) -> c.int --- + + /** + * Retrieve information about a rwlock. + * + * @param rwlock_id - UID of the rwlock to retrieve info for. + * @param info - Pointer to a ::SceKernelRWLockInfo struct to receive the info. + * + * @return 0 on success, < 0 on error + */ + GetRWLockInfo :: proc(rwlock_id: sce.UID, info: ^SceKernelRWLockInfo) -> c.int --- + + /** + * Creates a new semaphore + * + * @par Example: + * @code + * int semaid + * semaid = sceKernelCreateSema("MySema", 0, 1, 1, NULL) + * @endcode + * + * @param name - Specifies the name of the sema + * @param attr - Sema attribute flags (normally set to 0) + * @param initVal - Sema initial value + * @param maxVal - Sema maximum value + * @param option - Sema options (normally set to 0) + * @return A semaphore id + */ + CreateSema :: proc(name: cstring, attr: sce.UInt, initVal: c.int, maxVal: c.int, option: ^SceKernelSemaOptParam) -> sce.UID --- + + + /** + * Lock a semaphore + * + * @par Example: + * @code + * sceKernelWaitSema(semaid, 1, 0) + * @endcode + * + * @param semaid - The sema id returned from ::sceKernelCreateSema + * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1) + * @param timeout - Timeout in microseconds (assumed). + * + * @return < 0 on error. + */ + WaitSema :: proc(semaid: sce.UID, signal: c.int, timeout: ^sce.UInt) -> c.int --- + + /** + * Lock a semaphore and handle callbacks if necessary. + * + * @par Example: + * @code + * sceKernelWaitSemaCB(semaid, 1, 0) + * @endcode + * + * @param semaid - The sema id returned from ::sceKernelCreateSema + * @param signal - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1) + * @param timeout - Timeout in microseconds (assumed). + * + * @return < 0 on error. + */ + WaitSemaCB :: proc(semaid: sce.UID, signal: c.int, timeout: ^sce.UInt) -> c.int --- + + /** + * Cancels a semaphore + * + * @param semaid - The sema id returned from ::sceKernelCreateSema + * @param setCount - The new lock count of the semaphore + * @param numWaitThreads - Number of threads waiting for the semaphore + * @return < 0 On error. + */ + CancelSema :: proc(semaid: sce.UID, setCount: c.int, numWaitThreads: ^c.int) -> c.int --- + + /** + * Retrieve information about a semaphore. + * + * @param semaid - UID of the semaphore to retrieve info for. + * @param info - Pointer to a ::SceKernelSemaInfo struct to receive the info. + * + * @return < 0 on error. + */ + GetSemaInfo :: proc(semaid: sce.UID, info: ^SceKernelSemaInfo) -> c.int --- + + /** + * @brief Sleep current thread and wait for a signal. After it receives a signal, the thread wakes up. + * + * This is like a semphore with limit 1. + * If signal was sent before and not consumed before, the function will immediately return. + * @param unk0 unknown parameter. 0 can be used. + * @param delay the delay before wating for a signal + * @param timeout the timeout if it's null, it waits indefinitely. + * @return 0 on success + */ + WaitSignal :: proc(unk0: sce.UInt32, delay: sce.UInt32, timeout: ^sce.UInt32) -> c.int --- + + /** + * Create a thread + * + * @par Example: + * @code + * SceUID thid + * thid = sceKernelCreateThread("my_thread", threadFunc, 0x10000100, 0x10000, 0, 0, NULL) + * @endcode + * + * @param name - An arbitrary thread name. + * @param entry - The thread function to run when started. + * @param initPriority - The initial priority of the thread. Less if higher priority. + * @param stackSize - The size of the initial stack. + * @param attr - The thread attributes, zero or more of ::SceThreadAttributes. + * @param cpuAffinityMask - The CPU affinity mask + * A thread can run only on the cores specified in the CPU affinity mask. + * The CPU affinity mask can be specified by the logical sum of the following macros: + * - SCE_KERNEL_CPU_MASK_USER_0 + * - SCE_KERNEL_CPU_MASK_USER_1 + * - SCE_KERNEL_CPU_MASK_USER_2 + * - SCE_KERNEL_CPU_MASK_SYSTEM (system-reserved core) + * The following macro are also available to represent all available in userland CPU cores: + * - SCE_KERNEL_CPU_MASK_USER_ALL + * The following macro are also available to inherit affinity mask of the calling process: + * - SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT + * @param option - Additional options specified by ::SceKernelThreadOptParam. + + * @return UID of the created thread, or an error code. + */ + CreateThread :: proc(name: cstring, entry: SceKernelThreadEntry, initPriority: c.int, stackSize: sce.Size, attr: sce.UInt, cpuAffinityMask: c.int, option: ^SceKernelThreadOptParam) -> sce.UID --- + + + /** + * Start a created thread + * + * @param thid - Thread id from ::sceKernelCreateThread + * @param arglen - Length of the data pointed to by argp, in bytes + * @param argp - Pointer to the arguments. + */ + StartThread :: proc(thid: sce.UID, arglen: sce.Size, argp: rawptr) -> c.int --- + + + /** + * Wait until a thread has ended. + * + * @param thid - Id of the thread to wait for. + * @param stat - Exit status. + * @param timeout - Timeout in microseconds (assumed). + * + * @return < 0 on error. + */ + WaitThreadEnd :: proc(thid: sce.UID, stat: ^c.int, timeout: ^sce.UInt) -> c.int --- + + /** + * Wait until a thread has ended and handle callbacks if necessary. + * + * @param thid - Id of the thread to wait for. + * @param stat - Exit status. + * @param timeout - Timeout in microseconds (assumed). + * + * @return < 0 on error. + */ + WaitThreadEndCB :: proc(thid: sce.UID, stat: ^c.int, timeout: ^sce.UInt) -> c.int --- + + /** + * Modify the attributes of the current thread. + * + * @param clearAttr - The thread attributes to clear. One of ::SceThreadAttributes. + * @param setAttr - The thread attributes to set. One of ::SceThreadAttributes. + * + * @return < 0 on error. + */ + ChangeCurrentThreadAttr :: proc(clearAttr: sce.UInt, setAttr: sce.UInt) -> c.int --- + + + /** + * Get the current priority of the thread you are in. + * + * @return The current thread priority + */ + GetThreadCurrentPriority :: proc() -> c.int --- + + /** + * Get the exit status of a thread. + * + * @param[in] thid - The UID of the thread to check. + * @param[out] status - Status out pointer + * @return The exit status + */ + GetThreadExitStatus :: proc(thid: sce.UID, status: ^c.int) -> c.int --- + + /** + * Check the thread stack? + * + * @return Unknown. + */ + CheckThreadStack :: proc() -> c.int --- + + + /** + * Get the status information for the specified thread. + * + * @param thid - Id of the thread to get status + * @param info - Pointer to the info structure to receive the data. + * Note: The structures size field should be set to + * sizeof(SceKernelThreadInfo) before calling this function. + * + * @par Example: + * @code + * SceKernelThreadInfo status + * status.size = sizeof(SceKernelThreadInfo) + * if(sceKernelGetThreadInfo(thid, &status) == 0) + * { Do something... } + * @endcode + * @return 0 if successful, otherwise the error code. + */ + GetThreadInfo :: proc(thid: sce.UID, info: ^SceKernelThreadInfo) -> c.int --- + + /** + * Retrive the runtime status of a thread. + * + * @param thid - UID of the thread to retrieve status. + * @param status - Pointer to a ::SceKernelThreadRunStatus struct to receive the runtime status. + * + * @return 0 if successful, otherwise the error code. + */ + GetThreadRunStatus :: proc(thid: sce.UID, status: ^SceKernelThreadRunStatus) -> c.int --- + + /** + * Get the current thread Id + * + * @return The thread id of the calling thread. + */ + GetThreadId :: proc() -> c.int --- + + /** + * Get the system information + * + * @param info - Pointer to a ::SceKernelSystemInfo structure + * + * @return 0 on success, < 0 on error + */ + GetSystemInfo :: proc(info: ^SceKernelSystemInfo) -> c.int --- + + /** + * @brief sceKernelGetTLSAddr get pointer to TLS key area for current thread + * @param key - the TLS keyslot index + * @return pointer to TLS key value + */ + GetTLSAddr :: proc(key: c.int) -> rawptr --- + + AtomicSet8 :: proc(store: ^sce.Int8, value: sce.Int8) --- + AtomicSet16 :: proc(store: sce.Int16, value: sce.Int16) --- + AtomicSet32 :: proc(store: sce.Int32, value: sce.Int32) --- + AtomicSet64 :: proc(store: sce.Int64, value: sce.Int64) --- + + AtomicCompareAndSet8 :: proc(store: sce.Int8, value, SceInt8, new_value: sce.Int8) -> sce.Int8 --- + AtomicCompareAndSet16 :: proc(store: sce.Int16, value, SceInt16, new_value: sce.Int16) -> sce.Int16 --- + AtomicCompareAndSet32 :: proc(store: sce.Int32, value, SceInt32, new_value: sce.Int32) -> sce.Int32 --- + AtomicCompareAndSet64 :: proc(store: sce.Int64, value, SceInt64, new_value: sce.Int64) -> sce.Int64 --- + + + AtomicAddAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicAddAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicAddAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicAddAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicAddUnless8 :: proc(store: sce.Int8, value: sce.Int8, cmpv: sce.Int8) -> sce.Bool --- + AtomicAddUnless16 :: proc(store: sce.Int16, value: sce.Int16, cmpv: sce.Int16) -> sce.Bool --- + AtomicAddUnless32 :: proc(store: sce.Int32, value: sce.Int32, cmpv: sce.Int32) -> sce.Bool --- + AtomicAddUnless64 :: proc(store: sce.Int64, value: sce.Int64, cmpv: sce.Int64) -> sce.Bool --- + + AtomicSubAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicSubAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicSubAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicSubAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicAndAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicAndAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicAndAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicAndAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicOrAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicOrAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicOrAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicOrAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicXorAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicXorAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicXorAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicXorAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicClearAndGet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicClearAndGet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicClearAndGet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicClearAndGet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + + AtomicGetAndSet8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndSet16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndSet32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndSet64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndAdd8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndAdd16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndAdd32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndAdd64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndSub8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndSub16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndSub32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndSub64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndAnd8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndAnd16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndAnd32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndAnd64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndOr8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndOr16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndOr32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndOr64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndXor8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndXor16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndXor32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndXor64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + AtomicGetAndClear8 :: proc(store: sce.Int8, value: sce.Int8) -> sce.Int8 --- + AtomicGetAndClear16 :: proc(store: sce.Int16, value: sce.Int16) -> sce.Int16 --- + AtomicGetAndClear32 :: proc(store: sce.Int32, value: sce.Int32) -> sce.Int32 --- + AtomicGetAndClear64 :: proc(store: sce.Int64, value: sce.Int64) -> sce.Int64 --- + + + AtomicClearMask8 :: proc(store: sce.Int8, value: sce.Int8) --- + AtomicClearMask16 :: proc(store: sce.Int16, value: sce.Int16) --- + AtomicClearMask32 :: proc(store: sce.Int32, value: sce.Int32) --- + AtomicClearMask64 :: proc(store: sce.Int64, value: sce.Int64) --- + + AtomicDecIfPositive8 :: proc(store: ^sce.Int8) -> sce.Int8 --- + AtomicDecIfPositive16 :: proc(store: ^sce.Int16) -> sce.Int16 --- + AtomicDecIfPositive32 :: proc(store: ^sce.Int32) -> sce.Int32 --- + AtomicDecIfPositive64 :: proc(store: ^sce.Int64) -> sce.Int64 --- + + + LoadModule :: proc(path: cstring, flags: c.int, option: ^SceKernelLMOption) -> sce.UID --- + UnloadModule :: proc(modid: sce.UID, flags: c.int, option: ^SceKernelULMOption) -> c.int --- + + StartModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: rawptr, status: ^c.int) -> c.int --- + StopModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: rawptr, status: ^c.int) -> c.int --- + + LoadStartModule :: proc(path: cstring, args: sce.Size, argp: rawptr, flags: c.int, option: ^SceKernelLMOption, status: ^c.int) -> sce.UID --- + StopUnloadModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: c.int, option: ^SceKernelULMOption, status: ^c.int) -> c.int --- + + /** + * Exit current Process with specified return code + * + * @param[in] res - Exit code to return + * + * @return 0 on success, < 0 on error. + */ + ExitProcess :: proc(res: c.int) -> c.int --- + + /** + * Get the process time of the current process. + * + * @param[out] type - Pointer to a ::SceKernelSysClock structure which will receive the process time. + * + * @return 0 on success, < 0 on error. + */ + GetProcessTime :: proc(pSysClock: ^sce.KernelSysClock) -> c.int --- + + /** + * Get the lower 32 bits part of process time of the current process. + * + * @return process time of the current process + */ + GetProcessTimeLow :: proc() -> sce.UInt32 --- + + /** + * Get the process time of the current process. + * + * @return process time of the current process + */ + GetProcessTimeWide :: proc() -> sce.UInt64 --- + + + + GetOpenPsId :: proc(id: ^SceKernelOpenPsId) -> c.int --- +} diff --git a/Kernel/Modulemgr.odin b/Kernel/Modulemgr.odin new file mode 100644 index 0000000..2c16a23 --- /dev/null +++ b/Kernel/Modulemgr.odin @@ -0,0 +1,48 @@ +package kernel + +import "core:c" +import sce "../common" + +foreign import modulemgr "system:SceKernelModulemgr_stub" + +// missing structs +SceKernelLoadModuleOption :: struct {} +SceKernelUnloadModuleOption :: struct {} +SceKernelLibraryInfo :: struct {} + +@(link_prefix = "sceKernel") +foreign modulemgr { + GetModuleInfo :: proc(uid: sce.UID, info: ^SceKernelModuleInfo) -> c.int --- + GetModuleList :: proc(type: sce.UInt8, uids: [^]sce.UID, num: ^sce.Size) -> c.int --- + + /** + * Gets system firmware information. + * + * @param[out] version - System sw version. + * + * @note - If you spoofed the firmware version it will return the spoofed firmware. + */ + GetSystemSwVersion :: proc(version: ^SceKernelSystemSwVersion) -> c.int --- + + @(link_name = "_sceKernelLoadModule") + _LoadModule :: proc(module_filename: cstring, flags: sce.UInt32, option: ^SceKernelLoadModuleOption) -> sce.UID --- + @(link_name = "_sceKernelLoadStartModule") + _LoadStartModule :: proc(module_filename: cstring, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID --- + @(link_name = "_sceKernelUnloadModule") + _UnloadModule :: proc(uid: sce.UID, flags: sce.UInt32, option: ^SceKernelUnloadModuleOption) -> c.int --- + @(link_name = "_sceKernelStopModule") + _StopModule :: proc(uid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> c.int --- + @(link_name = "_sceKernelStopUnloadModule") + _StopUnloadModule :: proc(uid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> c.int --- + + @(link_name = "_sceKernelOpenModule") + _OpenModule :: proc(module_filename: cstring, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID --- + @(link_name = "_sceKernelCloseModule") + _CloseModule :: proc(modid: sce.UID, args: sce.Size, argp: rawptr, flags: sce.UInt32) -> sce.UID --- + + GetLibraryInfoByNID :: proc(modid: sce.UID, libnid: sce.NID, info: ^SceKernelLibraryInfo) -> c.int --- + + IsCalledFromSysModule :: proc(lr: rawptr) -> c.int --- + GetModuleIdByAddr :: proc(addr: rawptr) -> sce.UID --- + GetAllowedSdkVersionOnSystem :: proc() -> sce.UInt32 --- +} diff --git a/Kernel/Processmgr.odin b/Kernel/Processmgr.odin new file mode 100644 index 0000000..474e991 --- /dev/null +++ b/Kernel/Processmgr.odin @@ -0,0 +1,50 @@ +package kernel + +import "core:c" +import sce "../common" + +foreign import processmgr "system:SceProcessmgr_stub" + +@(link_prefix = "sceKernel") +foreign processmgr { + /** + * Cancel specified idle timers to prevent entering in power save processing. + * + * @param[in] type - One of ::SceKernelPowerTickType + * + * @return 0 + */ + PowerTick :: proc(type: SceKernelPowerTickType) -> c.int --- + + /** + * Locks certain timers from triggering. + * + * @param[in] type - One of ::SceKernelPowerTickType + * + * @return 0 + */ + PowerLock :: proc(type: SceKernelPowerTickType) -> c.int --- + + /** + * Unlocks certain timers. + * + * @param[in] type - One of ::SceKernelPowerTickType + * + * @return 0 + */ + PowerUnlock :: proc(type: SceKernelPowerTickType) -> c.int --- + + GetCurrentProcess :: proc() -> sce.UID --- + GetRemoteProcessTime :: proc(processId: sce.UID, pClock: ^sce.KernelSysClock) -> sce.Int32 --- + + GetStderr :: proc() -> sce.UID --- + GetStdin :: proc() -> sce.UID --- + GetStdout :: proc() -> sce.UID --- + + GetProcessParam :: proc() -> rawptr --- + + LibcClock :: proc() -> SceKernelClock --- + LibcTime :: proc(tloc: ^SceKernelTime) -> SceKernelTime --- + + LibcGettimeofday :: proc(tv: ^SceKernelTimeval, tz: ^SceKernelTimezone) -> c.int --- +} diff --git a/Kernel/Sysmem.odin b/Kernel/Sysmem.odin new file mode 100644 index 0000000..83baac0 --- /dev/null +++ b/Kernel/Sysmem.odin @@ -0,0 +1,79 @@ +package kernel + +import "core:c" +import sce "../common" + +foreign import sysmem "system:SceSysmem_stub" + +@(link_prefix = "sceKernel") +foreign sysmem { + GetCpuId :: proc() -> c.int --- + + /** + * Allocates a new memory block + * + * @param[in] name - Name for the memory block + * @param[in] type - Type of the memory to allocate. Use `SCE_KERNEL_MEMBLOCK_TYPE_USER_*`. + * @param[in] size - Size of the memory to allocate + * @param[in] opt - Memory block options? + * + * @return SceUID of the memory block on success, < 0 on error. + */ + AllocMemBlock :: proc(name: cstring, type: SceKernelMemBlockType, size: sce.Size, opt: ^SceKernelAllocMemBlockOpt) -> sce.UID --- + + /** + * Frees new memory block + * + * @param[in] uid - SceUID of the memory block to free + * + * @return 0 on success, < 0 on error. + */ + FreeMemBlock :: proc(uid: sce.UID) -> c.int --- + + /** + * Gets the base address of a memory block + * + * @param[in] uid - SceUID of the memory block to free + * @param[out] base - Base address of the memory block identified by SceUID + * + * @return 0 on success, < 0 on error. + */ + GetMemBlockBase :: proc(uid: sce.UID, base: ^rawptr) -> c.int --- + + FindMemBlockByAddr :: proc(addr: rawptr, size: sce.Size) -> sce.UID --- + + GetMemBlockInfoByAddr :: proc(base: rawptr, info: ^SceKernelMemBlockInfo) -> c.int --- + GetMemBlockInfoByRange :: proc(base: rawptr, size: sce.Size, info: ^SceKernelMemBlockInfo) -> c.int --- + + AllocMemBlockForVM :: proc(name: cstring, size: sce.Size) -> sce.UID --- + SyncVMDomain :: proc(uid: sce.UID, data: rawptr, size: sce.Size) -> c.int --- + OpenVMDomain :: proc() -> c.int --- + CloseVMDomain :: proc() -> c.int --- + + OpenMemBlock :: proc(name: cstring, flags: c.int) -> c.int --- + CloseMemBlock :: proc(uid: sce.UID) -> c.int --- + + /** + * Get the model number of the device + * + * @return A value from SCE_KERNEL_MODEL + */ + GetModelForCDialog :: proc() -> c.int --- + + /** + * Get the model number of the device + * + * @return A value from SCE_KERNEL_MODEL + */ + GetModel :: proc() -> c.int --- + + /** + * Get free memory size in bytes + * + * @param[out] info - Returned free memory size for different kind of memory block types + * @return 0 on success, < 0 on error. + */ + GetFreeMemorySize :: proc(info: ^SceKernelFreeMemorySizeInfo) -> c.int --- + + IsPSVitaTV :: proc() -> c.int --- +} diff --git a/Kernel/ThreadMgr.odin b/Kernel/ThreadMgr.odin new file mode 100644 index 0000000..3e6c857 --- /dev/null +++ b/Kernel/ThreadMgr.odin @@ -0,0 +1,433 @@ +package kernel + +import "core:c" +import sce "../common" + +foreign import threadmgr "system:SceKernelThreadMgr_stub" + +@(link_prefix = "sceKernel") +foreign threadmgr { + /** + * Create callback + * + * @par Example: + * @code + * int cbid + * cbid = sceKernelCreateCallback("Exit Callback", 0, exit_cb, NULL) + * @endcode + * + * @param name - A textual name for the callback + * @param attr - ? + * @param func - A pointer to a function that will be called as the callback + * @param userData - User defined data to be passed to the callback. + * + * @return >= 0 A callback id which can be used in subsequent functions, < 0 an error. + */ + CreateCallback :: proc(name: cstring, attr: c.uint, func: SceKernelCallbackFunction, userData: rawptr) -> c.int --- + + /** + * Delete a callback + * + * @param cb - The UID of the specified callback + * + * @return 0 on success, < 0 on error + */ + DeleteCallback :: proc(cb: sce.UID) -> c.int --- + + /** + * Notify a callback + * + * @param cb - The UID of the specified callback + * @param arg2 - Passed as arg2 into the callback function + * + * @return 0 on success, < 0 on error + */ + NotifyCallback :: proc(cb: sce.UID, arg2: c.int) -> c.int --- + + /** + * Cancel a callback ? + * + * @param cb - The UID of the specified callback + * + * @return 0 on success, < 0 on error + */ + CancelCallback :: proc(cb: sce.UID) -> c.int --- + + /** + * Get the callback count + * + * @param cb - The UID of the specified callback + * + * @return The callback count, < 0 on error + */ + GetCallbackCount :: proc(cb: sce.UID) -> c.int --- + + /** + * Check callback ? + * + * @return Something or another + */ + CheckCallback :: proc() -> c.int --- + + /** + * Destroy a condition variable + * + * @param condition variableid - The condition variable id returned from ::sceKernelCreateCond + * @return Returns the value 0 if it's successful, otherwise -1 + */ + DeleteCond :: proc(condId: sce.UID) -> c.int --- + + /** + * Open a condition variable + * + * @param name - The name of the condition variable to open + * @return Returns the value 0 if it's successful, otherwise -1 + */ + OpenCond :: proc(name: cstring) -> c.int --- + + /** + * Close a condition variable + * + * @param condition variableid - The condition variable id returned from ::sceKernelCreateCond + * @return Returns the value 0 if it's successful, otherwise -1 + */ + CloseCond :: proc(condId: sce.UID) -> c.int --- + + /** + * Signals a condition variable + * + * @param condId - The condition variable id returned from ::sceKernelCreateCond + * @return < 0 On error. + */ + SignalCond :: proc(condId: sce.UID) -> c.int --- + + /** + * Signals a condition variable to all threads waiting for it + * + * @param condId - The condition variable id returned from ::sceKernelCreateCond + * @return < 0 On error. + */ + SignalCondAll :: proc(condId: sce.UID) -> c.int --- + + /** + * Signals a condition variable to a specific thread waiting for it + * + * @param condId - The condition variable id returned from ::sceKernelCreateCond + * @param threadId - The thread id returned from ::sceKernelCreateThread + * @return < 0 On error. + */ + SignalCondTo :: proc(condId: sce.UID, threadId: sce.UID) -> c.int --- + + /** + * Set an event flag bit pattern. + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag. + * @param bits - The bit pattern to set. + * + * @return < 0 On error + */ + SetEventFlag :: proc(evid: sce.UID, bits: c.uint) -> c.int --- + + /** + * Clear a event flag bit pattern + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag + * @param bits - The bits to clean + * + * @return < 0 on Error + */ + ClearEventFlag :: proc(evid: sce.UID, bits: c.uint) -> c.int --- + + /** + * Delete an event flag + * + * @param evid - The event id returned by ::sceKernelCreateEventFlag. + * + * @return < 0 On error + */ + DeleteEventFlag :: proc(evid: c.int) -> c.int --- + + /** + * Delete a message pipe + * + * @param uid - The UID of the pipe + * + * @return 0 on success, < 0 on error + */ + DeleteMsgPipe :: proc(uid: sce.UID) -> c.int --- + + /** + * Destroy a mutex + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @return Returns the value 0 if it's successful, otherwise -1 + */ + DeleteMutex :: proc(mutexid: sce.UID) -> c.int --- + + + /** + * Open a mutex + * + * @param name - The name of the mutex to open + * @return Returns the value 0 if it's successful, otherwise -1 + */ + OpenMutex :: proc(name: cstring) -> c.int --- + + /** + * Close a mutex + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @return Returns the value 0 if it's successful, otherwise -1 + */ + CloseMutex :: proc(mutexid: sce.UID) -> c.int --- + + + /** + * Try to lock a mutex (non-blocking) + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @param lockCount - The value to increment to the lock count of the mutex + * @return < 0 On error. + */ + TryLockMutex :: proc(mutexid: sce.UID, lockCount: c.int) -> c.int --- + + /** + * Try to unlock a mutex (non-blocking) + * + * @param mutexid - The mutex id returned from ::sceKernelCreateMutex + * @param unlockCount - The value to decrement to the lock count of the mutex + * @return < 0 On error. + */ + UnlockMutex :: proc(mutexid: sce.UID, unlockCount: c.int) -> c.int --- + + /** + * Destroy a rwlock + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + DeleteRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + + /** + * Open a rwlock + * + * @param name - The name of the rwlock to open + * @return RWLock id on success, < 0 on error + */ + OpenRWLock :: proc(name: cstring) -> sce.UID --- + + /** + * Close a rwlock + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + CloseRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + /** + * Try to lock a rwlock with read access (non-blocking) + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + TryLockReadRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + + /** + * Try to lock a rwlock with write access (non-blocking) + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + TryLockWriteRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + + /** + * Try to unlock a rwlock with read access (non-blocking) + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + UnlockReadRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + + /** + * Try to unlock a rwlock with write access (non-blocking) + * + * @param rwlock_id - The rwlock id returned from ::sceKernelCreateRWLock + * @return 0 on success, < 0 on error + */ + UnlockWriteRWLock :: proc(rwlock_id: sce.UID) -> c.int --- + + /** + * Destroy a semaphore + * + * @param semaid - The semaid returned from a previous create call. + * @return Returns the value 0 if it's successful, otherwise -1 + */ + DeleteSema :: proc(semaid: sce.UID) -> c.int --- + + /** + * Send a signal to a semaphore + * + * @par Example: + * @code + * // Signal the sema + * sceKernelSignalSema(semaid, 1) + * @endcode + * + * @param semaid - The sema id returned from ::sceKernelCreateSema + * @param signal - The amount to signal the sema (i.e. if 2 then increment the sema by 2) + * + * @return < 0 On error. + */ + SignalSema :: proc(semaid: sce.UID, signal: c.int) -> c.int --- + + /** + * Poll a semaphore. + * + * @param semaid - UID of the semaphore to poll. + * @param signal - The value to test for. + * + * @return < 0 on error. + */ + PollSema :: proc(semaid: sce.UID, signal: c.int) -> c.int --- + + OpenSema :: proc(name: cstring) -> sce.UID --- + + CloseSema :: proc(semaid: sce.UID) -> c.int --- + + /** + * @brief Send a signal to the thread specified by thid. Note that it can send a signal to the current thread as well. + * + * @param thid - the id of the thread to send a signal to + * @return 0 on success + * @return SCE_KERNEL_ERROR_ALREADY_SENT if the last signal was not consumed by sceKernelWaitSignal + */ + SendSignal :: proc(thid: sce.UID) -> c.int --- + + /** + * Delate a thread + * + * @param thid - UID of the thread to be deleted. + * + * @return < 0 on error. + */ + DeleteThread :: proc(thid: sce.UID) -> c.int --- + + + /** + * Exit a thread + * + * @param status - Exit status. + */ + ExitThread :: proc(status: c.int) -> c.int --- + + + /** + * Exit a thread and delete itself. + * + * @param status - Exit status + */ + ExitDeleteThread :: proc(status: c.int) -> c.int --- + + /** + * Delay the current thread by a specified number of microseconds + * + * @param delay - Delay in microseconds. + * + * @par Example: + * @code + * sceKernelDelayThread(1000000) // Delay for a second + * @endcode + */ + DelayThread :: proc(delay: sce.UInt) -> c.int --- + + /** + * Delay the current thread by a specified number of microseconds and handle any callbacks. + * + * @param delay - Delay in microseconds. + * + * @par Example: + * @code + * sceKernelDelayThread(1000000) // Delay for a second + * @endcode + */ + DelayThreadCB :: proc(delay: sce.UInt) -> c.int --- + + /** + * Change the threads current priority. + * + * @param thid - The ID of the thread (from ::sceKernelCreateThread or ::sceKernelGetThreadId) + * @param priority - The new priority (the lower the number the higher the priority) + * + * @par Example: + * @code + * int thid = sceKernelGetThreadId() + * // Change priority of current thread to 16 + * sceKernelChangeThreadPriority(thid, 16) + * @endcode + * + * @return 0 if successful, otherwise the error code. + */ + ChangeThreadPriority :: proc(thid: sce.UID, priority: c.int) -> c.int --- + + + /** + * Get the free stack size for a thread. + * + * @param thid - The thread ID + * + * @return The free size. + */ + GetThreadStackFreeSize :: proc(thid: sce.UID) -> c.int --- + + /** + * Retrive the cpu affinity mask of a thread. + * + * @param thid - UID of the thread to retrieve affinity mask for. + * + * @return current affinity mask if >= 0, otherwise the error code. + */ + GetThreadCpuAffinityMask :: proc(thid: sce.UID) -> c.int --- + + /** + * Set the cpu affinity mask of a thread. + * + * @param thid - UID of the thread to retrieve affinity mask for. + * @param mask - New cpu affinity mask. + * + * @return 0 if successful, otherwise the error code. + */ + ChangeThreadCpuAffinityMask :: proc(thid: sce.UID, mask: c.int) -> c.int --- + + /** + * Get the process ID of in the running thread. + * + * @return process ID of in the running thread + */ + GetProcessId :: proc() -> sce.UID --- + + /** + * Get the type of a Threadmgr uid + * + * @param uid - The uid to get the type from + * + * @return The type, < 0 on error + */ + GetThreadmgrUIDClass :: proc(uid: sce.UID) -> SceKernelIdListType --- + + + /** + * @brief sceKernelGetThreadTLSAddr gets an address to a 4 bytes area of TLS memory for the specified thread + * @param thid - The UID of the thread to access TLS + * @param key - the TLS keyslot index + * @return pointer to TLS memory + */ + GetThreadTLSAddr :: proc(thid: sce.UID, key: c.int) -> rawptr --- + + + /** + * Get the system time (wide version) + * + * @return The system time + */ + GetSystemTimeWide :: proc() -> sce.Int64 --- + +} diff --git a/Kernel/types.odin b/Kernel/types.odin new file mode 100644 index 0000000..a82e76b --- /dev/null +++ b/Kernel/types.odin @@ -0,0 +1,953 @@ +package kernel + +import "core:c" +import sce "../common" + +// TODO: this should be a c.int +SceKernelErrorCode :: enum i64 { + OK = 0x0, + ERROR = 0x80020001, + NOT_IMPLEMENTED = 0x80020002, + NOSYS = 0x80020003, + UNSUP = 0x80020004, + INVALID_ARGUMENT = 0x80020005, + ILLEGAL_ADDR = 0x80020006, + ILLEGAL_ALIGNMENT = 0x80020007, + ILLEGAL_PERMISSION = 0x80020008, + INVALID_ARGUMENT_SIZE = 0x80020009, + INVALID_FLAGS = 0x8002000A, + ILLEGAL_SIZE = 0x8002000B, + ILLEGAL_TYPE = 0x8002000C, + ILLEGAL_PATTERN = 0x8002000D, + ILLEGAL_ATTR = 0x8002000E, + ILLEGAL_COUNT = 0x8002000F, + ILLEGAL_MODE = 0x80020010, + ILLEGAL_OPEN_LIMIT = 0x80020011, + ONLY_DEVELOPMENT_MODE = 0x80020012, + DEBUG_ERROR = 0x80021000, + ILLEGAL_DIPSW_NUMBER = 0x80021001, + PA_ERROR = 0x80021100, + PA_NOT_AVAILABLE = 0x80021101, + PA_INVALID_KEY = 0x80021102, + PA_KEY_IS_NOT_SHARED = 0x80021103, + PA_INVALID_SIGNATURE = 0x80021104, + CPU_ERROR = 0x80022000, + MMU_ILLEGAL_L1_TYPE = 0x80022001, + MMU_L2_INDEX_OVERFLOW = 0x80022002, + MMU_L2_SIZE_OVERFLOW = 0x80022003, + INVALID_CPU_AFFINITY = 0x80022004, + INVALID_MEMORY_ACCESS = 0x80022005, + INVALID_MEMORY_ACCESS_PERMISSION = 0x80022006, + VA2PA_FAULT = 0x80022007, + VA2PA_MAPPED = 0x80022008, + VALIDATION_CHECK_FAILED = 0x80022009, + SYSMEM_ERROR = 0x80024000, + INVALID_PROCESS_CONTEXT = 0x80024001, + UID_NAME_TOO_LONG = 0x80024002, + VARANGE_IS_NOT_PHYSICAL_CONTINUOUS = 0x80024003, + PHYADDR_ERROR = 0x80024100, + NO_PHYADDR = 0x80024101, + PHYADDR_USED = 0x80024102, + PHYADDR_NOT_USED = 0x80024103, + NO_IOADDR = 0x80024104, + PHYMEM_ERROR = 0x80024300, + ILLEGAL_PHYPAGE_STATUS = 0x80024301, + NO_FREE_PHYSICAL_PAGE = 0x80024302, + NO_FREE_PHYSICAL_PAGE_UNIT = 0x80024303, + PHYMEMPART_NOT_EMPTY = 0x80024304, + NO_PHYMEMPART_LPDDR2 = 0x80024305, + NO_PHYMEMPART_CDRAM = 0x80024306, + PHYMEMPART_OUT_OF_INDEX = 0x80024307, + CANNOT_GROW_PHYMEMPART = 0x80024308, + NO_FREE_PHYSICAL_PAGE_CDRAM = 0x80024309, + INVALID_SUBBUDGET_ID = 0x8002430A, + FIXEDHEAP_ERROR = 0x80024400, + FIXEDHEAP_ILLEGAL_SIZE = 0x80024401, + FIXEDHEAP_ILLEGAL_INDEX = 0x80024402, + FIXEDHEAP_INDEX_OVERFLOW = 0x80024403, + FIXEDHEAP_NO_CHUNK = 0x80024404, + UID_ERROR = 0x80024500, + INVALID_UID = 0x80024501, + SYSMEM_UID_INVALID_ARGUMENT = 0x80024502, + SYSMEM_INVALID_UID_RANGE = 0x80024503, + SYSMEM_NO_VALID_UID = 0x80024504, + SYSMEM_CANNOT_ALLOCATE_UIDENTRY = 0x80024505, + NOT_PROCESS_UID = 0x80024506, + NOT_KERNEL_UID = 0x80024507, + INVALID_UID_CLASS = 0x80024508, + INVALID_UID_SUBCLASS = 0x80024509, + UID_CANNOT_FIND_BY_NAME = 0x8002450A, + UID_NOT_VISIBLE = 0x8002450B, + UID_MAX_OPEN = 0x8002450C, + UID_RL_OVERFLOW = 0x8002450D, + VIRPAGE_ERROR = 0x80024600, + ILLEGAL_VIRPAGE_TYPE = 0x80024601, + BLOCK_ERROR = 0x80024700, + ILLEGAL_BLOCK_ID = 0x80024701, + ILLEGAL_BLOCK_TYPE = 0x80024702, + BLOCK_IN_USE = 0x80024703, + PARTITION_ERROR = 0x80024800, + ILLEGAL_PARTITION_ID = 0x80024801, + ILLEGAL_PARTITION_INDEX = 0x80024802, + NO_L2PAGETABLE = 0x80024803, + HEAPLIB_ERROR = 0x80024900, + ILLEGAL_HEAP_ID = 0x80024901, + OUT_OF_RANG = 0x80024902, + HEAPLIB_NOMEM = 0x80024903, + HEAPLIB_VERIFY_ERROR = 0x80024904, + SYSMEM_ADDRESS_SPACE_ERROR = 0x80024A00, + INVALID_ADDRESS_SPACE_ID = 0x80024A01, + INVALID_PARTITION_INDEX = 0x80024A02, + ADDRESS_SPACE_CANNOT_FIND_PARTITION_BY_ADDR = 0x80024A03, + SYSMEM_MEMBLOCK_ERROR = 0x80024B00, + ILLEGAL_MEMBLOCK_TYPE = 0x80024B01, + ILLEGAL_MEMBLOCK_REMAP_TYPE = 0x80024B02, + NOT_PHY_CONT_MEMBLOCK = 0x80024B03, + ILLEGAL_MEMBLOCK_CODE = 0x80024B04, + ILLEGAL_MEMBLOCK_SIZE = 0x80024B05, + ILLEGAL_USERMAP_SIZE = 0x80024B06, + MEMBLOCK_TYPE_FOR_KERNEL_PROCESS = 0x80024B07, + PROCESS_CANNOT_REMAP_MEMBLOCK = 0x80024B08, + MEMBLOCK_RANGE_ERROR = 0x80024B09, + MEMBLOCK_TYPE_FOR_UPDATER_OR_SAFEMODE = 0x80024B0A, + MEMBLOCK_OVERFLOW = 0x80024B0B, + SYSMEM_PHYMEMLOW_ERROR = 0x80024C00, + CANNOT_ALLOC_PHYMEMLOW = 0x80024C01, + UNKNOWN_PHYMEMLOW_TYPE = 0x80024C02, + SYSMEM_BITHEAP_ERROR = 0x80024D00, + CANNOT_ALLOC_BITHEAP = 0x80024D01, + SYSMEM_NAMEHEAP_ERROR = 0x80024E00, + NO_SUCH_NAME = 0x80024E01, + DUPLICATE_NAME = 0x80024E02, + LOADCORE_ERROR = 0x80025000, + ILLEGAL_ELF_HEADER = 0x80025001, + ILLEGAL_SELF_HEADER = 0x80025002, + EXCPMGR_ERROR = 0x80027000, + ILLEGAL_EXCPCODE = 0x80027001, + ILLEGAL_EXCPHANDLER = 0x80027002, + NOTFOUND_EXCPHANDLER = 0x80027003, + CANNOT_RELEASE_EXCPHANDLER = 0x80027004, + INTRMGR_ERROR = 0x80027100, + ILLEGAL_CONTEXT = 0x80027101, + ILLEGAL_INTRCODE = 0x80027102, + ILLEGAL_INTRPARAM = 0x80027103, + ILLEGAL_INTRPRIORITY = 0x80027104, + ILLEGAL_TARGET_CPU = 0x80027105, + ILLEGAL_INTRFILTER = 0x80027106, + ILLEGAL_INTRTYPE = 0x80027107, + ILLEGAL_HANDLER = 0x80027108, + FOUND_HANDLER = 0x80027109, + NOTFOUND_HANDLER = 0x8002710A, + NO_MEMORY = 0x8002710B, + DMACMGR_ERROR = 0x80027200, + ALREADY_QUEUED = 0x80027201, + NOT_QUEUED = 0x80027202, + NOT_SETUP = 0x80027203, + ON_TRANSFERRING = 0x80027204, + NOT_INITIALIZED = 0x80027205, + TRANSFERRED = 0x80027206, + NOT_UNDER_CONTROL = 0x80027207, + CANCELING = 0x80027208, + SYSTIMER_ERROR = 0x80027300, + NO_FREE_TIMER = 0x80027301, + TIMER_NOT_ALLOCATED = 0x80027302, + TIMER_COUNTING = 0x80027303, + TIMER_STOPPED = 0x80027304, + THREADMGR_ERROR = 0x80028000, + UNKNOWN_UID = 0x80028001, + DIFFERENT_UID_CLASS = 0x80028002, + ALREADY_REGISTERED = 0x80028003, + CAN_NOT_WAIT = 0x80028004, + WAIT_TIMEOUT = 0x80028005, + WAIT_DELETE = 0x80028006, + WAIT_CANCEL = 0x80028007, + THREAD_ERROR = 0x80028020, + UNKNOWN_THREAD_ID = 0x80028021, + ILLEGAL_THREAD_ID = 0x80028022, + ILLEGAL_PRIORITY = 0x80028023, + ILLEGAL_STACK_SIZE = 0x80028024, + ILLEGAL_CPU_AFFINITY_MASK = 0x80028025, + ILLEGAL_THREAD_PARAM_COMBINATION = 0x80028026, + DORMANT = 0x80028027, + NOT_DORMANT = 0x80028028, + RUNNING = 0x80028029, + DELETED = 0x8002802A, + CAN_NOT_SUSPEND = 0x8002802B, + THREAD_STOPPED = 0x8002802C, + THREAD_SUSPENDED = 0x8002802D, + NOT_SUSPENDED = 0x8002802E, + ALREADY_DEBUG_SUSPENDED = 0x8002802F, + NOT_DEBUG_SUSPENDED = 0x80028030, + CAN_NOT_USE_VFP = 0x80028031, + THREAD_EVENT_ERROR = 0x80028060, + UNKNOWN_THREAD_EVENT_ID = 0x80028061, + KERNEL_TLS_ERROR = 0x80028080, + KERNEL_TLS_FULL = 0x80028081, + ILLEGAL_KERNEL_TLS_INDEX = 0x80028082, + KERNEL_TLS_BUSY = 0x80028083, + CALLBACK_ERROR = 0x800280A0, + UNKNOWN_CALLBACK_ID = 0x800280A1, + NOTIFY_CALLBACK = 0x800280A2, + CALLBACK_NOT_REGISTERED = 0x800280A3, + ALARM_ERROR = 0x800280C0, + UNKNOWN_ALARM_ID = 0x800280C1, + ALARM_CAN_NOT_CANCEL = 0x800280C2, + EVF_ERROR = 0x800280E0, + UNKNOWN_EVF_ID = 0x800280E1, + EVF_MULTI = 0x800280E2, + EVF_COND = 0x800280E3, + SEMA_ERROR = 0x80028100, + UNKNOWN_SEMA_ID = 0x80028101, + SEMA_ZERO = 0x80028102, + SEMA_OVF = 0x80028103, + SIGNAL_ERROR = 0x80028120, + ALREADY_SENT = 0x80028121, + MUTEX_ERROR = 0x80028140, + UNKNOWN_MUTEX_ID = 0x80028141, + MUTEX_RECURSIVE = 0x80028142, + MUTEX_LOCK_OVF = 0x80028143, + MUTEX_UNLOCK_UDF = 0x80028144, + MUTEX_FAILED_TO_OWN = 0x80028145, + MUTEX_NOT_OWNED = 0x80028146, + FAST_MUTEX_ERROR = 0x80028160, + UNKNOWN_FAST_MUTEX_ID = 0x80028161, + FAST_MUTEX_RECURSIVE = 0x80028162, + FAST_MUTEX_LOCK_OVF = 0x80028163, + FAST_MUTEX_FAILED_TO_OWN = 0x80028164, + FAST_MUTEX_NOT_OWNED = 0x80028165, + FAST_MUTEX_OWNED = 0x80028166, + FAST_MUTEX_ALREADY_INITIALIZED = 0x80028167, + FAST_MUTEX_NOT_INITIALIZED = 0x80028168, + LW_MUTEX_ERROR = 0x80028180, + UNKNOWN_LW_MUTEX_ID = 0x80028181, + LW_MUTEX_RECURSIVE = 0x80028182, + LW_MUTEX_LOCK_OVF = 0x80028183, + LW_MUTEX_UNLOCK_UDF = 0x80028184, + LW_MUTEX_FAILED_TO_OWN = 0x80028185, + LW_MUTEX_NOT_OWNED = 0x80028186, + COND_ERROR = 0x800281A0, + UNKNOWN_COND_ID = 0x800281A1, + WAIT_DELETE_MUTEX = 0x800281A2, + WAIT_CANCEL_MUTEX = 0x800281A3, + WAIT_DELETE_COND = 0x800281A4, + WAIT_CANCEL_COND = 0x800281A5, + LW_COND_ERROR = 0x800281C0, + UNKNOWN_LW_COND_ID = 0x800281C1, + WAIT_DELETE_LW_MUTEX = 0x800281C2, + WAIT_DELETE_LW_COND = 0x800281C3, + RW_LOCK_ERROR = 0x800281E0, + UNKNOWN_RW_LOCK_ID = 0x800281E1, + RW_LOCK_RECURSIVE = 0x800281E2, + RW_LOCK_LOCK_OVF = 0x800281E3, + RW_LOCK_NOT_OWNED = 0x800281E4, + RW_LOCK_UNLOCK_UDF = 0x800281E5, + RW_LOCK_FAILED_TO_LOCK = 0x800281E6, + RW_LOCK_FAILED_TO_UNLOCK = 0x800281E7, + EVENT_ERROR = 0x80028200, + UNKNOWN_EVENT_ID = 0x80028201, + EVENT_COND = 0x80028202, + MSG_PIPE_ERROR = 0x80028220, + UNKNOWN_MSG_PIPE_ID = 0x80028221, + MSG_PIPE_FULL = 0x80028222, + MSG_PIPE_EMPTY = 0x80028223, + MSG_PIPE_DELETED = 0x80028224, + TIMER_ERROR = 0x80028240, + UNKNOWN_TIMER_ID = 0x80028241, + EVENT_NOT_SET = 0x80028242, + SIMPLE_EVENT_ERROR = 0x80028260, + UNKNOWN_SIMPLE_EVENT_ID = 0x80028261, + PMON_ERROR = 0x80028280, + PMON_NOT_THREAD_MODE = 0x80028281, + PMON_NOT_CPU_MODE = 0x80028282, + WORK_QUEUE = 0x80028300, + UNKNOWN_WORK_QUEUE_ID = 0x80028301, + UNKNOWN_WORK_TASK_ID = 0x80028302, + PROCESSMGR_ERROR = 0x80029000, + INVALID_PID = 0x80029001, + INVALID_PROCESS_TYPE = 0x80029002, + PLS_FULL = 0x80029003, + INVALID_PROCESS_STATUS = 0x80029004, + PROCESS_CALLBACK_NOTFOUND = 0x80029005, + INVALID_BUDGET_ID = 0x80029006, + INVALID_BUDGET_SIZE = 0x80029007, + CP14_DISABLED = 0x80029008, + EXCEEDED_MAX_PROCESSES = 0x80029009, + PROCESS_REMAINING = 0x8002900A, + NO_PROCESS_DATA = 0x8002900B, + PROCESS_EVENT_INHIBITED = 0x8002900C, + IOFILEMGR_ERROR = 0x8002A000, + IO_NAME_TOO_LONG = 0x8002A001, + IO_REG_DEV = 0x8002A002, + IO_ALIAS_USED = 0x8002A003, + IO_DEL_DEV = 0x8002A004, + IO_WOULD_BLOCK = 0x8002A005, + MODULEMGR_START_FAILED = 0x8002D000, + MODULEMGR_STOP_FAIL = 0x8002D001, + MODULEMGR_IN_USE = 0x8002D002, + MODULEMGR_NO_LIB = 0x8002D003, + MODULEMGR_SYSCALL_REG = 0x8002D004, + MODULEMGR_NOMEM_LIB = 0x8002D005, + MODULEMGR_NOMEM_STUB = 0x8002D006, + MODULEMGR_NOMEM_SELF = 0x8002D007, + MODULEMGR_NOMEM = 0x8002D008, + MODULEMGR_INVALID_LIB = 0x8002D009, + MODULEMGR_INVALID_STUB = 0x8002D00A, + MODULEMGR_NO_FUNC_NID = 0x8002D00B, + MODULEMGR_NO_VAR_NID = 0x8002D00C, + MODULEMGR_INVALID_TYPE = 0x8002D00D, + MODULEMGR_NO_MOD_ENTRY = 0x8002D00E, + MODULEMGR_INVALID_PROC_PARAM = 0x8002D00F, + MODULEMGR_NO_MODOBJ = 0x8002D010, + MODULEMGR_NO_MOD = 0x8002D011, + MODULEMGR_NO_PROCESS = 0x8002D012, + MODULEMGR_OLD_LIB = 0x8002D013, + MODULEMGR_STARTED = 0x8002D014, + MODULEMGR_NOT_STARTED = 0x8002D015, + MODULEMGR_NOT_STOPPED = 0x8002D016, + MODULEMGR_INVALID_PROCESS_UID = 0x8002D017, + MODULEMGR_CANNOT_EXPORT_LIB_TO_SHARED = 0x8002D018, + MODULEMGR_INVALID_REL_INFO = 0x8002D019, + MODULEMGR_INVALID_REF_INFO = 0x8002D01A, + MODULEMGR_ELINK = 0x8002D01B, + MODULEMGR_NOENT = 0x8002D01C, + MODULEMGR_BUSY = 0x8002D01D, + MODULEMGR_NOEXEC = 0x8002D01E, + MODULEMGR_NAMETOOLONG = 0x8002D01F, + LIBRARYDB_NOENT = 0x8002D080, + LIBRARYDB_NO_LIB = 0x8002D081, + LIBRARYDB_NO_MOD = 0x8002D082, + PRELOAD_FAILED = 0x8002D0F0, + PRELOAD_LIBC_FAILED = 0x8002D0F1, + PRELOAD_FIOS2_FAILED = 0x8002D0F2, + AUTHFAIL = 0x8002F000, + NO_AUTH = 0x8002F001 +} + +SceKernelOpenPsId :: struct { + id: [16]c.char, +} +#assert(size_of(SceKernelOpenPsId) == 0x10) + +/** Threadmgr types */ +SceKernelIdListType :: enum c.int { + SCE_KERNEL_TMID_Thread = 1, + SCE_KERNEL_TMID_Semaphore = 2, + SCE_KERNEL_TMID_EventFlag = 3, + SCE_KERNEL_TMID_Mbox = 4, + SCE_KERNEL_TMID_Vpl = 5, + SCE_KERNEL_TMID_Fpl = 6, + SCE_KERNEL_TMID_Mpipe = 7, + SCE_KERNEL_TMID_Callback = 8, + SCE_KERNEL_TMID_ThreadEventHandler = 9, + SCE_KERNEL_TMID_Alarm = 10, + SCE_KERNEL_TMID_VTimer = 11, + SCE_KERNEL_TMID_SleepThread = 64, + SCE_KERNEL_TMID_DelayThread = 65, + SCE_KERNEL_TMID_SuspendThread = 66, + SCE_KERNEL_TMID_DormantThread = 67, +} + +SceThreadStatus :: enum c.int { + RUNNING = 1, + READY = 2, + STANDBY = 4, + WAITING = 8, + SUSPEND = 8, /* Compatibility */ + DORMANT = 16, + STOPPED = 16, /* Compatibility */ + DELETED = 32, /* Thread manager has killed the thread (stack overflow) */ + KILLED = 32, /* Compatibility */ + DEAD = 64, + STAGNANT = 128, + SUSPENDED = 256, +} + +/** Statistics about a running thread. + * @see sceKernelGetThreadRunStatus. + */ +SceKernelThreadRunStatus :: struct { + size: sce.Size, + cpuInfo: [4]struct { + processId: sce.UID, + threadId: sce.UID, + priority: c.int, + }, +} +#assert(size_of(SceKernelThreadRunStatus) == 0x34) + +SceKernelThreadEntry :: #type ^proc(args: sce.Size, argp: rawptr) -> c.int + +/** Additional options used when creating threads. */ +SceKernelThreadOptParam :: struct { + /** Size of the ::SceKernelThreadOptParam structure. */ + size: sce.Size, + /** Attributes */ + attr: sce.UInt32, + kStackMemType: sce.UInt32, + uStackMemType: sce.UInt32, + uTLSMemType: sce.UInt32, + uStackMemid: sce.UInt32, + data_0x18: sce.UInt32, +} +#assert(size_of(SceKernelThreadOptParam) == 0x1C) + +/** Structure to hold the status information for a thread + * @see sceKernelGetThreadInfo + */ +SceKernelThreadInfo :: struct { + /** Size of the structure */ + size: sce.Size, + /** The UID of the process where the thread belongs */ + processId: sce.UID, + /** Nul terminated name of the thread */ + name: [32]c.char, + /** Thread attributes */ + attr: sce.UInt32, + /** Thread status */ + status: sce.UInt32, + /** Thread entry point */ + entry: SceKernelThreadEntry, + /** Thread stack pointer */ + stack: rawptr, + /** Thread stack size */ + stackSize: sce.Int32, + /** Initial priority */ + initPriority: sce.Int32, + /** Current priority */ + currentPriority: sce.Int32, + /** Initial CPU affinity mask */ + initCpuAffinityMask: sce.Int32, + /** Current CPU affinity mask */ + currentCpuAffinityMask: sce.Int32, + /** Current CPU ID */ + currentCpuId: sce.Int32, + /** Last executed CPU ID */ + lastExecutedCpuId: sce.Int32, + /** Wait type */ + waitType: sce.UInt32, + /** Wait id */ + waitId: sce.UID, + /** Exit status of the thread */ + exitStatus: sce.Int32, + /** Number of clock cycles run */ + runClocks: sce.KernelSysClock, + /** Interrupt preemption count */ + intrPreemptCount: sce.UInt32, + /** Thread preemption count */ + threadPreemptCount: sce.UInt32, + /** Thread release count */ + threadReleaseCount: sce.UInt32, + /** Number of CPUs to which the thread is moved */ + changeCpuCount: sce.Int32, + /** Function notify callback UID */ + fNotifyCallback: sce.Int32, + /** Reserved */ + reserved: sce.Int32, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelThreadInfo) == 0x80) +} + +/** Inherit calling thread affinity mask. */ +SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT :: 0 + + + +/** Callback function prototype */ +SceKernelCallbackFunction :: #type ^proc(notifyId: c.int, notifyCount: c.int, notifyArg: c.int, userData: rawptr) -> c.int + +/** Structure to hold the status information for a callback */ +SceKernelCallbackInfo :: struct { + /** Size of the structure (i.e. sizeof(SceKernelCallbackInfo)) */ + size: sce.Size, + /** The UID of the callback. */ + callbackId: sce.UID, // Needs confirmation + /** The name given to the callback */ + name: [32]c.char, + /** The thread id associated with the callback */ + threadId: sce.UID, + /** Pointer to the callback function */ + callback: SceKernelCallbackFunction, + /** User supplied argument for the callback */ + common: rawptr, + /** Unknown */ + notifyCount: c.int, + /** Unknown */ + notifyArg: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelCallbackInfo) == 0x3C) +} + + + + +/** Additional options used when creating semaphores. */ +SceKernelSemaOptParam :: struct { + /** Size of the ::SceKernelSemaOptParam structure. */ + size: sce.Size, +} +#assert(size_of(SceKernelSemaOptParam) == 4) + +/** Current state of a semaphore. + * @see sceKernelGetSemaInfo. + */ +SceKernelSemaInfo :: struct { + /** Size of the ::SceKernelSemaInfo structure. */ + size: sce.Size, + /** The UID of the semaphore */ + semaId: sce.UID, + /** NUL-terminated name of the semaphore. */ + name: [32]c.char, + /** Attributes. */ + attr: sce.UInt, + /** The initial count the semaphore was created with. */ + initCount: c.int, + /** The current count. */ + currentCount: c.int, + /** The maximum count. */ + maxCount: c.int, + /** The number of threads waiting on the semaphore. */ + numWaitThreads: c.int, +} +#assert(size_of(SceKernelSemaInfo) == 0x3C) + + + +SceKernelWaitableAttribute :: enum c.int { + THREAD_FIFO = 0x00000000, //!< Waiting threads First input First output + THREAD_PRIO = 0x00002000, //!< Waiting threads queued on priority basis + OPENABLE = 0x00000080, //!< Sync object can be accessed by sceKernelOpenXxx +} + +/** Event flag creation attributes */ +SceEventFlagAttributes :: enum c.int { + // Deprecated + THREAD_FIFO = auto_cast SceKernelWaitableAttribute.THREAD_FIFO, //!< Use SCE_KERNEL_ATTR_THREAD_FIFO + // Deprecated + THREAD_PRIO = auto_cast SceKernelWaitableAttribute.THREAD_PRIO, //!< Use SCE_KERNEL_ATTR_THREAD_PRIO + WAITSINGLE = 0, //!< Sync object can only be waited upon by one thread. + WAITMULTIPLE = 0x00001000, //!< Sync object can be waited upon by multiple threads. + // Deprecated + OPENABLE = auto_cast SceKernelWaitableAttribute.OPENABLE, //!< Use SCE_KERNEL_ATTR_OPENABLE +} + +SceKernelEventFlagOptParam :: struct { + size: sce.Size, +} +#assert(size_of(SceKernelEventFlagOptParam) == 4) + +/** Structure to hold the event flag information */ +SceKernelEventFlagInfo :: struct { + size: sce.Size, + evfId: sce.UID, // Needs confirmation + name: [32]c.char, + attr: sce.UInt, + initPattern: sce.UInt, + currentPattern: sce.UInt, + numWaitThreads: c.int, +} +#assert(size_of(SceKernelEventFlagInfo) == 0x38) + +/** Event flag wait types */ +SceEventFlagWaitTypes :: enum c.int { + /** Wait for all bits in the pattern to be set */ + WAITAND = 0, + /** Wait for one or more bits in the pattern to be set */ + WAITOR = 1, + /** Clear all the bits when it matches */ + WAITCLEAR = 2, + /** Clear the wait pattern when it matches */ + WAITCLEAR_PAT = 4, +} + + + +SceKernelLwCondWork :: struct { + data: [4]sce.Int32 , +} +#assert(size_of(SceKernelLwCondWork) == 0x10) + +SceKernelLwCondOptParam :: struct { + size: sce.Size, +} +#assert(size_of(SceKernelLwCondOptParam) == 4) + + + +SceKernelLwMutexWork :: struct { + data: [4]sce.Int64, +} +#assert(size_of(SceKernelLwMutexWork) == 0x20) + +SceKernelLwMutexOptParam :: struct { + size: sce.Size, +} +#assert(size_of(SceKernelLwMutexOptParam) == 4) + + + + +SceKernelMutexAttribute :: enum c.int { + RECURSIVE = 0x02, + CEILING = 0x04, +} + +/** Additional options used when creating mutexes. */ +SceKernelMutexOptParam :: struct { + /** Size of the ::SceKernelMutexOptParam structure. */ + size: sce.Size, + ceilingPriority: c.int, +} +#assert(size_of(SceKernelMutexOptParam) == 8) + +/** Current state of a mutex. + * @see sceKernelGetMutexInfo. + */ +SceKernelMutexInfo :: struct { + /** Size of the ::SceKernelMutexInfo structure. */ + size: sce.Size, + /** The UID of the mutex. */ + mutexId: sce.UID, + /** NUL-terminated name of the mutex. */ + name: [32]c.char, + /** Attributes. */ + attr: sce.UInt, + /** The initial count the mutex was created with. */ + initCount: c.int, + /** The current count. */ + currentCount: c.int, + /** The UID of the current owner of the mutex. */ + currentOwnerId: sce.UID, + /** The number of threads waiting on the mutex. */ + numWaitThreads: c.int, +} +#assert(size_of(SceKernelMutexInfo) == 0x3C) + + + +/** Additional options used when creating condition variables. */ +SceKernelCondOptParam :: struct { + /** Size of the ::SceKernelCondOptParam structure. */ + size: sce.Size, +} +#assert(size_of(SceKernelCondOptParam) == 4) + +/** Current state of a condition variable. + * @see sceKernelGetCondInfo. + */ +SceKernelCondInfo :: struct { + /** Size of the ::SceKernelCondInfo structure. */ + size: sce.Size, + /** The UID of the condition variable. */ + condId: sce.UID, + /** NUL-terminated name of the condition variable. */ + name: [32]c.char, + /** Attributes. */ + attr: sce.UInt, + /** Mutex associated with the condition variable. */ + mutexId: sce.UID, + /** The number of threads waiting on the condition variable. */ + numWaitThreads: c.int, +} +#assert(size_of(SceKernelCondInfo) == 0x34) + +// +// modulemgr.h start +// + +/** + * @brief Return values for plugins `module_start` and `module_stop` + */ +/** @{ */ +SCE_KERNEL_START_SUCCESS :: (0) +SCE_KERNEL_START_RESIDENT :: SCE_KERNEL_START_SUCCESS +SCE_KERNEL_START_NO_RESIDENT :: (1) +SCE_KERNEL_START_FAILED :: (2) + +SCE_KERNEL_STOP_SUCCESS :: (0) +SCE_KERNEL_STOP_FAIL :: (1) +SCE_KERNEL_STOP_CANCEL :: SCE_KERNEL_STOP_FAIL +/** @} */ + +SceKernelModuleState :: enum c.int { + READY = 0x00000002, + STARTED = 0x00000006, + ENDED = 0x00000009 +} + +/* + * Assigning the following macro to the variable sceKernelPreloadModuleInhibit with the OR operator inhibit preloading that module. + * + * Example + * + * // Inhibit preload SceLibc and SceShellSvc. + * int sceKernelPreloadModuleInhibit = SCE_KERNEL_PRELOAD_INHIBIT_LIBC | SCE_KERNEL_PRELOAD_INHIBIT_LIBSHELLSVC; + * + * + * And these are only valid for modules in the process image, preload is not inhibited even if specified for modules to be loaded later. + * + * WARNING + * If SceLibNet etc. is loaded without SceShellSvc etc. loaded, an unintended system crash will occur. + */ +SceKernelPreloadInhibit :: enum c.int { + NONE = 0x00000000, + LIBC = 0x10000, + LIBDBG = 0x20000, + LIBSHELLSVC = 0x80000, + LIBCDLG = 0x100000, + LIBFIOS2 = 0x200000, + APPUTIL = 0x400000, + LIBSCEFT2 = 0x800000, + LIBPVF = 0x1000000, + LIBPERF = 0x2000000 +} +#assert(size_of(SceKernelPreloadInhibit) == 4) + + +SceKernelSegmentInfo :: struct { + size: sce.Size, //!< this structure size (0x18) + perms: sce.UInt, //!< probably rwx in low bits + vaddr: rawptr, //!< address in memory + memsz: sce.Size, //!< size in memory + filesz: sce.Size, //!< original size of memsz + res: sce.UInt, //!< unused +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelSegmentInfo) == 0x18) +} + +SceKernelModuleInfo :: struct { + size: sce.Size, //!< 0x1B8 for Vita 1.x + modid: sce.UID, + modattr: c.uint16_t, + modver: [2]c.uint8_t, + module_name: [28]c.char, + unk28: sce.UInt, + start_entry: rawptr, + stop_entry: rawptr, + exit_entry: rawptr, + exidx_top: rawptr, + exidx_btm: rawptr, + extab_top: rawptr, + extab_btm: rawptr, + tlsInit: rawptr, + tlsInitSize: sce.Size, + tlsAreaSize: sce.Size, + path: [256]c.char, + segments: [4]SceKernelSegmentInfo, + state: sce.UInt, //!< see:SceKernelModuleState +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelModuleInfo) == 0x1B8) +} + +SceKernelLMOption :: struct { + size: sce.Size, +} +#assert(size_of(SceKernelLMOption) == 4) + +SceKernelULMOption :: struct { + size: sce.Size, +} +#assert(size_of(SceKernelULMOption) == 4) + +SceKernelSystemSwVersion :: struct { + size: sce.Size, + versionString: [0x1C]c.char, + version: sce.UInt, + unk_24: sce.UInt, +} +#assert(size_of(SceKernelSystemSwVersion) == 0x28) + +/* For backward compatibility */ +SceKernelFwInfo :: SceKernelSystemSwVersion + +SceKernelModuleLibraryInfo :: struct { + size: sce.Size, //!< sizeof(SceKernelModuleLibraryInfo) : 0x120 + library_id: sce.UID, + libnid: c.uint32_t, + version: c.uint16_t, + flags: c.uint16_t, + entry_num_function: c.uint16_t, + entry_num_variable: c.uint16_t, + unk_0x14: c.uint16_t, + unk_0x16: c.uint16_t, + library_name: [0x100]c.char, + number_of_imported: sce.Size, + modid2: sce.UID, +} +#assert(size_of(SceKernelModuleLibraryInfo) == 0x120) + + +// +// modulemgr.h end +// + + +// +// processmgr.h start +// + + +SceKernelProcessType :: distinct sce.UInt32 +SceKernelClock :: distinct sce.UInt64 +SceKernelTime :: distinct sce.UInt32 + +SceKernelTimeval :: struct { + sec: sce.Int32, + usec: sce.Int32, +} +#assert(size_of(SceKernelTimeval) == 8) + +SceKernelTimezone :: struct { + value: sce.UInt64, +} +#assert(size_of(SceKernelTimezone) == 8) + +SceKernelProcessPrioritySystem :: enum c.int { + SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_HIGH = 32, + SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_DEFAULT = 96, + SCE_KERNEL_PROCESS_PRIORITY_SYSTEM_LOW = 159, + __SCE_KERNEL_PROCESS_PRIORITY_SYSTEM = -1 // 0xFFFFFFFF +} +#assert(size_of(SceKernelProcessPrioritySystem) == 4) + +SceKernelProcessPriorityUser :: enum c.int { + SCE_KERNEL_PROCESS_PRIORITY_USER_HIGH = 64, + SCE_KERNEL_PROCESS_PRIORITY_USER_DEFAULT = 96, + SCE_KERNEL_PROCESS_PRIORITY_USER_LOW = 127, + __SCE_KERNEL_PROCESS_PRIORITY_USER = -1 // 0xFFFFFFFF +} +#assert(size_of(SceKernelProcessPriorityUser) == 4) + +SceKernelPowerTickType :: enum c.int { + /** Cancel all timers */ + SCE_KERNEL_POWER_TICK_DEFAULT = 0, + /** Cancel automatic suspension timer */ + SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND = 1, + /** Cancel OLED-off timer */ + SCE_KERNEL_POWER_TICK_DISABLE_OLED_OFF = 4, + /** Cancel OLED dimming timer */ + SCE_KERNEL_POWER_TICK_DISABLE_OLED_DIMMING = 6, + __SCE_KERNEL_POWER_TICK_DISABLE = -1 // 0xFFFFFFFF +} +#assert(size_of(SceKernelPowerTickType) == 4) + + +// +// processmgr.h end +// + + + +// +// sysmem.h start +// + +SceKernelMemBlockType :: distinct sce.UInt32 +#assert(size_of(SceKernelMemBlockType) == 4) + +/* + * User/Kernel shared memtypes + */ + +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_L1WBWA_RW :: (0x09404060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_R :: (0x09408040) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW :: (0x09408060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_DEVICE_RW :: (0x0C200860) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_R :: (0x0C20D040) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_RW :: (0x0C20D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_NC_RW :: (0x0C208060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_GAME_RW :: (0x0C50D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_RW :: (0x0C80D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW :: (0x0D808060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_RW :: (0x0CA0D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_CDIALOG_NC_RW :: (0x0CA08060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_RW :: (0x0CF0D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_TOOL_NC_RW :: (0x0CF08060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_R :: (0x0E20D040) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_RW :: (0x0E20D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_R :: (0x0E208040) +SCE_KERNEL_MEMBLOCK_TYPE_USER_CDIALOG_NC_RW :: (0x0E208060) + + +/* + * For Backwards compatibility + */ + +SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE :: (0x0C208060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_RW :: (0x0C20D060) +SCE_KERNEL_MEMBLOCK_TYPE_USER_TOOL_NC_RW :: (0x0CF08060) + + +SceKernelAllocMemBlockAttr :: enum c.uint { + HAS_PADDR = 0x00000002, + HAS_ALIGNMENT = 0x00000004, + HAS_MIRROR_BLOCKID = 0x00000040, + HAS_PID = 0x00000080, + HAS_PADDR_LIST = 0x00001000, + PHYCONT = 0x00200000, + ALLOW_PARTIAL_OP = 0x04000000, +} + +SceKernelModel :: enum c.int { + VITA = 0x10000, + VITATV = 0x20000 +} + +SCE_KERNEL_CPU_MASK_USER_0 :: 0x00010000 +SCE_KERNEL_CPU_MASK_USER_1 :: 0x00020000 +SCE_KERNEL_CPU_MASK_USER_2 :: 0x00040000 +SCE_KERNEL_CPU_MASK_SYSTEM :: 0x00080000 + +SCE_KERNEL_CPU_MASK_USER_ALL :: (SCE_KERNEL_CPU_MASK_USER_0 | SCE_KERNEL_CPU_MASK_USER_1 | SCE_KERNEL_CPU_MASK_USER_2) + +SceKernelAllocMemBlockOpt :: struct { + size: sce.Size, + attr: sce.UInt32, + alignment: sce.Size, + uidBaseBlock: sce.UInt32, + strBaseBlockName: cstring, + flags: c.int, //! Unknown flags 0x10 or 0x30 for ::sceKernelOpenMemBlock + reserved: [10]c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelAllocMemBlockOpt) == 0x40) +} + +SceKernelFreeMemorySizeInfo :: struct { + size: c.int, //!< sizeof(SceKernelFreeMemorySizeInfo) + size_user: c.int, //!< Free memory size for *_USER_RW memory + size_cdram: c.int, //!< Free memory size for USER_CDRAM_RW memory + size_phycont: c.int, //!< Free memory size for USER_MAIN_PHYCONT_*_RW memory +} +#assert(size_of(SceKernelFreeMemorySizeInfo) == 0x10) + +SceKernelMemBlockInfo :: struct { + size: sce.Size, + mappedBase: rawptr, + mappedSize: sce.Size, + memoryType: c.int, + access: sce.UInt32, + type: SceKernelMemBlockType, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceKernelMemBlockInfo) == 0x18) +} + +SceKernelMemoryAccessType :: enum c.int { + SCE_KERNEL_MEMORY_ACCESS_X = 0x01, + SCE_KERNEL_MEMORY_ACCESS_W = 0x02, + SCE_KERNEL_MEMORY_ACCESS_R = 0x04 +} + +SceKernelMemoryType :: enum c.int { + SCE_KERNEL_MEMORY_TYPE_NORMAL_NC = 0x80, + SCE_KERNEL_MEMORY_TYPE_NORMAL = 0xD0 +} + +// +// sysmem.h end +// + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0231f7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 IllusionMan1212 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Location/Location.odin b/Location/Location.odin new file mode 100644 index 0000000..0cc4b57 --- /dev/null +++ b/Location/Location.odin @@ -0,0 +1,60 @@ +package location + +import "core:c" +import sce "../common" + +foreign import location "system:SceLibLocation_stub" + +@(link_prefix = "sceLocation") +foreign location { + /** Library start */ + Open :: proc(handle: ^SceLocationHandle, locateMethod: SceLocationLocationMethod, headingMethod: SceLocationHeadingMethod) -> sce.Int32 --- + + /** Close library */ + Close :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Reopen library */ + Reopen :: proc(handle: SceLocationHandle, locateMethod: SceLocationLocationMethod, headingMethod: SceLocationHeadingMethod) -> sce.Int32 --- + + /** Get location measurement method */ + GetMethod :: proc(handle: SceLocationHandle, locateMethod: ^SceLocationLocationMethod, headingMethod: ^SceLocationHeadingMethod) -> sce.Int32 --- + + /** Get location information */ + GetLocation :: proc(handle: SceLocationHandle, locationInfo: ^SceLocationLocationInfo) -> sce.Int32 --- + + /** Cancel location information acquisition operation */ + CancelGetLocation :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Start continuous acquisition of location information */ + StartLocationCallback :: proc(handle: SceLocationHandle, distance: sce.UInt32, callback: SceLocationLocationInfoCallback, userdata: rawptr) -> sce.Int32 --- + + /** Stop continuous acquisition of location information */ + StopLocationCallback :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Get direction information */ + GetHeading :: proc(handle: SceLocationHandle, headingInfo: ^SceLocationHeadingInfo) -> sce.Int32 --- + + /** Start continuous acquisition of direction information */ + StartHeadingCallback :: proc(handle: SceLocationHandle, difference: sce.UInt32, callback: SceLocationHeadingInfoCallback, userdata: rawptr) -> sce.Int32 --- + + /** Stop continuous acquisition of direction information */ + StopHeadingCallback :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Allow acquisition of location information */ + Confirm :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Get status of location information acquisition permission dialog */ + ConfirmGetStatus :: proc(handle: SceLocationHandle, status: ^SceLocationDialogStatus) -> sce.Int32 --- + + /** Get result of location information acquisition permission dialog */ + ConfirmGetResult :: proc(handle: SceLocationHandle, result: ^SceLocationDialogResult) -> sce.Int32 --- + + /** Abort location information acquisition permission dialog */ + ConfirmAbort :: proc(handle: SceLocationHandle) -> sce.Int32 --- + + /** Get location information acquisition permission/refusal information */ + GetPermission :: proc(handle: SceLocationHandle, info: ^SceLocationPermissionInfo) -> sce.Int32 --- + + /** Get location information acquisition permission information */ + SetGpsEmulationFile :: proc(filename: cstring) -> sce.Int32 --- +} diff --git a/Location/types.odin b/Location/types.odin new file mode 100644 index 0000000..2b80c41 --- /dev/null +++ b/Location/types.odin @@ -0,0 +1,140 @@ +package location + +import "core:c" +import sce "../common" + +SCE_LOCATION_DATA_INVALID :: -9999.0 + +/** Location error codes */ +// TODO: +SceLocationErrorCode :: enum c.uint { + SUCCESS = 0, + + INFO_UNDETERMINED_LOCATION = 0x80101200, + INFO_INSUFFICIENT_INFORMATION = 0x80101201, + INFO_GET_LOCATION_CANCELED = 0x80101202, + INFO_DENIED_BY_USER = 0x80101203, + + INVALID_ADDRESS = 0x80101204, + INVALID_HANDLE = 0x80101205, + NO_MEMORY = 0x80101206, + TOO_MANY_HANDLES = 0x80101207, + INVALID_LOCATION_METHOD = 0x80101208, + INVALID_HEADING_METHOD = 0x80101209, + MULTIPLE_CALLBACK = 0x8010120A, + NOT_RUNNING_CALLBACK = 0x8010120B, + DIALOG_RESULT_NONE = 0x8010120C, + DISABLE_APPLICATION = 0x8010120D, + MULTIPLE_CONFIRM = 0x8010120E, + + UNAUTHORIZED = 0x80101280, + PROVIDER_UNAVAILABLE = 0x80101281, + FILE_IO = 0x80101282, + INVALID_FILE_FORMAT = 0x80101283, + TIME_OUT = 0x80101284, + NO_SERVER_MEMORY = 0x80101285, + INVALID_TITLE_ID = 0x80101286, + FATAL_ERROR = 0x801012FF, +} + +//TO DO: further comment each struct and function (i.e. parameters) + +/** Location handle datatype */ +SceLocationHandle :: sce.UInt32 +#assert(size_of(SceLocationHandle) == 4) + +/** Usage permission dialog display status */ +SceLocationDialogStatus :: enum c.int { + SCE_LOCATION_DIALOG_STATUS_IDLE = 0, //!< Dialog initial idle status + SCE_LOCATION_DIALOG_STATUS_RUNNING = 1, //!< Dialog running + SCE_LOCATION_DIALOG_STATUS_FINISHED = 2, //!< Dialog operation finished + __SCE_LOCATION_DIALOG_STATUS = -1 // 0xFFFFFFFF +} + +/** Usage permission dialog result */ +SceLocationDialogResult :: enum c.int { + SCE_LOCATION_DIALOG_RESULT_NONE = 0, //!< Result is not stored + SCE_LOCATION_DIALOG_RESULT_DISABLE = 1, //!< Negative result is stored + SCE_LOCATION_DIALOG_RESULT_ENABLE = 2, //!< Positive result is stored + __SCE_LOCATION_DIALOG_RESULT = -1 // 0xFFFFFFFF +} + +/** location usage permission status for individual application */ +SceLocationPermissionApplicationStatus :: enum c.int { + SCE_LOCATION_PERMISSION_APPLICATION_NONE = 0, //!< liblocation not used + SCE_LOCATION_PERMISSION_APPLICATION_INIT = 1, //!< liblocation not accessed + SCE_LOCATION_PERMISSION_APPLICATION_DENY = 2, //!< liblocation access denied status + SCE_LOCATION_PERMISSION_APPLICATION_ALLOW = 3, //!< liblocation access allowed status + __SCE_LOCATION_PERMISSION_APPLICATION = -1 // 0xFFFFFFFF +} + +/** location usage permission status */ +SceLocationPermissionStatus :: enum c.int { + SCE_LOCATION_PERMISSION_DENY = 0, //!< liblocation access denied status + SCE_LOCATION_PERMISSION_ALLOW = 1, //!< liblocation access allowed status + __SCE_LOCATION_PERMISSION = -1 // 0xFFFFFFFF +} + +/** Location measurement method */ +SceLocationLocationMethod :: enum c.int { + SCE_LOCATION_LMETHOD_NONE = 0, //!< Do not perform location measurement + SCE_LOCATION_LMETHOD_AGPS_AND_3G_AND_WIFI = 1, //!< Perform measurement by switching between AGPS, Wi-Fi, and 3G + SCE_LOCATION_LMETHOD_GPS_AND_WIFI = 2, //!< Perform measurement by switching between GPS and Wi-Fi + SCE_LOCATION_LMETHOD_WIFI = 3, //!< Use only Wi-Fi + SCE_LOCATION_LMETHOD_3G = 4, //!< Use only 3G + SCE_LOCATION_LMETHOD_GPS = 5, //!< Use only GPS + __SCE_LOCATION_LMETHOD = -1 // 0xFFFFFFFF +} + +/** Direction measurement method */ +SceLocationHeadingMethod :: enum c.int { + SCE_LOCATION_HMETHOD_NONE = 0, //!< Don't perform heading measurement + SCE_LOCATION_HMETHOD_AUTO = 1, //!< Automatically determine hold orientation and outputs its value + SCE_LOCATION_HMETHOD_VERTICAL = 2, //!< Output value in vertical hold reference system + SCE_LOCATION_HMETHOD_HORIZONTAL = 3, //!< Output value in horizontal hold reference system + SCE_LOCATION_HMETHOD_CAMERA = 4, //!< Output value in camera axis reference system + __SCE_LOCATION_HMETHOD = -1 // 0xFFFFFFFF +} + +/** Structure of location information */ +SceLocationLocationInfo :: struct { + latitude: sce.Double64, //!< Latitude (deg). Valid range: -90 to + 90. If cannot be obtained, SCE_LOCATION_DATA_INVALID + longitude: sce.Double64, //!< Longitude (deg). Valid range: -180 to +180. If cannot be obtained, SCE_LOCATION_DATA_INVALID + altitude: sce.Double64, //!< Altitude (m). If cannot be obtained, SCE_LOCATION_DATA_INVALID + accuracy: sce.Float32, //!< Horizontal error (m). If cannot be obtained, SCE_LOCATION_DATA_INVALID + reserve: sce.Float32, //!< Reserve + direction: sce.Float32, //!< Travel direction. If cannot be obtained, SCE_LOCATION_DATA_INVALID + speed: sce.Float32, //!< Travel speed (m/s). If cannot be obtained, SCE_LOCATION_DATA_INVALID + timestamp: sce.RtcTick, //!< Time of data acquisition, in μsec (UTC) +} +#assert(size_of(SceLocationLocationInfo) == 0x30) + + +/** Structure of heading information */ +SceLocationHeadingInfo :: struct { + trueHeading: sce.Float32, //!< Clockwise angle from true north (0 to 360 degrees). If cannot be acquired, SCE_LOCATION_INVALID_DATA + headingVectorX: sce.Float32, //!< Direction vector X coordinates element of true north. If cannot be acquired, SCE_LOCATION_INVALID_DATA + headingVectorY: sce.Float32, //!< Direction vector Y coordinates element of true north. If cannot be acquired, SCE_LOCATION_INVALID_DATA + headingVectorZ: sce.Float32, //!< Direction vector Z coordinates element of true north. If cannot be acquired, SCE_LOCATION_INVALID_DATA + reserve: sce.Float32, //!< Reserve + reserve2: sce.Float32, //!< Reserve + timestamp: sce.RtcTick, //!< Time acquired in unit of 1 usec (UTC) +} +#assert(size_of(SceLocationHeadingInfo) == 0x20) + +/** Location information callback notification function */ +SceLocationLocationInfoCallback :: #type ^proc "c" (result: sce.Int32, handle: SceLocationHandle, #by_ptr location: SceLocationLocationInfo, userdata: rawptr) + +/** Callback notification function for direction information */ +SceLocationHeadingInfoCallback :: #type ^proc "c" (result: sce.Int32, handle: SceLocationHandle, #by_ptr heading: SceLocationHeadingInfo, userdata: rawptr) + +/** Location information acquisition permission information */ +SceLocationPermissionInfo :: struct { + parentalstatus: SceLocationPermissionStatus, //!< Status of usage permission through parental control + mainstatus: SceLocationPermissionStatus, //!< Status of usage permission through location data item of system settings + applicationstatus: SceLocationPermissionApplicationStatus, //!< Status of usage permission through location data item for each application in system settings + unk_0x0C: c.int, + unk_0x10: c.int, +} +#assert(size_of(SceLocationPermissionInfo) == 0x14) + diff --git a/MonoBridge/MonoBridge.odin b/MonoBridge/MonoBridge.odin new file mode 100644 index 0000000..e07e448 --- /dev/null +++ b/MonoBridge/MonoBridge.odin @@ -0,0 +1,25 @@ +package monobridge + +import "core:c" +import sce "../common" + +foreign import monobridge "system:SceLibMonoBridge_stub" + +ScePssCryptoHandle :: struct { + fd: sce.UID, + unk1: c.uint32_t, + size: sce.Size, + unk3: c.uint32_t, +} +#assert(size_of(ScePssCryptoHandle) == 0x10) + +@(link_prefix = "pss_") +foreign monobridge { + crypto_open :: proc(handle: ^ScePssCryptoHandle, path: cstring) -> c.int --- + crypto_read :: proc(handle: ^ScePssCryptoHandle, mode: ^c.int) -> [^]c.char --- + crypto_close :: proc(handle: ^ScePssCryptoHandle) -> c.int --- + code_mem_alloc :: proc(_: ^sce.Size) -> rawptr --- + code_mem_flush_icache :: proc(_: rawptr, __: sce.Size) --- + code_mem_lock :: proc() --- + code_mem_unlock :: proc() --- +} diff --git a/Motion/Motion.odin b/Motion/Motion.odin new file mode 100644 index 0000000..a6ef96a --- /dev/null +++ b/Motion/Motion.odin @@ -0,0 +1,171 @@ +package motion + +import "core:c" +import sce "../common" + +foreign import motion "system:SceMotion_stub" + +@(link_prefix = "sceMotion") +foreign motion { + /** + * Gets the current motion state. + * + * @param[out] *motionState - See ::SceMotionState + * + * @return 0, <0 on error. + */ + GetState :: proc(motionState: ^SceMotionState) -> c.int --- + + /** + * Gets the current motion sensor state + * + * @param[in] numRecords - Amount of records to get + * @param[out] *motionSensorState - See ::SceMotionSensorState + * + * @return 0, <0 on error + */ + GetSensorState :: proc(sensorState: ^SceMotionSensorState, numRecords: c.int) -> c.int --- + + /** + * Gets the location of the device's sensors in relation to its center point (in mm). + * + * @param[out] *deviceLocation - See ::SceMotionDeviceLocation + * + * @return 0, <0 on error + */ + GetDeviceLocation :: proc(deviceLocation: ^SceMotionDeviceLocation) -> c.int --- + + /** + * Gets the basic orientation of the device in relation to gravity + * @note - Possible values in the output vector are -1, 0 and 1 + * @note - Using the same coordinate system as ::SceMotionDeviceLocation these values are set in the vector depending on if the axies' positive or negative directions are facing away from gravitational pull + * @note - For example if the vita is laying on a flat and level surface, with the OLED/LCD side facing upwards, the Z part of the vector will be 1 + * @note - Now flipping the device upwards, taking hold of the right joystick's side, until it forms a 90 degree angle to the surface will result in the X part of the vector being 1 instead + * @note - Both examples would result in the returned value being -1 if flipped 180 degrees, swapping their top and bottom sides in correlation to gravity + * @note - The angle of rotation in relation to being in a centered state on an axis (returned as 0) after which the device will change the value is determined by ::SceMotionSetAngleThreshold + * @note - In order for this function to return up to date data, ::GetState must be called prior to call this function. + * @param[out] *basicOrientation + * + * @return 0, <0 on error + */ + GetBasicOrientation :: proc(basicOrientation: ^sce.FVector3) -> c.int --- + + /** + * Rotate the yaw axis + * + * @param[in] radians - Rotation angle in radians + * + * @return 0 + */ + RotateYaw :: proc(radians: c.float) -> c.int --- + + /** + * Get Status of tilt correction + * @note - With tilt correction enabled the data for roll and pitch movements of the device get recalculated to not distort the yaw movements in relation to gravity + * @note - Enabled by default + * @return 1 if enabled, 0 if disabled + */ + GetTiltCorrection :: proc() -> c.int --- + + /** + * Activate/deactivate tilt correction + * @note - For more information see ::GetTiltCorrection + * @param[in] setValue - 1 to enable, 0 to disable + * + * @return 0 + */ + SetTiltCorrection :: proc(setValue: c.int) -> c.int --- + + /** + * Get status of deadbanding + * @note - With deadbanding enabled the device will filter out small movements to reduce jitter + * @note - Potentially decreaces accuracy of fine movements + * @note - Enabled by default + * @return 1 if enabled, 0 if disabled + */ + GetDeadband :: proc() -> c.int --- + + /** + * Activate/deactivate deadbanding + * @note - For more information see ::GetDeadbanding + * @param[in] setValue - 1 to enable, 0 to disable + * + * @return 0 + */ + SetDeadband :: proc(setValue: c.int) -> c.int --- + + /** + * Get status of gyroscope bias correction + * @note - With gyroscope bias correction enabled the device will attempt to adjust for outside influences that could impact calibration + * @note - Enabled by default + * @return 1 if enabled, 0 if disabled + */ + GetGyroBiasCorrection :: proc() -> c.int --- + + /** + * Activate/deactivate gyroscope bias correction + * @note - For more information see ::GetGyroBiasCorrection + * @param[in] setValue - 1 to enable, 0 to disable + * + * @return 0 + */ + SetGyroBiasCorrection :: proc(setValue: c.int) -> c.int --- + + /** + * Define the angle threshold for basic orientation + * + * @param[in] angle - range of 0 to 45 degrees + * + * @return 0 + */ + SetAngleThreshold :: proc(angle: c.float) -> c.int --- + + /** + * Get the angle threshold for basic orientation + * + * @return angle in degrees + */ + GetAngleThreshold :: proc() -> c.float --- + + /** + * Set current orientation as origin + * + * @return 0, <0 on error + */ + Reset :: proc() -> c.int --- + + /** + * Start magnetometer sampling + * + * @return 0, <0 on error + */ + MagnetometerOn :: proc() -> c.int --- + + /** + * Stop magnetometer sampling + * + * @return 0, <0 on error + */ + MagnetometerOff :: proc() -> c.int --- + + /** + * Get status of magnetometer sampling + * + * @return 1 if enabled, 0 if disabled + */ + GetMagnetometerState :: proc() -> c.int --- + + /** + * Start sampling + * + * @return 0, <0 on error + */ + StartSampling :: proc() -> c.int --- + + /** + * Stop sampling + * + * @return 0, <0 on error + */ + StopSampling :: proc() -> c.int --- +} diff --git a/Motion/types.odin b/Motion/types.odin new file mode 100644 index 0000000..f5da836 --- /dev/null +++ b/Motion/types.odin @@ -0,0 +1,79 @@ +package motion + +import "core:c" +import sce "../common" + +SceMotionMagFieldStability :: enum c.int { + UNSTABLE = 0, + UNUSED = 1, + STABLE = 2 +} + +// TODO: +SceMotionErrorCode :: enum c.uint { + DATA_INVALID = 0x80360200, + READING = 0x80360201, + NON_INIT_ERR = 0x80360202, + STATE_INVALID = 0x80360203, + CALIB_READ_FAIL = 0x80360204, + OUT_OF_BOUNDS = 0x80360205, + NOT_SAMPLING = 0x80360206, + ALREADY_SAMPLING = 0x80360207, + MEM_IN_USE = 0x80360208 +} + + +/* struct */ + +/** Returned motion state */ +SceMotionState :: struct { + timestamp: c.uint, //!< Local timestamp of the device + acceleration: sce.FVector3, //!< Accelerometer data + angularVelocity: sce.FVector3, //!< Angular velocity data + reserved1: [12]c.uint8_t, //!< Reserved data + deviceQuat: sce.FQuaternion, //!< Orientation data as a Quaternion + rotationMatrix: sce.FMatrix4, //!< Orientation data as a rotation matrix + nedMatrix: sce.FMatrix4, //!< Magnetometer orientation matrix + reserved2: [4]c.uint8_t, //!< Reserved data + basicOrientation: sce.FVector3, //!< Orientation of the device in reference to gravity + hostTimestamp: sce.ULong64, //!< Timestamp of the data in microseconds + reserved3: [36]c.uint8_t, //!< Reserved data + magFieldStability: c.uint8_t, //!< One of ::SceMotionMagFieldStability + unknown: c.uint8_t, //!< Unknown + reserved4: [2]c.uint8_t, //!< Reserved data +} +#assert(size_of(SceMotionState) == 0xF8) + +/** Returned motion sensor state +* @note - ::SceMotionSensorState holds actual sensor data as opposed to ::SceMotionState which uses a calculated state +*/ +SceMotionSensorState :: struct { + accelerometer: sce.FVector3, //!< Accelerometer data + gyro: sce.FVector3, //!< Angular velocity data + reserved1: [12]c.uint8_t, //!< Reserved data + timestamp: c.uint, //!< Timestamp of the data in microseconds + counter: c.uint, //!< Number of requested state + reserved2: [4]c.uint8_t, //!< Reserved data + hostTimestamp: sce.ULong64, //!< Timestamp of the data in microseconds + unknown: c.uint8_t, //!< Unknown + reserved3: [7]c.uint8_t, //!< Reserved data +} +#assert(size_of(SceMotionSensorState) == 0x40) + +/** Returned location of both the accelerometer and gyroscope in mm +* @note - Axies are fixed with z axis being straight perpendicular through the screen and x axis being parallel to the screen's bottom and top edge +* @note - Direction of the z axis is as if the device were laying on a flat surface, oled/lcd side facing upwards +* @note - OLED models should return the following values: +* @note - Accelerometer: x == -32; y == 12; z == -8 +* @note - Gyroscope: x == -33; y == 6; z == -8 +* @note - LCD models should return the following values: +* @note - Accelerometer: x == 13; y == 19; z == -8 +* @note - Gyroscope: x == 13; y == 19; z == -8 +*/ +SceMotionDeviceLocation :: struct { + accelerometer: sce.FVector3, //!< Location of te accelerometer in relation to the center of the device (in mm) + gyro: sce.FVector3, //!< Location of te gyroscope in relation to the center of the device (in mm) + reserved: [24]c.uint8_t, //!< Reserved data +} +#assert(size_of(SceMotionDeviceLocation) == 0x30) + diff --git a/MotionDev/MotionDev.odin b/MotionDev/MotionDev.odin new file mode 100644 index 0000000..4d947f0 --- /dev/null +++ b/MotionDev/MotionDev.odin @@ -0,0 +1,49 @@ +package motiondev + +import "core:c" +import sce "../common" + +foreign import motiondev "system:SceMotionDev_stub" + +// missing structs +SceMotionDevAccCalibData :: struct{} +SceMotionDevCalibrationData :: struct{} +SceMotionDevCalibrationHeader :: struct{} +SceMotionDevMagnCalibData :: struct{} +SceMotionDevDeviceInfo :: struct{} +SceMotionDevDeviceLocation :: struct{} +SceMotionDevGyroBiasData :: struct{} +SceMotionDevGyroCalibData :: struct{} +SceMotionDevModeInfo :: struct{} +SceMotionDevData :: struct{} + +@(link_prefix = "sceMotionDev") +foreign motiondev { + GetAccCalibData :: proc(data: ^SceMotionDevAccCalibData) -> c.int --- + GetAccCalibData2 :: proc(port: c.int, data: ^SceMotionDevAccCalibData) -> c.int --- + GetCalibrationData :: proc(block_id: sce.UInt32, data: ^SceMotionDevCalibrationData, data_num: sce.UInt32) -> c.int --- + GetCalibrationHeader :: proc(block_id: sce.UInt32, calib_header: ^SceMotionDevCalibrationHeader) -> c.int --- + GetCurrentMagnCalibData :: proc(data: ^SceMotionDevMagnCalibData) -> c.int --- + GetCurrentMagnStabilityLevel :: proc(level: ^sce.UInt32) -> c.int --- + GetDeviceInfo :: proc(device_info: ^SceMotionDevDeviceInfo) -> c.int --- + GetDeviceLocation :: proc(location: ^SceMotionDevDeviceLocation) -> c.int --- + GetFactoryMagnCalibData :: proc(data: ^SceMotionDevMagnCalibData) -> c.int --- + GetGyroBias :: proc(bias: ^SceMotionDevGyroBiasData) -> c.int --- + GetGyroBias2 :: proc(port: c.int, bias: ^SceMotionDevGyroBiasData) -> c.int --- + GetGyroCalibData :: proc(data: ^SceMotionDevGyroCalibData) -> c.int --- + GetGyroCalibData2 :: proc(port: c.int, data: ^SceMotionDevGyroCalibData) -> c.int --- + GetMeasMode :: proc(mode_info: ^SceMotionDevModeInfo) -> c.int --- + IsReady :: proc() -> c.int --- + MagnSamplingStart :: proc() -> c.int --- + MagnSamplingStop :: proc() -> c.int --- + Read :: proc(data: ^SceMotionDevData, data_num: c.int, info: ^sce.UInt32) -> c.int --- + Read2 :: proc(port: c.int, data: ^SceMotionDevData, data_num: c.int, info: ^sce.UInt32) -> c.int --- + ReadForMagnCalib :: proc(data: ^SceMotionDevData, data_num: c.int) -> c.int --- + SamplingStart :: proc() -> c.int --- + SamplingStart2 :: proc(port: c.int) -> c.int --- + SamplingStop :: proc() -> c.int --- + SamplingStop2 :: proc(port: c.int) -> c.int --- + SetSamplingMode :: proc(mode: sce.UInt32) -> c.int --- + UpdateMagnCalibData :: proc(#by_ptr data: SceMotionDevMagnCalibData, tag: ^sce.UInt32) -> c.int --- + UpdateMagnStabilityLevel :: proc(level: sce.UInt32) -> c.int --- +} diff --git a/Mtp/Mtp.odin b/Mtp/Mtp.odin new file mode 100644 index 0000000..5c71291 --- /dev/null +++ b/Mtp/Mtp.odin @@ -0,0 +1,26 @@ +package mtp + +import "core:c" + +foreign import mtp "system:SceMtpIfDriver_stub" + +@(link_prefix = "sceMtpIf") +foreign mtp { + /** + * Start MTP driver + * + * @param[in] flags - Set to 1 + * + * @return 0 on success, < 0 on error. + */ + StartDriver :: proc(flags: c.int) -> c.int --- + + /** + * Stop MTP driver + * + * @param[in] flags - Set to 1 + * + * @return 0 on success, < 0 on error. + */ + StopDriver :: proc(flags: c.int) -> c.int --- +} diff --git a/MusicExport/MusicExport.odin b/MusicExport/MusicExport.odin new file mode 100644 index 0000000..6dff185 --- /dev/null +++ b/MusicExport/MusicExport.odin @@ -0,0 +1,24 @@ +package musicexport + +import "core:c" +import sce "../common" + +foreign import musicexport "system:SceMusicExport_stub" + +MusicExportParam :: struct { + reserved: [128]c.char, //!< Reserved data +} +#assert(size_of(MusicExportParam) == 0x80) + +@(link_prefix = "sceMusicExport") +foreign musicexport { + FromFile :: proc( + path: cstring, + #by_ptr param: MusicExportParam, + workingMemory: rawptr, + cancelCb: rawptr, + progress: #type ^proc "c" (_: rawptr, __: c.int), + user: rawptr, + outPath: cstring, + outPathSize: sce.Size) -> c.int --- +} diff --git a/Net/Net.odin b/Net/Net.odin new file mode 100644 index 0000000..b46ef92 --- /dev/null +++ b/Net/Net.odin @@ -0,0 +1,92 @@ +package net + +import "core:c" +foreign import net "system:SceNet_stub" + +@(link_prefix = "sceNet") +foreign net { + Init :: proc(param: ^SceNetInitParam) -> c.int --- + Term :: proc() -> c.int --- + + ShowIfconfig :: proc(p: rawptr, b: c.int) -> c.int --- + ShowRoute :: proc() -> c.int --- + ShowNetstat :: proc() -> c.int --- + + EmulationSet :: proc(param: ^SceNetEmulationParam, flags: SceNetEmulationFlag) -> c.int --- + EmulationGet :: proc(param: ^SceNetEmulationParam, flags: SceNetEmulationFlag) -> c.int --- + + // flags is always 0 + ResolverCreate :: proc(name: cstring, param: ^SceNetResolverParam, flags: c.int) -> c.int --- + ResolverStartNtoa :: proc(rid: c.int, hostname: cstring, addr: ^SceNetInAddr, timeout: c.int, retry: c.int, flags: SceNetResolverFlag) -> c.int --- + ResolverStartAton :: proc(rid: c.int, addr: ^SceNetInAddr, hostname: cstring, len: c.int, timeout: c.int, retry: c.int, flags: SceNetResolverFlag) -> c.int --- + ResolverGetError :: proc(rid: c.int, result: ^c.int) -> SceNetResolverErrorCode --- + ResolverDestroy :: proc(rid: c.int) -> c.int --- + ResolverAbort :: proc(rid: c.int, flags: SceNetResolverAbortFlag) -> c.int --- + + // flags is always 0 + DumpCreate :: proc(name: cstring, len: c.int, flags: c.int) -> c.int --- + DumpRead :: proc(id: c.int, buf: rawptr, len: c.int, pflags: ^SceNetDumpReadFlag) -> c.int --- + DumpDestroy :: proc(id: c.int) -> c.int --- + DumpAbort :: proc(id: c.int, flags: SceNetDumpAbortFlag) -> c.int --- + // flags is always 0 + EpollCreate :: proc(name: cstring, flags: c.int) -> c.int --- + EpollControl :: proc(eid: c.int, op: SceNetEpollControlFlag, id: c.int, event: ^SceNetEpollEvent) -> c.int --- + EpollWait :: proc(eid: c.int, events: ^SceNetEpollEvent, maxevents: c.int, timeout: c.int) -> c.int --- + EpollWaitCB :: proc(eid: c.int, events: ^SceNetEpollEvent, maxevents: c.int, timeout: c.int) -> c.int --- + EpollDestroy :: proc(eid: c.int) -> c.int --- + EpollAbort :: proc(eid: c.int, flags: SceNetEpollAbortFlag) -> c.int --- + + EtherStrton :: proc(str: cstring, n: ^SceNetEtherAddr) -> c.int --- + EtherNtostr :: proc(n: ^SceNetEtherAddr, str: cstring, len: c.uint) -> c.int --- + // flags is always 0 + GetMacAddress :: proc(addr: ^SceNetEtherAddr, flags: ^c.int) -> c.int --- + + Socket :: proc(name: cstring, domain: c.int, type: SceNetSocketType, protocol: c.int) -> c.int --- + Accept :: proc(s: c.int, addr: ^SceNetSockaddr, addrlen: ^c.uint) -> c.int --- + Bind :: proc(s: c.int, addr: ^SceNetSockaddr, addrlen: c.uint) -> c.int --- + Connect :: proc(s: c.int, name: ^SceNetSockaddr, namelen: c.uint) -> c.int --- + Getpeername :: proc(s: c.int, name: ^SceNetSockaddr, namelen: ^c.uint) -> c.int --- + Getsockname :: proc(s: c.int, name: ^SceNetSockaddr, namelen: ^c.uint) -> c.int --- + Getsockopt :: proc(s: c.int, level: c.int, optname: c.int, optval: rawptr, optlen: ^c.uint) -> c.int --- + Listen :: proc(s: c.int, backlog: c.int) -> c.int --- + Recv :: proc(s: c.int, buf: rawptr, len: c.uint, flags: SceNetMsgFlag) -> c.int --- + Recvfrom :: proc(s: c.int, buf: rawptr, len: c.uint, flags: SceNetMsgFlag, from: ^SceNetSockaddr, fromlen: ^c.uint) -> c.int --- + Recvmsg :: proc(s: c.int, msg: ^SceNetMsghdr, flags: SceNetMsgFlag) -> c.int --- + Send :: proc(s: c.int, msg: rawptr, len: c.uint, flags: SceNetMsgFlag) -> c.int --- + Sendto :: proc(s: c.int, msg: rawptr, len: c.uint, flags: SceNetMsgFlag, to: ^SceNetSockaddr, tolen: c.uint) -> c.int --- + Sendmsg :: proc(s: c.int, msg: ^SceNetMsghdr, flags: SceNetMsgFlag) -> c.int --- + Setsockopt :: proc(s: c.int, level: c.int, optname: c.int, optval: rawptr, optlen: c.uint) -> c.int --- + Shutdown :: proc(s: c.int, how: SceNetShutdownFlag) -> c.int --- + SocketClose :: proc(s: c.int) -> c.int --- + SocketAbort :: proc(s: c.int, flags: SceNetSocketAbortFlag) -> c.int --- + // flags is always 0 + GetSockInfo :: proc(s: c.int, info: ^SceNetSockInfo, n: c.int, flags: c.int) -> c.int --- + // flags is always 0 + GetSockIdInfo :: proc(fds: ^SceNetFdSet, sockinfoflags: c.int, flags: c.int) -> c.int --- + // flags is always 0 + GetStatisticsInfo :: proc(info: ^SceNetStatisticsInfo, flags: c.int) -> c.int --- + + // flags is always 0 + SetDnsInfo :: proc(info: ^SceNetDnsInfo, flags: c.int) -> c.int --- + // flags is always 0 + ClearDnsCache :: proc(flags: c.int) -> c.int --- + + InetNtop :: proc(af: c.int, src: rawptr, dst: cstring, size: c.uint) -> cstring --- + InetPton :: proc(af: c.int, src: cstring, dst: rawptr) -> c.int --- + + //TODO : create BSD aliases ? + + Htonll :: proc(host64: c.ulonglong) -> c.ulonglong --- + Htonl :: proc(host32: c.uint) -> c.uint --- + Htons :: proc(host16: c.ushort) -> c.ushort --- + Ntohll :: proc(net64: c.ulonglong) -> c.ulonglong --- + Ntohl :: proc(net32: c.uint) -> c.uint --- + Ntohs :: proc(net16: c.ushort) -> c.ushort --- + + /** + * Get pointer to last network errno. + * + * @return pointer to int. + */ + ErrnoLoc :: proc() -> ^c.int --- +} diff --git a/Net/types.odin b/Net/types.odin new file mode 100644 index 0000000..0efeaef --- /dev/null +++ b/Net/types.odin @@ -0,0 +1,735 @@ +package net + +import "core:c" + +/** Resolver specific error codes */ +SceNetResolverErrorCode :: enum c.int { + EINTERNAL = 220, + EBUSY, + ENOSPACE, + EPACKET, + ERESERVED224, + ENODNS, + ETIMEDOUT, + ENOSUPPORT, + EFORMAT, + ESERVERFAILURE, + ENOHOST, + ENOTIMPLEMENTED, + ESERVERREFUSED, + ENORECORD, + EALIGNMENT +} + +/** Flags to specify as argument to ::sceNetDumpRead() */ +SceNetDumpReadFlag :: enum c.int { + PEEK = 0x00000010, + DONTWAIT = 0x00000020, + OVERFLOW = 0x00000040, +} + +SceNetDumpAbortFlag :: enum c.int { + PRESERVATION = 0x00000001 +} + +/** Events for ::SceNetEpollEvent */ +SceNetEpollEventType :: enum c.int { + EPOLLIN = 0x00000001, + EPOLLOUT = 0x00000002, + EPOLLERR = 0x00000008, + EPOLLHUP = 0x00000010, + EPOLLDESCID = 0x00010000 +} + +/** Flags to specify as argument to ::sceNetEpollControl() */ +SceNetEpollControlFlag :: enum c.int { + ADD = 1, + MOD, + DEL +} + +/** Flags to specify as argument to ::sceNetEmulationGet() / ::sceNetEmulationSet() */ +SceNetEmulationFlag :: enum c.int { + ETH0 = 1, + WLAN0 +} + +/** Flags to specify as argument to ::sceNetResolverStartNtoa() / ::sceNetResolverStartAton() */ +SceNetResolverFlag :: enum c.int { + ASYNC = 0x00000001, + START_NTOA_DISABLE_IPADDRESS = 0x00010000 +} + +/** Flags to specify as argument to ::sceNetResolverAbort() */ +SceNetResolverAbortFlag :: enum c.int { + NTOA_PRESERVATION = 0x00000001, + ATON_PRESERVATION = 0x00000002 +} + +/** Flags to specify as argument to ::sceNetSocketAbort() */ +SceNetSocketAbortFlag :: enum c.int { + RCV_PRESERVATION = 0x00000001, + SND_PRESERVATION = 0x00000002 +} + +/** Flags to specify as argument to ::sceNetShutdown */ +SceNetShutdownFlag :: enum c.int { + RD, + WR, + RDWR +} + +/* Defines */ +SceNetEpollAbortFlag :: enum c.int { + PRESERVATION = 0x00000001, +} + +SCE_NET_RESOLVER_PORT :: 53 +SCE_NET_RESOLVER_HOSTNAME_LEN_MAX :: 255 + +/* callback */ + +SceNetResolverFunctionAllocate :: #type ^proc( + size: c.uint, + rid: c.int, + name: cstring, + user: rawptr, +) -> rawptr + +SceNetResolverFunctionFree :: #type ^proc( + ptr: rawptr, + rid: c.int, + name: cstring, + user: rawptr, +) + +/* struct */ + +SceNetInitParam :: struct { + memory: rawptr, + size: c.int, + flags: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetInitParam) == 0xC) +} + +SceNetEmulationData :: struct { + drop_rate: c.ushort, + drop_duration: c.ushort, + pass_duration: c.ushort, + delay_time: c.ushort, + delay_jitter: c.ushort, + order_rate: c.ushort, + order_delay_time: c.ushort, + duplication_rate: c.ushort, + bps_limit: c.uint, + lower_size_limit: c.ushort, + upper_size_limit: c.ushort, + system_policy_pattern: c.uint, + game_policy_pattern: c.uint, + policy_flags: [64]c.ushort, + reserved: [64]c.uchar, +} +#assert(size_of(SceNetEmulationData) == 0xE0) + +SceNetEmulationParam :: struct { + version: c.ushort, + option_number: c.ushort, + current_version: c.ushort, + result: c.ushort, + flags: c.uint, + reserved1: c.uint, + send: SceNetEmulationData, + recv: SceNetEmulationData, + seed: c.uint, + reserved: [44]c.uchar, +} +#assert(size_of(SceNetEmulationParam) == 0x200) + +SceNetEpollDataExt :: struct { + id: c.int, + u32: c.uint, +} +#assert(size_of(SceNetEpollDataExt) == 8) + +SceNetEpollData :: struct #raw_union { + ptr: rawptr, + fd: c.int, + u32: c.uint, + u64: c.ulonglong, + ext: SceNetEpollDataExt, +} +#assert(size_of(SceNetEpollData) == 8) + +SceNetEpollSystemData :: struct { + system: [4]c.uint, +} +#assert(size_of(SceNetEpollSystemData) == 0x10) + +SceNetEpollEvent :: struct { + events: c.uint, + reserved: c.uint, + system: SceNetEpollSystemData, + data: SceNetEpollData, +} +#assert(size_of(SceNetEpollEvent) == 0x20) + +SceNetResolverParam :: struct { + allocate: SceNetResolverFunctionAllocate, + free: SceNetResolverFunctionFree, + user: rawptr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetResolverParam) == 0xC) +} + +/** Net Error Codes */ +// TODO: this should be a c.int +SceNetErrorCode :: enum i64 { + EPERM = 0x80410101, + ENOENT = 0x80410102, + ESRCH = 0x80410103, + EINTR = 0x80410104, + EIO = 0x80410105, + ENXIO = 0x80410106, + E2BIG = 0x80410107, + ENOEXEC = 0x80410108, + EBADF = 0x80410109, + ECHILD = 0x8041010A, + EDEADLK = 0x8041010B, + ENOMEM = 0x8041010C, + EACCES = 0x8041010D, + EFAULT = 0x8041010E, + ENOTBLK = 0x8041010F, + EBUSY = 0x80410110, + EEXIST = 0x80410111, + EXDEV = 0x80410112, + ENODEV = 0x80410113, + ENOTDIR = 0x80410114, + EISDIR = 0x80410115, + EINVAL = 0x80410116, + ENFILE = 0x80410117, + EMFILE = 0x80410118, + ENOTTY = 0x80410119, + ETXTBSY = 0x8041011A, + EFBIG = 0x8041011B, + ENOSPC = 0x8041011C, + ESPIPE = 0x8041011D, + EROFS = 0x8041011E, + EMLINK = 0x8041011F, + EPIPE = 0x80410120, + EDOM = 0x80410121, + ERANGE = 0x80410122, + EAGAIN = 0x80410123, + EWOULDBLOCK = 0x80410123, + EINPROGRESS = 0x80410124, + EALREADY = 0x80410125, + ENOTSOCK = 0x80410126, + EDESTADDRREQ = 0x80410127, + EMSGSIZE = 0x80410128, + EPROTOTYPE = 0x80410129, + ENOPROTOOPT = 0x8041012A, + EPROTONOSUPPORT = 0x8041012B, + ESOCKTNOSUPPORT = 0x8041012C, + EOPNOTSUPP = 0x8041012D, + EPFNOSUPPORT = 0x8041012E, + EAFNOSUPPORT = 0x8041012F, + EADDRINUSE = 0x80410130, + EADDRNOTAVAIL = 0x80410131, + ENETDOWN = 0x80410132, + ENETUNREACH = 0x80410133, + ENETRESET = 0x80410134, + ECONNABORTED = 0x80410135, + ECONNRESET = 0x80410136, + ENOBUFS = 0x80410137, + EISCONN = 0x80410138, + ENOTCONN = 0x80410139, + ESHUTDOWN = 0x8041013A, + ETOOMANYREFS = 0x8041013B, + ETIMEDOUT = 0x8041013C, + ECONNREFUSED = 0x8041013D, + ELOOP = 0x8041013E, + ENAMETOOLONG = 0x8041013F, + EHOSTDOWN = 0x80410140, + EHOSTUNREACH = 0x80410141, + ENOTEMPTY = 0x80410142, + EPROCLIM = 0x80410143, + EUSERS = 0x80410144, + EDQUOT = 0x80410145, + ESTALE = 0x80410146, + EREMOTE = 0x80410147, + EBADRPC = 0x80410148, + ERPCMISMATCH = 0x80410149, + EPROGUNAVAIL = 0x8041014A, + EPROGMISMATCH = 0x8041014B, + EPROCUNAVAIL = 0x8041014C, + ENOLCK = 0x8041014D, + ENOSYS = 0x8041014E, + EFTYPE = 0x8041014F, + EAUTH = 0x80410150, + ENEEDAUTH = 0x80410151, + EIDRM = 0x80410152, + ENOMS = 0x80410153, + EOVERFLOW = 0x80410154, + EILSEQ = 0x80410155, + ENOTSUP = 0x80410156, + ECANCELED = 0x80410157, + EBADMSG = 0x80410158, + ENODATA = 0x80410159, + ENOSR = 0x8041015A, + ENOSTR = 0x8041015B, + ETIME = 0x8041015C, + EADHOC = 0x804101A0, + EDISABLEDIF = 0x804101A1, + ERESUME = 0x804101A2, + ENOTINIT = 0x804101C8, + ENOLIBMEM = 0x804101C9, + ERESERVED202 = 0x804101CA, + ECALLBACK = 0x804101CB, + EINTERNAL = 0x804101CC, + ERETURN = 0x804101CD, + RESOLVER_EINTERNAL = 0x804101DC, + RESOLVER_EBUSY = 0x804101DD, + RESOLVER_ENOSPACE = 0x804101DE, + RESOLVER_EPACKET = 0x804101DF, + RESOLVER_ERESERVED22 = 0x804101E0, + RESOLVER_ENODNS = 0x804101E1, + RESOLVER_ETIMEDOUT = 0x804101E2, + RESOLVER_ENOSUPPORT = 0x804101E3, + RESOLVER_EFORMAT = 0x804101E4, + RESOLVER_ESERVERFAILURE = 0x804101E5, + RESOLVER_ENOHOST = 0x804101E6, + RESOLVER_ENOTIMPLEMENTED = 0x804101E7, + RESOLVER_ESERVERREFUSED = 0x804101E8, + RESOLVER_ENORECORD = 0x804101E9, + RESOLVER_EALIGNMENT = 0x804101EA +} + +/** Specific kernel and libnet error codes */ +SceNetKernelErrorCode :: enum c.int { + EPERM = 1, + ENOENT = 2, + ESRCH = 3, + EINTR = 4, + EIO = 5, + ENXIO = 6, + E2BIG = 7, + ENOEXEC = 8, + EBADF = 9, + ECHILD = 10, + EDEADLK = 11, + ENOMEM = 12, + EACCES = 13, + EFAULT = 14, + ENOTBLK = 15, + EBUSY = 16, + EEXIST = 17, + EXDEV = 18, + ENODEV = 19, + ENOTDIR = 20, + EISDIR = 21, + EINVAL = 22, + ENFILE = 23, + EMFILE = 24, + ENOTTY = 25, + ETXTBSY = 26, + EFBIG = 27, + ENOSPC = 28, + ESPIPE = 29, + EROFS = 30, + EMLINK = 31, + EPIPE = 32, + EDOM = 33, + ERANGE = 34, + EAGAIN = 35, + EWOULDBLOCK = 35, + EINPROGRESS = 36, + EALREADY = 37, + ENOTSOCK = 38, + EDESTADDRREQ = 39, + EMSGSIZE = 40, + EPROTOTYPE = 41, + ENOPROTOOPT = 42, + EPROTONOSUPPORT = 43, + ESOCKTNOSUPPORT = 44, + EOPNOTSUPP = 45, + EPFNOSUPPORT = 46, + EAFNOSUPPORT = 47, + EADDRINUSE = 48, + EADDRNOTAVAIL = 49, + ENETDOWN = 50, + ENETUNREACH = 51, + ENETRESET = 52, + ECONNABORTED = 53, + ECONNRESET = 54, + ENOBUFS = 55, + EISCONN = 56, + ENOTCONN = 57, + ESHUTDOWN = 58, + ETOOMANYREFS = 59, + ETIMEDOUT = 60, + ECONNREFUSED = 61, + ELOOP = 62, + ENAMETOOLONG = 63, + EHOSTDOWN = 64, + EHOSTUNREACH = 65, + ENOTEMPTY = 66, + EPROCLIM = 67, + EUSERS = 68, + EDQUOT = 69, + ESTALE = 70, + EREMOTE = 71, + EBADRPC = 72, + ERPCMISMATCH = 73, + EPROGUNAVAIL = 74, + EPROGMISMATCH = 75, + EPROCUNAVAIL = 76, + ENOLCK = 77, + ENOSYS = 78, + EFTYPE = 79, + EAUTH = 80, + ENEEDAUTH = 81, + EIDRM = 82, + ENOMSG = 83, + EOVERFLOW = 84, + EILSEQ = 85, + ENOTSUP = 86, + ECANCELED = 87, + EBADMSG = 88, + ENODATA = 89, + ENOSR = 90, + ENOSTR = 91, + ETIME = 92, + EADHOC = 160, + EDISABLEDIF = 161, + ERESUME = 162 +} + +/** libnet specific error codes */ +SceNetLibnetErrorCode :: enum c.int { + ENOTINIT = 200, + ENOLIBMEM, + ETLS, + ECALLBACK, + EINTERNAL, + ERETURN +} + +/** state for ::SceNetSockInfo structure */ +SceNetSockInfoState :: enum c.int { + UNKNOWN, + CLOSED, + OPENED, + LISTEN, + SYN_SENT, + SYN_RECEIVED, + ESTABLISHED, + FIN_WAIT_1, + FIN_WAIT_2, + CLOSE_WAIT, + CLOSING, + LAST_ACK, + TIME_WAIT +} + +/** flags for ::SceNetSockInfo structure */ +SceNetSockInfoFlag :: enum c.int { + SELF = 0x00000001, + KERNEL = 0x00000002, + OTHERS = 0x00000004, + RECV_WAIT = 0x00010000, + SEND_WAIT = 0x00020000, + RECV_EWAIT = 0x00040000, + SEND_EWAIT = 0x00080000, + WAKEUP_SIGNAL = 0x00100000, + ALL = 0x001F0007 +} + +/** Net Protocols */ +SceNetProtocol :: enum c.int { + IPPROTO_IP = 0, + IPPROTO_ICMP = 1, + IPPROTO_IGMP = 2, + IPPROTO_TCP = 6, + IPPROTO_UDP = 17, + SOL_SOCKET = 0xFFFF +} + +/** Socket Options */ +SceNetSocketOption :: enum c.int { + /* IP */ + IP_HDRINCL = 2, + IP_TOS = 3, + IP_TTL = 4, + IP_MULTICAST_IF = 9, + IP_MULTICAST_TTL = 10, + IP_MULTICAST_LOOP = 11, + IP_ADD_MEMBERSHIP = 12, + IP_DROP_MEMBERSHIP = 13, + IP_TTLCHK = 23, + IP_MAXTTL = 24, + /* TCP */ + TCP_NODELAY = 1, + TCP_MAXSEG = 2, + TCP_MSS_TO_ADVERTISE = 3, + /* SOCKET */ + SO_REUSEADDR = 0x00000004, + SO_KEEPALIVE = 0x00000008, + SO_BROADCAST = 0x00000020, + SO_LINGER = 0x00000080, + SO_OOBINLINE = 0x00000100, + SO_REUSEPORT = 0x00000200, + SO_ONESBCAST = 0x00000800, + SO_USECRYPTO = 0x00001000, + SO_USESIGNATURE = 0x00002000, + SO_SNDBUF = 0x1001, + SO_RCVBUF = 0x1002, + SO_SNDLOWAT = 0x1003, + SO_RCVLOWAT = 0x1004, + SO_SNDTIMEO = 0x1005, + SO_RCVTIMEO = 0x1006, + SO_ERROR = 0x1007, + SO_TYPE = 0x1008, + SO_NBIO = 0x1100, + SO_TPPOLICY = 0x1101, + SO_NAME = 0x1102 +} + +/** Socket types */ +SceNetSocketType :: enum c.int { + STREAM = 1, + DGRAM = 2, + RAW = 3, + DGRAM_P2P = 6, + STREAM_P2P = 10 +} + +/** MSG Flags */ +SceNetMsgFlag :: enum c.int { + PEEK = 0x00000002, + WAITALL = 0x00000040, + DONTWAIT = 0x00000080, + USECRYPTO = 0x00000400, + USESIGNATURE = 0x00000800 +} + +/** Types to specify to ::SceNetIcmpHeader structure */ +SceNetIcmpType :: enum c.int { + ECHO_REPLY = 0, + DEST_UNREACH = 3, + SOURCE_QUENCH = 4, + REDIRECT = 5, + ECHO_REQUEST = 8, + TIME_EXCEEDED = 11, + PARAMETER_PROBLEM = 12, + TIMESTAMP_REQUEST = 13, + TIMESTAMP_REPLY = 14, + INFORMATION_REQUEST = 15, + INFORMATION_REPLY = 16, + ADDRESS_MASK_REQUEST = 17, + ADDRESS_MASK_REPLY = 18 +} + +/** Codes to specify to ::SceNetIcmpHeader structure */ +SceNetIcmpCode :: enum c.int { + DEST_UNREACH_NET_UNREACH = 0, + DEST_UNREACH_HOST_UNREACH = 1, + DEST_UNREACH_PROTO_UNREACH = 2, + DEST_UNREACH_PORT_UNREACH = 3, + DEST_UNREACH_FRAG_AND_DF = 4, + DEST_UNREACH_SRC_HOST_FAILED = 5, + DEST_UNREACH_DST_NET_UNKNOWN = 6, + DEST_UNREACH_DST_HOST_UNKNOWN = 7, + DEST_UNREACH_SRC_HOST_ISOLATED = 8, + DEST_UNREACH_NET_ADMIN_PROHIBITED = 9, + DEST_UNREACH_NET_HOST_PROHIBITED = 10, + DEST_UNREACH_NET_TOS = 11, + DEST_UNREACH_HOST_TOS = 12, + TIME_EXCEEDED_TTL_EXCEEDED = 0, + TIME_EXCEEDED_FRT_EXCEEDED = 1 +} + +SCE_NET_IP_DEFAULT_MULTICAST_TTL :: 1 +SCE_NET_IP_DEFAULT_MULTICAST_LOOP :: 1 + +SCE_NET_IPVERSION :: 4 + +SCE_NET_IP_RF :: 0x8000 +SCE_NET_IP_DF :: 0x4000 +SCE_NET_IP_MF :: 0x2000 +SCE_NET_IP_OFFMASK :: 0x1FFF + +SCE_NET_INADDR_ANY :: 0x00000000 +SCE_NET_INADDR_LOOPBACK :: 0x7F000001 +SCE_NET_INADDR_BROADCAST :: 0xFFFFFFFF +SCE_NET_INADDR_UNSPEC_GROUP :: 0xE0000000 +SCE_NET_INADDR_AUTOIP :: 0xA9FE0000 + +SCE_NET_IN_CLASSD_NET :: 0xF0000000 +SCE_NET_IN_AUTOIP_NET :: 0xFFFF0000 + +SCE_NET_ADHOC_PORT :: 3658 + +SCE_NET_AF_INET :: 2 + +SCE_NET_DEBUG_NAME_LEN_MAX :: 31 + +SCE_NET_ID_SOCKET_MIN :: 0 +SCE_NET_ID_SOCKET_MAX :: 1023 + +SceNetFdSet :: struct { + bits: [32]c.uint, +} +#assert(size_of(SceNetFdSet) == 0x80) + +SceNetInAddr :: struct { + s_addr: c.uint, +} +#assert(size_of(SceNetInAddr) == 4) + +SceNetSockaddrIn :: struct { + sin_len: c.uchar, + sin_family: c.uchar, + sin_port: c.ushort, + sin_addr: SceNetInAddr, + sin_vport: c.ushort, + sin_zero: [6]c.char, +} +#assert(size_of(SceNetSockaddrIn) == 0x10) + +SceNetIpMreq :: struct { + imr_multiaddr: SceNetInAddr, + imr_interface: SceNetInAddr, +} +#assert(size_of(SceNetIpMreq) == 8) + +SceNetEtherAddr :: struct { + data: [6]c.uchar, +} +#assert(size_of(SceNetEtherAddr) == 6) + +SceNetDnsInfo :: struct { + dns_addr: [2]SceNetInAddr, +} +#assert(size_of(SceNetDnsInfo) == 8) + +SceNetLinger :: struct { + l_onoff: c.int, + l_linger: c.int, +} +#assert(size_of(SceNetLinger) == 8) + +SceNetSockaddr :: struct { + sa_len: c.uchar, + sa_family: c.uchar, + sa_data: [14]c.char, +} +#assert(size_of(SceNetSockaddr) == 0x10) + +SceNetIovec :: struct { + iov_base: rawptr, + iov_len: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetIovec) == 8) +} + +SceNetMsghdr :: struct { + msg_name: rawptr, + msg_namelen: c.uint, + msg_iov: ^SceNetIovec, + msg_iovlen: c.int, + msg_control: rawptr, + msg_controllen: c.uint, + msg_flags: c.int, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetMsghdr) == 0x1C) +} + +SceNetSockInfo :: struct { + name: [SCE_NET_DEBUG_NAME_LEN_MAX + 1]c.char, + pid: c.int, + s: c.int, + socket_type: c.char, + policy: c.char, + reserved16: c.short, + recv_queue_length: c.int, + send_queue_length: c.int, + local_adr: SceNetInAddr, + remote_adr: SceNetInAddr, + local_port: c.ushort, + remote_port: c.ushort, + local_vport: c.ushort, + remote_vport: c.ushort, + state: c.int, + flags: c.int, + reserved: [8]c.int, +} +#assert(size_of(SceNetSockInfo) == 0x6C) + +SceNetStatisticsInfo :: struct { + kernel_mem_free_size: c.int, + kernel_mem_free_min: c.int, + packet_count: c.int, + packet_qos_count: c.int, + + libnet_mem_free_size: c.int, + libnet_mem_free_min: c.int, +} +#assert(size_of(SceNetStatisticsInfo) == 0x18) + +SceNetIpHeaderIpVerHl :: struct { + hl: c.char, + ver: c.char, +} +#assert(size_of(SceNetIpHeaderIpVerHl) == 2) + +SceNetIpHeaderUnion :: struct #raw_union { + ip_ver_hl: SceNetIpHeaderIpVerHl , + ver_hl: c.uchar, +} +#assert(size_of(SceNetIpHeaderUnion) == 2) + +SceNetIpHeader :: struct { + un: SceNetIpHeaderUnion, + ip_tos: c.uchar, + ip_len: c.ushort, + ip_id: c.ushort, + ip_off: c.ushort, + ip_ttl: c.uchar, + ip_p: c.uchar, + ip_sum: c.ushort, + ip_src: SceNetInAddr, + ip_dst: SceNetInAddr, +} +#assert(size_of(SceNetIpHeader) == 0x18) + +SceNetIcmpHeaderEcho :: struct { + id: c.ushort, + sequence: c.ushort, +} +#assert(size_of(SceNetIcmpHeaderEcho) == 4) + +SceNetIcmpHeaderFrag :: struct { + unused: c.ushort, + mtu: c.ushort, +} +#assert(size_of(SceNetIcmpHeaderFrag) == 4) + +SceNetIcmpHeaderUnion :: struct #raw_union { + echo: SceNetIcmpHeaderEcho, + gateway: c.uint, + frag: SceNetIcmpHeaderFrag, +} +#assert(size_of(SceNetIcmpHeaderUnion) == 4) + +SceNetIcmpHeader :: struct { + type: c.uchar, + code: c.uchar, + checksum: c.ushort, + un: SceNetIcmpHeaderUnion, +} +#assert(size_of(SceNetIcmpHeader) == 8) + diff --git a/NetCtl/NetCtl.odin b/NetCtl/NetCtl.odin new file mode 100644 index 0000000..91b5eb2 --- /dev/null +++ b/NetCtl/NetCtl.odin @@ -0,0 +1,30 @@ +package netctl + +import "core:c" + +foreign import netctl "system:SceNetCtl_stub" + +@(link_prefix = "SceNetCtl") +foreign netctl { + Init :: proc() -> c.int --- + Term :: proc() --- + + CheckCallback :: proc() -> c.int --- + + InetGetResult :: proc(eventType: c.int, errorCode: ^c.int) -> c.int --- + AdhocGetResult :: proc(eventType: c.int, errorCode: ^c.int) -> c.int --- + + InetGetInfo :: proc(code: c.int, info: ^SceNetCtlInfo) -> c.int --- + InetGetState :: proc(state: ^c.int) -> c.int --- + GetNatInfo :: proc(natinfo: ^SceNetCtlNatInfo) -> c.int --- + + InetRegisterCallback :: proc(func: SceNetCtlCallback, arg: rawptr, cid: ^c.int) -> c.int --- + InetUnregisterCallback :: proc(cid: c.int) -> c.int --- + + AdhocRegisterCallback :: proc(func: SceNetCtlCallback, arg: rawptr, cid: ^c.int) -> c.int --- + AdhocUnregisterCallback :: proc(cid: c.int) -> c.int --- + AdhocGetState :: proc(state: ^c.int) -> c.int --- + AdhocDisconnect :: proc() -> c.int --- + AdhocGetPeerList :: proc(buflen: ^c.uint, buf: rawptr) -> c.int --- + AdhocGetInAddr :: proc(inaddr: ^SceNetInAddr) -> c.int --- +} diff --git a/NetCtl/types.odin b/NetCtl/types.odin new file mode 100644 index 0000000..55f54f6 --- /dev/null +++ b/NetCtl/types.odin @@ -0,0 +1,103 @@ +package netctl + +import "core:c" + +SCE_NETCTL_INFO_CONFIG_NAME_LEN_MAX :: 64 +SCE_NETCTL_INFO_SSID_LEN_MAX :: 32 + +SceNetCtlInfoType :: enum c.int { + GET_CNF_NAME = 1, + GET_DEVICE, + GET_ETHER_ADDR, + GET_MTU, + GET_LINK, + GET_BSSID, + GET_SSID, + GET_WIFI_SECURITY, + GET_RSSI_DBM, + GET_RSSI_PERCENTAGE, + GET_CHANNEL, + GET_IP_CONFIG, + GET_DHCP_HOSTNAME, + GET_PPPOE_AUTH_NAME, + GET_IP_ADDRESS, + GET_NETMASK, + GET_DEFAULT_ROUTE, + GET_PRIMARY_DNS, + GET_SECONDARY_DNS, + GET_HTTP_PROXY_CONFIG, + GET_HTTP_PROXY_SERVER, + GET_HTTP_PROXY_PORT, +} + +SceNetCtlState :: enum c.int { + DISCONNECTED, + CONNECTING, + FINALIZING, + CONNECTED +} + +/* callback */ + +SceNetCtlCallback :: #type ^proc( + event_type: c.int, + arg: rawptr, +) -> rawptr + +/* struct/union */ + +// TODO: copy-pasted from Net/types.odin. should prob be in common or something +SceNetEtherAddr :: struct { + data: [6]c.uchar, +} +#assert(size_of(SceNetEtherAddr) == 6) + +// TODO: copy-pasted from Net/types.odin. should prob be in common or something +SceNetInAddr :: struct { + s_addr: c.uint, +} +#assert(size_of(SceNetInAddr) == 4) + +SceNetCtlInfo :: struct #raw_union { + cnf_name: [SCE_NETCTL_INFO_CONFIG_NAME_LEN_MAX + 1]c.char, + device: c.uint, + ether_addr: SceNetEtherAddr, + mtu: c.uint, + link: c.uint, + bssid: SceNetEtherAddr, + ssid: [SCE_NETCTL_INFO_SSID_LEN_MAX + 1]c.char, + wifi_security: c.uint, + rssi_dbm: c.uint, + rssi_percentage: c.uint, + channel: c.uint, + ip_config: c.uint, + dhcp_hostname: [256]c.char, + pppoe_auth_name: [128]c.char, + ip_address: [16]c.char, + netmask: [16]c.char, + default_route: [16]c.char, + primary_dns: [16]c.char, + secondary_dns: [16]c.char, + http_proxy_config: c.uint, + http_proxy_server: [256]c.char, + http_proxy_port: c.uint, +} +#assert(size_of(SceNetCtlInfo) == 0x100) + + +SceNetCtlNatInfo :: struct { + size: c.uint, + stun_status: c.int, + nat_type: c.int, + mapped_addr: SceNetInAddr, +} +#assert(size_of(SceNetCtlNatInfo) == 0x10) + +SceNetCtlAdhocPeerInfo :: struct { + next: ^SceNetCtlAdhocPeerInfo, + inet_addr: SceNetInAddr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetCtlAdhocPeerInfo) == 8) +} + diff --git a/NetSyscalls/NetSyscalls.odin b/NetSyscalls/NetSyscalls.odin new file mode 100644 index 0000000..15e813f --- /dev/null +++ b/NetSyscalls/NetSyscalls.odin @@ -0,0 +1,55 @@ +package net_syscalls + +import "core:c" + +foreign import net_syscalls "system:SceNetPsForSyscalls_stub" + +SceNetSyscallParameter :: struct{} // missing struct + +@(link_prefix = "sceNetSyscall") +foreign net_syscalls { + Accept :: proc(s: c.int, addr: rawptr, addrlen: rawptr) -> c.int --- + Bind :: proc(s: c.int, addr: rawptr, addrlen: c.int) -> c.int --- + Close :: proc(s: c.int) -> c.int --- + Connect :: proc(s: c.int, name: rawptr, namelen: c.int) -> c.int --- + Control :: proc(if_index: c.int, code: c.int, ptr: rawptr, len: c.int) -> c.int --- + DescriptorClose :: proc(id: c.int) -> c.int --- + DescriptorCreate :: proc(name: cstring, flags: c.int) -> c.int --- + DescriptorCtl :: proc(id: c.int, op: c.int, s: c.int, info: rawptr) -> c.int --- + DumpAbort :: proc(id: c.int, flags: c.int) -> c.int --- + DumpClose :: proc(id: c.int) -> c.int --- + DumpCreate :: proc(name: cstring, len: c.int, flags: c.int) -> c.int --- + DumpRead :: proc(id: c.int, buf: rawptr, len: c.int, pflags: rawptr) -> c.int --- + EpollAbort :: proc(eid: c.int, flags: c.int) -> c.int --- + EpollClose :: proc(eid: c.int) -> c.int --- + EpollCreate :: proc(name: cstring, flags: c.int) -> c.int --- + EpollCtl :: proc(eid: c.int, op: c.int, id: c.int, event: rawptr) -> c.int --- + EpollWait :: proc(param: ^SceNetSyscallParameter) -> c.int --- + + /** + * @brief Get net if list + * + * @param[out] list - The output buffer list. size is (0x140 * n) + * @param[in] n - The output size number. + * + * @return 0 on success, < 0 on error. + */ + GetIfList :: proc(list: rawptr, n: c.int) -> c.int --- + + GetSockinfo :: proc(s: c.int, ptr: rawptr, n: c.int, flags: c.int) -> c.int --- + Getpeername :: proc(s: c.int, name: rawptr, namelen: rawptr) -> c.int --- + Getsockname :: proc(s: c.int, name: rawptr, namelen: rawptr) -> c.int --- + Getsockopt :: proc(param: ^SceNetSyscallParameter) -> c.int --- + IcmConnect :: proc(s: c.int, flags: c.int) -> c.int --- + Ioctl :: proc(s: c.int, com: c.uint, data: rawptr) -> c.int --- + Listen :: proc(s: c.int, backlog: c.int) -> c.int --- + Recvfrom :: proc(param: ^SceNetSyscallParameter) -> c.int --- + Recvmsg :: proc(s: c.int, msg: rawptr, flags: c.int) -> c.int --- + Sendmsg :: proc(s: c.int, msg: rawptr, flags: c.int) -> c.int --- + Sendto :: proc(param: ^SceNetSyscallParameter) -> c.int --- + Setsockopt :: proc(param: ^SceNetSyscallParameter) -> c.int --- + Shutdown :: proc(s: c.int, how: c.int) -> c.int --- + Socket :: proc(name: cstring, domain: c.int, type: c.int, protocol: c.int) -> c.int --- + SocketAbort :: proc(s: c.int, flags: c.int) -> c.int --- + Sysctl :: proc(param: ^SceNetSyscallParameter) -> c.int --- +} diff --git a/Ngs/Ngs.odin b/Ngs/Ngs.odin new file mode 100644 index 0000000..df3e735 --- /dev/null +++ b/Ngs/Ngs.odin @@ -0,0 +1,71 @@ +package ngs + +import "core:c" +import sce "../common" + +foreign import ngs "sceNgs_stub" + +@(link_prefix = "sceNgs") +foreign ngs { + ModuleCheckParamsInRangeInternal :: proc(handle: SceNgsHVoice, module_id: SceNgsModuleID, #by_ptr descriptor: SceNgsParamsDescriptor, size: sce.UInt32) -> sce.Int32 --- + ModuleGetNumPresetsInternal :: proc(handle: SceNgsHSynSystem, module_id: SceNgsModuleID, num_presets: ^sce.UInt32) -> sce.Int32 --- + ModuleGetPresetInternal :: proc(handle: SceNgsHSynSystem, module_id: SceNgsModuleID, preset_index: sce.UInt32, info: ^SceNgsBufferInfo) -> sce.Int32 --- + PatchCreateRoutingInternal :: proc(#by_ptr info: SceNgsPatchSetupInfo, handle: ^SceNgsHPatch) -> sce.Int32 --- + PatchRemoveRoutingInternal :: proc(handle: SceNgsHPatch) -> sce.Int32 --- + RackGetRequiredMemorySizeInternal :: proc(handle: SceNgsHSynSystem, #by_ptr rack_description: SceNgsRackDescription, user_size: ^sce.UInt32) -> sce.Int32 --- + RackGetVoiceHandleInternal :: proc(rack_handle: SceNgsHRack, index: sce.UInt32, voice_handle: ^SceNgsHVoice) -> sce.Int32 --- + RackInitInternal :: proc(system_handle: SceNgsHSynSystem, rack_buffer: ^SceNgsBufferInfo, #by_ptr rack_description: SceNgsRackDescription, rack_handle: ^SceNgsHRack) -> sce.Int32 --- + RackReleaseInternal :: proc(handle: SceNgsHRack, callback: SceNgsRackReleaseCallbackFunc) -> sce.Int32 --- + RackSetParamErrorCallbackInternal :: proc(rack_handle: SceNgsHRack, callback: SceNgsParamsErrorCallbackFunc) -> sce.Int32 --- + SulphaGetInfoInternal :: proc(#by_ptr obj_reg: SulphaNgsRegistration, info: ^SceNgsBufferInfo) -> sce.Int32 --- + SulphaGetModuleListInternal :: proc(module_ids: ^sce.UInt32, in_array_count: sce.UInt32, count: ^sce.UInt32) -> sce.Int32 --- + SulphaGetSynthUpdateCallbackInternal :: proc(handle: SceNgsHSynSystem, update_callback: ^SceNgsSulphaUpdateCallback, info: ^SceNgsBufferInfo) -> sce.Int32 --- + SulphaQueryModuleInternal :: proc(type: SulphaNgsModuleQueryType, debug: ^SulphaNgsModuleQuery) -> sce.Int32 --- + SulphaSetSynthUpdateCallbackInternal :: proc(handle: SceNgsHSynSystem, update_callback: SceNgsSulphaUpdateCallback, info: ^SceNgsBufferInfo) -> sce.Int32 --- + SystemGetCallbackListInternal :: proc(handle: SceNgsHSynSystem, array: ^[^]SceNgsCallbackListInfo, array_size: ^sce.UInt32) -> sce.Int32 --- + SystemGetRequiredMemorySizeInternal :: proc(#by_ptr params: SceNgsSystemInitParams, size: ^sce.UInt32) -> sce.Int32 --- + SystemInitInternal :: proc(buffer_info: ^SceNgsBufferInfo, compiled_sdk_version: sce.UInt32, #by_ptr params: SceNgsSystemInitParams, handle: ^SceNgsHSynSystem) -> sce.Int32 --- + SystemLockInternal :: proc(handle: SceNgsHSynSystem) -> sce.Int32 --- + SystemPullDataInternal :: proc(handle: SceNgsHSynSystem, dirty_flags_a: sce.UInt32, dirty_flags_b: sce.UInt32) -> sce.Int32 --- + SystemPushDataInternal :: proc(handle: SceNgsHSynSystem) -> sce.Int32 --- + SystemReleaseInternal :: proc(handle: SceNgsHSynSystem) -> sce.Int32 --- + SystemSetFlagsInternal :: proc(handle: SceNgsHSynSystem, system_flags: sce.UInt32) -> sce.Int32 --- + SystemSetParamErrorCallbackInternal :: proc(handle: SceNgsHSynSystem, callback_id: SceNgsParamsErrorCallbackFunc) -> sce.Int32 --- + SystemUnlockInternal :: proc(handle: SceNgsHSynSystem) -> sce.Int32 --- + SystemUpdateInternal :: proc(handle: SceNgsHSynSystem) -> sce.Int32 --- + VoiceBypassModuleInternal :: proc(handle: SceNgsHVoice, module: sce.UInt32, flag: sce.UInt32) -> sce.Int32 --- + VoiceClearDirtyFlagInternal :: proc(handle: SceNgsHVoice, param_bit_flag: sce.UInt32) -> sce.Int32 --- + VoiceDefinitionGetPresetInternal :: proc(#by_ptr definition: SceNgsVoiceDefinition, index: sce.UInt32, presets: ^^SceNgsVoicePreset) -> sce.Int32 --- + VoiceGetModuleBypassInternal :: proc(handle: SceNgsHVoice, module: sce.UInt32, flag: ^sce.UInt32) -> sce.Int32 --- + VoiceGetOutputPatchInternal :: proc(handle: SceNgsHVoice, nOutputIndex: sce.Int32, nSubIndex: sce.Int32, pPatchHandle: ^SceNgsHPatch) -> sce.Int32 --- + VoiceGetParamsOutOfRangeBufferedInternal :: proc(handle: SceNgsHVoice, module: sce.UInt32, message_buffer: [^]c.char) -> sce.Int32 --- + VoiceInitInternal :: proc(handle: SceNgsHVoice, #by_ptr preset: SceNgsVoicePreset, flags: sce.UInt32) -> sce.Int32 --- + VoiceKeyOffInternal :: proc(handle: SceNgsHVoice) -> sce.Int32 --- + VoiceKillInternal :: proc(handle: SceNgsHVoice) -> sce.Int32 --- + VoicePauseInternal :: proc(handle: SceNgsHVoice) -> sce.Int32 --- + VoicePlayInternal :: proc(handle: SceNgsHVoice) -> sce.Int32 --- + VoiceResumeInternal :: proc(handle: SceNgsHVoice) -> sce.Int32 --- + VoiceSetAllBypassesInternal :: proc(handle: SceNgsHVoice, bitflag: sce.UInt32) -> sce.Int32 --- + VoiceSetFinishedCallbackInternal :: proc(handle: SceNgsHVoice, callback: SceNgsCallbackFunc, userdata: rawptr) -> sce.Int32 --- + VoiceSetModuleCallbackInternal :: proc(handle: SceNgsHVoice, module: sce.UInt32, callback: SceNgsModuleCallbackFunc, callback_userdata: rawptr) -> sce.Int32 --- + VoiceSetPresetInternal :: proc(handle: SceNgsHVoice, #by_ptr preset: SceNgsVoicePreset) -> sce.Int32 --- + + VoiceDefGetAtrac9VoiceInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetCompressorBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetCompressorSideChainBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetDelayBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetDistortionBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetEnvelopeBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetEqBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetMasterBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetMixerBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetPauserBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetPitchshiftBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetReverbBussInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetSasEmuVoiceInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetScreamVoiceAT9Internal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetScreamVoiceInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetSimpleAtrac9VoiceInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetSimpleVoiceInternal :: proc() -> ^SceNgsVoiceDefinition --- + VoiceDefGetTemplate1Internal :: proc() -> ^SceNgsVoiceDefinition --- +} diff --git a/Ngs/types.odin b/Ngs/types.odin new file mode 100644 index 0000000..4067593 --- /dev/null +++ b/Ngs/types.odin @@ -0,0 +1,38 @@ +package ngs + +import "core:c" +import sce "../common" + +SceNgsHRack :: sce.UInt32 +#assert(size_of(SceNgsHRack) == 4) +SceNgsHPatch :: sce.UInt32 +#assert(size_of(SceNgsHPatch) == 4) +SceNgsHSynSystem :: sce.UInt32 +#assert(size_of(SceNgsHSynSystem) == 4) +SceNgsHVoice :: sce.UInt32 +#assert(size_of(SceNgsHVoice) == 4) +SulphaNgsModuleQueryType :: sce.UInt32 +#assert(size_of(SulphaNgsModuleQueryType) == 4) +SceNgsModuleID :: sce.UInt32 +#assert(size_of(SceNgsModuleID) == 4) +SceNgsSulphaUpdateCallback :: rawptr + +SceNgsCallbackFunc :: #type ^proc "c" (#by_ptr callback_info: SceNgsCallbackInfo) + +SceNgsRackReleaseCallbackFunc :: SceNgsCallbackFunc +SceNgsModuleCallbackFunc :: SceNgsCallbackFunc +SceNgsParamsErrorCallbackFunc :: SceNgsCallbackFunc + +// missing structs +SceNgsVoicePreset :: struct{} +SceNgsBufferInfo :: struct{} +SceNgsSystemInitParams :: struct{} +SceNgsCallbackListInfo :: struct{} +SulphaNgsModuleQuery :: struct{} +SulphaNgsRegistration :: struct{} +SceNgsRackDescription :: struct{} +SceNgsPatchSetupInfo :: struct{} +SceNgsParamsDescriptor :: struct{} +SceNgsCallbackInfo :: struct{} +SceNgsVoiceDefinition :: struct{} + diff --git a/NotificationUtil/NotificationUtil.odin b/NotificationUtil/NotificationUtil.odin new file mode 100644 index 0000000..658b9d4 --- /dev/null +++ b/NotificationUtil/NotificationUtil.odin @@ -0,0 +1,43 @@ +package notificationutil + +import "core:c" +import sce "../common" + +foreign import notificationutil "system:SceNotificationUtil_stub" + +@(link_prefix = "sceNotificationUtil") +foreign notificationutil { + /** + * Initialize notification util for use with BG application. + * + * Does not need to be called for normal applications. + */ + BgAppInitialize :: proc() -> sce.Int32 --- + + /** + * Send notification. + * + * Text buffer size must be 0x410. + */ + SendNotification :: proc(text: [^]sce.WChar16) -> sce.Int32 --- + + /** + * Clean notifications for calling app from notification history. + */ + CleanHistory :: proc() -> sce.Int32 --- + + /** + * Start BGDL-type notification. + */ + ProgressBegin :: proc(initParams: ^SceNotificationUtilProgressInitParam) -> sce.Int32 --- + + /** + * Update BGDL-type notification. + */ + ProgressUpdate :: proc(updateParams: ^SceNotificationUtilProgressUpdateParam) -> sce.Int32 --- + + /** + * Finish BGDL-type notification. + */ + ProgressFinish :: proc(finishParams: ^SceNotificationUtilProgressFinishParam) -> sce.Int32 --- +} diff --git a/NotificationUtil/types.odin b/NotificationUtil/types.odin new file mode 100644 index 0000000..30183f9 --- /dev/null +++ b/NotificationUtil/types.odin @@ -0,0 +1,55 @@ +package notificationutil + +import "core:c" +import sce "../common" + +/** + * Constants + */ +SCE_NOTIFICATIONUTIL_TEXT_MAX :: 0x3F + +/** + * Error Codes + */ +// TODO: +SceNotificationUitlErrorCode :: enum c.uint { + INTERNAL = 0x80106300 +} + +/** + * BGDL-type notification event handler function + */ +SceNotificationUtilProgressEventHandler :: #type ^proc "c" (eventId: c.int) + +SceNotificationUtilProgressInitParam :: struct { + notificationText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator0: sce.Int16, //must be 0 + notificationSubText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator1: sce.Int16, //must be 0 + unk: [0x3E6]sce.Char8, + unk_4EC: sce.Int32, //can be set to 0 + eventHandler: SceNotificationUtilProgressEventHandler, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNotificationUtilProgressInitParam) == 0x4F0) +} + +SceNotificationUtilProgressUpdateParam :: struct { + notificationText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator0: sce.Int16, //must be 0 + notificationSubText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator1: sce.Int16, //must be 0 + targetProgress: sce.Float, + reserved: [0x38]sce.Char8, +} +#assert(size_of(SceNotificationUtilProgressUpdateParam) == 0x13C) + +SceNotificationUtilProgressFinishParam :: struct { + notificationText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator0: sce.Int16, //must be 0 + notificationSubText: [SCE_NOTIFICATIONUTIL_TEXT_MAX]sce.WChar16, + separator1: sce.Int16, //must be 0 + path: [0x3E8]sce.Char8, +} +#assert(size_of(SceNotificationUtilProgressFinishParam) == 0x4E8) + diff --git a/NpDrm/NpDrm.odin b/NpDrm/NpDrm.odin new file mode 100644 index 0000000..24f21ab --- /dev/null +++ b/NpDrm/NpDrm.odin @@ -0,0 +1,100 @@ +package npdrm + +import "core:c" +import sce "../common" + +foreign import npdrm "system:SceNpDrm_stub" +foreign import npdrmpackage "system:SceNpDrmPackage_stub" + +foreign npdrm { + /** + * Get rif name + * + * @param[out] rif_name - RIF name buffer (48 bytes) + * + * @param[in] aid - Account ID + * + * @return 0 on success, < 0 on error. + */ + _sceNpDrmGetRifName :: proc(rif_name: [^]c.char, aid: c.uint64_t) -> c.int --- + + /** + * Get fixed rif name + * + * @param[out] rif_name - RIF name buffer (48 bytes) + * + * @param[in] aid - Account ID + * + * @return 0 on success, < 0 on error. + */ + _sceNpDrmGetFixedRifName :: proc(rif_name: [^]c.char, aid: c.uint64_t) -> c.int --- + + /** + * Check you have npdrm activation data, and get information from it + * + * @param[out] act_type - The pointer of activation type output. + * + * @param[out] version_flag - The pointer of version flag output. + * + * @param[out] account_id - The pointer of activated account id output. + * + * @param[out] act_exp_time - The pointer of activation expire time output, [0] is start_date, [1] is end_date + * + * @return 0 on success, < 0 on error. + */ + _sceNpDrmCheckActData :: proc(act_type: ^c.int, version_flag: ^c.int, account_id: ^sce.UInt64, act_exp_time: [2]sce.UInt64) -> c.int --- + + /** + * Get rif name for install + * + * @param[out] rif_name - RIF name buffer (48 bytes) + * + * @param[in] rif_data - Data of RIF file (512 bytes) + * + * @param[in] unk - Unknown, use 0 + * + * @return 0 on success, < 0 on error. + */ + _sceNpDrmGetRifNameForInstall :: proc(rif_name: [^]c.char, rif_data: rawptr, unk: c.int) -> c.int --- + + /** + * Get PSM rif key + * + * @param[in] license_buf - RIF buffer (1024 bytes) + * + * @param[out] keydata - Decrypted key data + * + * @param[in] flags - Unknown + * + * @return 0 on success, < 0 on error + */ + scePsmDrmGetRifKey :: proc(#by_ptr license_buf: ScePsmDrmLicense, keydata: [^]c.char, flags: c.int) -> c.int --- +} + +@(link_prefix = "_sceNpDrmPackage") +foreign npdrmpackage { + /** + * Read the header of the PKG and initialize the context + * + * @param buffer - The buffer containing the header of PKG. + * @param size - The size of buffer. The minimum confirmed value is 0x8000. + * @param zero - Unknown. Supposed to be set to 0. + * @param identifier - arbitrary value [0, 6) ORed with (1 << 8) or 0. + * If it is set to 0, the function just checks the header + * and doesn't create the context. + * + * @return 0 on success, != 0 on error + */ + Check :: proc(buffer: rawptr, size: sce.Size, zero: c.int, identifier: c.uint) -> c.int --- + + /** + * Decrypt a PKG + * + * @param buffer - The buffer containing the content of the PKG. + * @param size - The size of the buffer. The minimum confirmed value is 0x20. + * @param opt - The options. + * + * @return 0 on success, != 0 on error + */ + Decrypt :: proc(#no_alias buffer: rawptr, size: sce.Size, #no_alias opt: ^_sceNpDrmPackageDecrypt_opt) -> c.int --- +} diff --git a/NpDrm/types.odin b/NpDrm/types.odin new file mode 100644 index 0000000..6a573c1 --- /dev/null +++ b/NpDrm/types.odin @@ -0,0 +1,80 @@ +package npdrm + +import "core:c" +import sce "../common" + +SceNpDrmActivationData :: struct { // size is 0x1038 + act_type: sce.Int16, + version_flag: sce.Int16, + version: sce.Int32, + account_id: sce.UInt64, + primary_key_table: [0x80][0x10]sce.UInt8, + unk1: [0x40]sce.UInt8, + openpsid: [0x10]sce.UInt8, + unk2: [0x10]sce.UInt8, + unk3: [0x10]sce.UInt8, + secondary_key_table: [0x65][0x10]sce.UInt8, + rsa_signature: [0x100]sce.UInt8, + unk_sigmature: [0x40]sce.UInt8, + ecdsa_signature: [0x28]sce.UInt8, // checked by pspemu, and SceNpDrm. +} +#assert(size_of(SceNpDrmActivationData) == 0x1038) + +SceNpDrmLicense :: struct { // size is 0x200 + version: sce.Int16, // -1 VITA, 0 PSP, 1 PSP-VITA + version_flags: sce.Int16, // 0, 1 + license_type: sce.Int16, // 1 + license_flags: sce.Int16, // 0x400:non-check ecdsa + account_id: sce.UInt64, + content_id: [0x30]c.char, + key_table: [0x10]c.char, + key1: [0x10]c.char, + start_time: sce.Int64, + expiration_time: sce.Int64, + ecdsa_signature: [0x28]c.char, + flags: sce.Int64, + key2: [0x10]c.char, + unk_0xB0: [0x10]c.char, + open_psid: [0x10]c.char, + unk_0xD0: [0x10]c.char, + cmd56_handshake_part: [0x14]c.char, + debug_upgradable: c.int, + unk_0xF8: c.int, + sku_flag: c.int, + rsa_signature: [0x100]c.char, +} +#assert(size_of(SceNpDrmLicense) == 0x200) + +ScePsmDrmLicense :: struct { + magic: [0x8]c.char, + unk1: sce.UInt32, + unk2: sce.UInt32, + account_id: sce.UInt64, + unk3: sce.UInt32, + unk4: sce.UInt32, + start_time: sce.UInt64, + expiration_time: sce.UInt64, + activation_checksum: [0x20]sce.UInt8, + content_id: [0x30]c.char, + unk5: [0x80]sce.UInt8, + unk6: [0x20]sce.UInt8, + key: [0x10]sce.UInt8, + signature: [0x1D0]sce.UInt8, + rsa_signature: [0x100]sce.UInt8, +} +#assert(size_of(ScePsmDrmLicense) == 0x400) + +/** Options for _sceNpDrmPackageDecrypt */ +_sceNpDrmPackageDecrypt_opt :: struct { + /** The offset in the encrypted data */ + offset: sce.Off, + + /** + * The identifier specified for _sceNpDrmPackageCheck but NOT ORed + * with (1 << 8) + */ + identifier: c.uint, +} +#assert(size_of(_sceNpDrmPackageDecrypt_opt) == 0x10) + + diff --git a/Paf/Paf.odin b/Paf/Paf.odin new file mode 100644 index 0000000..9382c58 --- /dev/null +++ b/Paf/Paf.odin @@ -0,0 +1,103 @@ +package paf + +import sce "../common" +import "core:c" + +foreign import paf "system:ScePaf_stub" + +@(link_prefix = "scePaf") +foreign paf { + + /** + * Update the current wave + * + * @param[in] index - The index from 0 to 0x1F within range. + * @param[in] update_interval - The update interval. 0.0f to it will change soon. 1.0f will slowly turn into an updated wave after 1 second, just like when you change it the normal way. + * + * @return 0 on success, <0 otherwise. + */ + GraphicsUpdateCurrentWave :: proc(index: sce.UInt32, update_interval: sce.Float32) -> c.int --- + + GetCurrentClockLocalTime :: proc(data: ^ScePafDateTime) -> c.int --- + + Sha1Init :: proc(_context: ^ScePafSha1Context) -> c.int --- + Sha1Update :: proc(_context: ^ScePafSha1Context, data: rawptr, length: sce.Size) -> c.int --- + Sha1Result :: proc(_context: ^ScePafSha1Context, dst: rawptr) -> c.int --- + + CreateHeap :: proc(_context: ^ScePafHeapContext, membase: rawptr, size: sce.Size, name: cstring, opt: ^ScePafHeapOpt) --- + DeleteHeap :: proc(_context: ^ScePafHeapContext) --- + + MallocWithContext :: proc(_context: ^ScePafHeapContext, len: sce.Size) -> rawptr --- + FreeWithContext :: proc(_context: ^ScePafHeapContext, ptr: rawptr) --- + + MallocAlignWithContext :: proc(_context: ^ScePafHeapContext, align: sce.UInt32, len: sce.Size) -> rawptr --- + ReallocWithContext :: proc(_context: ^ScePafHeapContext, ptr: rawptr, len: sce.Size) -> rawptr --- + + @(link_name = "sce_paf_malloc") + malloc :: proc(size: sce.Size) -> rawptr --- + @(link_name = "sce_paf_free") + free :: proc(ptr: rawptr) --- + + /** + * @brief Alloc memory with align + * + * @param[in] align The align size + * @param[in] length The alloc length + * + * @return memory pointer or NULL + */ + @(link_name = "sce_paf_memalign") + memalign :: proc(align: sce.Size, length: sce.Size) -> rawptr --- + + @(link_name = "sce_paf_memchr") + memchr :: proc(src: rawptr, ch: c.int, length: sce.Size) -> rawptr --- + @(link_name = "sce_paf_memcmp") + memcmp :: proc(s1: rawptr, s2: rawptr, n: sce.Size) -> c.int --- + + @(link_name = "sce_paf_memcpy") + memcpy :: proc(dst: rawptr, src: rawptr, len: sce.Size) -> rawptr --- + @(link_name = "sce_paf_memset") + memset :: proc(dst: rawptr, ch: c.int, len: sce.Size) -> rawptr --- + @(link_name = "sce_paf_memmove") + memmove :: proc(dst: rawptr, src: rawptr, len: sce.Size) -> rawptr --- + + @(link_name = "sce_paf_snprintf") + snprintf :: proc(dst: cstring, max: c.uint, fmt: cstring, #c_vararg args: ..any) -> c.int --- + @(link_name = "sce_paf_vsnprintf") + vsnprintf :: proc(dst: cstring, max: c.uint, fmt: cstring, arg: c.va_list) -> c.int --- + + @(link_name = "sce_paf_bcmp") + bcmp :: proc(ptr1: rawptr, ptr2: rawptr, num: sce.Size) -> c.int --- + @(link_name = "sce_paf_bcopy") + bcopy :: proc(dst: rawptr, src: rawptr, n: sce.Size) -> rawptr --- + @(link_name = "sce_paf_bzero") + bzero :: proc(dst: rawptr, n: sce.Size) -> rawptr --- + + @(link_name = "sce_paf_strchr") + strchr :: proc(s: cstring, ch: c.int) -> ^c.char --- + @(link_name = "sce_paf_strcmp") + strcmp :: proc(s1: cstring, s2: cstring) -> c.int --- + @(link_name = "sce_paf_strlen") + strlen :: proc(s: cstring) -> c.size_t --- + @(link_name = "sce_paf_strcasecmp") + strcasecmp :: proc(s1: cstring, s2: cstring) -> c.int --- + @(link_name = "sce_paf_strncasecmp") + strncasecmp :: proc(s1: cstring, s2: cstring, len: sce.Size) -> c.int --- + @(link_name = "sce_paf_strncmp") + strncmp :: proc(s1: cstring, s2: cstring, len: sce.Size) -> c.int --- + @(link_name = "sce_paf_strncpy") + strncpy :: proc(dst: cstring, src: cstring, len: sce.Size) -> cstring --- + @(link_name = "sce_paf_strrchr") + strrchr :: proc(s: cstring, ch: c.int) -> ^c.char --- + + /** + * @brief string to double + * + * @param[in] nptr The input float string + * @param[out] endptr The float string endpoint + * + * @return parsed value + */ + @(link_name = "sce_paf_strtod") + strtod :: proc(nptr: cstring, endptr: ^^c.char) -> c.double --- +} diff --git a/Paf/types.odin b/Paf/types.odin new file mode 100644 index 0000000..23ce02e --- /dev/null +++ b/Paf/types.odin @@ -0,0 +1,63 @@ +package paf + +import sce "../common" +import "core:c" + +scePafGraphicsCurrentWave :: sce.UInt32 + +ScePafDateTime :: struct { + data: sce.DateTime, + data_0x10: c.int, + data_0x14: c.int, +} +#assert(size_of(ScePafDateTime) == 0x18) + +ScePafSha1Context :: struct { + // size is 0x68 + h: [5]c.uint32_t, + unk: [0x54]c.char, +} +#assert(size_of(ScePafSha1Context) == 0x68) + +// TODO: copy-pasted from Kernel/types.odin. should be in common or something +SceKernelLwMutexWork :: struct { + data: [4]sce.Int64, +} +#assert(size_of(SceKernelLwMutexWork) == 0x20) + + +ScePafHeapContext :: struct { + // size is 0x60-bytes + vtable: rawptr, + heap: rawptr, + membase: rawptr, + size: sce.Size, + name: [0x20]c.char, + is_import_membase: sce.Char8, + is_skip_debug_msg: sce.Char8, + data_0x32: c.char, + data_0x33: c.char, // maybe unused. just for align. + data_0x34: c.int, // maybe unused. just for align. + lw_mtx: SceKernelLwMutexWork, + memblk_id: sce.UID, + + /* + * !1 : Game + * 1 : CDialog + */ + mode: sce.Int32, +} +when size_of(rawptr) == 4 { + #assert(size_of(ScePafHeapContext) == 0x60) +} + +ScePafHeapOpt :: struct { + // size is 0x14-bytes + a1: c.int, + a2: c.int, + is_skip_debug_msg: sce.Char8, + a3: [3]c.char, + mode: sce.Int32, + a5: c.int, +} +#assert(size_of(ScePafHeapOpt) == 0x14) diff --git a/Pamgr/Pamgr.odin b/Pamgr/Pamgr.odin new file mode 100644 index 0000000..5e498bf --- /dev/null +++ b/Pamgr/Pamgr.odin @@ -0,0 +1,43 @@ +package pamgr + +import "core:c" +import sce "../common" + +foreign import pamgr "system:ScePamgr_stub" + +// missing structs +SceKernelPaTraceBufferParam :: struct{} +SceKernelPaGpuSampledData :: struct{} +SceKernelPaGpuTraceParam :: struct{} +SceKernelPaCounterTraceParam :: struct{} +SceKernelPaArmTraceParam :: struct{} + +foreign pamgr { + sceKernelPaGetTraceBufferSize :: proc(type: sce.UInt32) -> sce.Size --- + sceKernelPaGetIoBaseAddress :: proc() -> sce.UInt32 --- + sceKernelPaGetTimebaseFrequency :: proc() -> sce.UInt32 --- + sceKernelPaGetTraceBufferStatus :: proc() -> sce.UInt32 --- + sceKernelPaGetWritePointer :: proc() -> sce.UInt32 --- + sceKernelPaGetTimebaseValue :: proc() -> sce.UInt64 --- + _sceKernelPaAddArmTraceByKey :: proc(key: c.int, #by_ptr param: SceKernelPaArmTraceParam) -> c.int --- + _sceKernelPaAddCounterTraceByKey :: proc(key: c.int, #by_ptr param: SceKernelPaCounterTraceParam) -> c.int --- + _sceKernelPaAddGpuTraceByKey :: proc(key: c.int, #by_ptr param: SceKernelPaGpuTraceParam) -> c.int --- + _sceKernelPaGetGpuSampledData :: proc(data: ^SceKernelPaGpuSampledData) -> c.int --- + _sceKernelPaSetupTraceBufferByKey :: proc(key: c.int, #by_ptr param: SceKernelPaTraceBufferParam) -> c.int --- + sceKernelPaInsertBookmark :: proc(fifo: sce.UInt32, channel: sce.UInt32, data: sce.UInt32) -> c.int --- + sceKernelPaRegister :: proc() -> c.int --- + sceKernelPaRemoveArmTraceByKey :: proc(key: c.int) -> c.int --- + sceKernelPaRemoveCounterTraceByKey :: proc(key: c.int) -> c.int --- + sceKernelPaRemoveGpuTraceByKey :: proc(key: c.int) -> c.int --- + sceKernelPaSetBookmarkChannelEnableByKey :: proc(key: c.int, fifo: sce.UInt32, mask: sce.UInt32) -> c.int --- + sceKernelPaStartByKey :: proc(key: c.int) -> c.int --- + sceKernelPaStopByKey :: proc(key: c.int) -> c.int --- + sceKernelPaUnregister :: proc(key: c.int) -> c.int --- + sceKernelPerfArmPmonClose :: proc() -> c.int --- + sceKernelPerfArmPmonOpen :: proc() -> c.int --- + sceKernelPerfArmPmonReset :: proc(threadId: sce.UID) -> c.int --- + sceKernelPerfArmPmonSelectEvent :: proc(threadId: sce.UID, counter: sce.UInt32, eventCode: sce.UInt8) -> c.int --- + sceKernelPerfArmPmonSetCounterValue :: proc(threadId: sce.UID, counter: sce.UInt32, value: sce.UInt32) -> c.int --- + sceKernelPerfArmPmonStart :: proc(threadId: sce.UID) -> c.int --- + sceKernelPerfArmPmonStop :: proc(threadId: sce.UID) -> c.int --- +} diff --git a/Perf/Perf.odin b/Perf/Perf.odin new file mode 100644 index 0000000..200e6c4 --- /dev/null +++ b/Perf/Perf.odin @@ -0,0 +1,78 @@ +package perf + +import "core:c" +import sce "../common" + +foreign import perf "system:ScePerf_stub" + +SCE_PERF_ARM_PMON_THREAD_ID_SELF :: (sce.SCE_KERNEL_THREAD_ID_SELF) + +_ScePerfArmPmonEventCode :: enum c.int { + SOFT_INCREMENT = 0x00, + ICACHE_MISS = 0x01, + ITLB_MISS = 0x02, + DCACHE_MISS = 0x03, + DCACHE_ACCESS = 0x04, + DTLB_MISS = 0x05, + DATA_READ = 0x06, + DATA_WRITE = 0x07, + EXCEPTION_TAKEN = 0x09, + EXCEPTION_RETURN = 0x0A, + WRITE_CONTEXTID = 0x0B, + SOFT_CHANGEPC = 0x0C, + IMMEDIATE_BRANCH = 0x0D, + UNALIGNED = 0x0F, + BRANCH_MISPREDICT = 0x10, + CYCLE_COUNT = 0x11, + PREDICT_BRANCH = 0x12, + COHERENT_LF_MISS = 0x50, + COHERENT_LF_HIT = 0x51, + ICACHE_STALL = 0x60, + DCACHE_STALL = 0x61, + MAINTLB_STALL = 0x62, + STREX_PASSED = 0x63, + STREX_FAILED = 0x64, + DATA_EVICTION = 0x65, + ISSUE_NO_DISPATCH = 0x66, + ISSUE_EMPTY = 0x67, + INST_RENAME = 0x68, + PREDICT_FUNC_RET = 0x6E, + MAIN_PIPE = 0x70, + SECOND_PIPE = 0x71, + LS_PIPE = 0x72, + FPU_RENAME = 0x73, + NEON_RENAME = 0x74, + PLD_STALL = 0x80, + WRITE_STALL = 0x81, + INST_MAINTLB_STALL = 0x82, + DATA_MAINTLB_STALL = 0x83, + INST_UTLB_STALL = 0x84, + DATA_UTLB_STALL = 0x85, + DMB_STALL = 0x86, + INTEGER_CLOCK = 0x8A, + DATAENGINE_CLOCK = 0x8B, + ISB = 0x90, + DSB = 0x91, + DMB = 0x92, + EXT_INTERRUPT = 0x93, + PLE_LINE_REQ_COMPLETED = 0xA0, + PLE_CHANNEL_SKIPPED = 0xA1, + PLE_FIFO_FLUSH = 0xA2, + PLE_REQ_COMPLETED = 0xA3, + PLE_FIFO_OVERFLOW = 0xA4, + PLE_REQ_PROGRAMMED = 0xA5 +} + +@(link_prefix = "scePerf") +foreign perf { + ArmPmonReset :: proc(thid: sce.UID) -> c.int --- + ArmPmonSelectEvent :: proc(thid: sce.UID, counter: sce.UInt32, event_code: sce.UInt8) -> c.int --- + ArmPmonStart :: proc(thid: sce.UID) -> c.int --- + ArmPmonStop :: proc(thid: sce.UID) -> c.int --- + ArmPmonGetCounterValue :: proc(thid: sce.UID, counter: sce.UInt32, value: ^sce.UInt32) -> c.int --- + ArmPmonSetCounterValue :: proc(thid: sce.UID, counter: sce.UInt32, value: sce.UInt32) -> c.int --- + ArmPmonSoftwareIncrement :: proc(mask: sce.UInt32) -> c.int --- + + GetTimebaseValue :: proc() -> sce.UInt64 --- + GetTimebaseFrequency :: proc() -> sce.UInt32 --- +} diff --git a/Pgf/Pgf.odin b/Pgf/Pgf.odin new file mode 100644 index 0000000..51b5660 --- /dev/null +++ b/Pgf/Pgf.odin @@ -0,0 +1,33 @@ +package pgf + +import "core:c" +import sce "../common" + +foreign import pgf "system:ScePgf_stub" + +@(link_prefix = "sceFont") +foreign pgf { + NewLib :: proc(params: ^SceFontNewLibParams, errorCode: ^c.uint) -> SceFontLibHandle --- + DoneLib :: proc(libHandle: SceFontLibHandle) -> c.int --- + Open :: proc(libHandle: SceFontLibHandle, index: c.int, mode: c.int, errorCode: ^c.uint) -> SceFontHandle --- + OpenUserMemory :: proc(libHandle: SceFontLibHandle, pMemoryFont: rawptr, pMemoryFontSize: sce.Size, errorCode: ^c.uint) -> SceFontHandle --- + OpenUserFile :: proc(libHandle: SceFontLibHandle, file: cstring, mode: c.int, errorCode: ^c.uint) -> SceFontHandle --- + Close :: proc(fontHandle: SceFontHandle) -> c.int --- + GetNumFontList :: proc(libHandle: SceFontLibHandle, errorCode: ^c.uint) -> c.int --- + FindOptimumFont :: proc(libHandle: SceFontLibHandle, fontStyle: ^SceFontStyle, errorCode: ^c.uint) -> c.int --- + FindFont :: proc(libHandle: SceFontLibHandle, fontStyle: ^SceFontStyle, errorCode: ^c.uint) -> c.int --- + GetFontInfo :: proc(fontHandle: SceFontHandle, fontInfo: ^SceFontInfo) -> c.int --- + GetFontInfoByIndexNumber :: proc(libHandle: SceFontLibHandle, fontStyle: ^SceFontStyle, unknown: c.int, fontIndex: c.int) -> c.int --- + SetResolution :: proc(libHandle: SceFontLibHandle, hRes: c.float, vRes: c.float) -> c.int --- + GetFontList :: proc(libHandle: SceFontLibHandle, fontStyle: ^SceFontStyle, numFonts: c.int) -> c.int --- + GetCharInfo :: proc(fontHandle: SceFontHandle, charCode: c.uint, charInfo: ^SceFontCharInfo) -> c.int --- + GetCharImageRect :: proc(fontHandle: SceFontHandle, charCode: c.uint, charRect: ^SceFontImageRect) -> c.int --- + GetCharGlyphImage :: proc(fontHandle: SceFontHandle, charCode: c.uint, glyphImage: ^SceFontGlyphImage) -> c.int --- + GetCharGlyphImage_Clip :: proc(fontHandle: SceFontHandle, charCode: c.uint, glyphImage: ^SceFontGlyphImage, clipXPos: c.int, clipYPos: c.int, clipWidth: c.int, clipHeight: c.int) -> c.int --- + PixelToPointH :: proc(libHandle: SceFontLibHandle, fontPixelsH: c.float, errorCode: ^c.uint) -> c.float --- + PixelToPointV :: proc(libHandle: SceFontLibHandle, fontPixelsV: c.float, errorCode: ^c.uint) -> c.float --- + PointToPixelH :: proc(libHandle: SceFontLibHandle, fontPointsH: c.float, errorCode: ^c.uint) -> c.float --- + PointToPixelV :: proc(libHandle: SceFontLibHandle, fontPointsV: c.float, errorCode: ^c.uint) -> c.float --- + SetAltCharacterCode :: proc(libHandle: SceFontLibHandle, charCode: c.uint) -> c.int --- + Flush :: proc(fontHandle: SceFontHandle) -> c.int --- +} diff --git a/Pgf/types.odin b/Pgf/types.odin new file mode 100644 index 0000000..9311328 --- /dev/null +++ b/Pgf/types.odin @@ -0,0 +1,179 @@ +package pgf + +import "core:c" +import sce "../common" + +SceFontLibHandle :: rawptr +SceFontHandle :: rawptr + +/* struct */ + +// TODO: +SceFontErrorCode :: enum c.uint { + OUT_OF_MEMORY = 0x80460001, + INVALID_LIBID = 0x80460002, + INVALID_PARAMETER = 0x80460003, + HANDLER_OPEN_FAILED = 0x80460005, + TOO_MANY_OPEN_FONTS = 0x80460009, + INVALID_FONT_DATA = 0x8046000A, +} + +SceFontNewLibParams :: struct { + userData: rawptr, + numFonts: c.uint, + cacheData: rawptr, + + // Driver callbacks. + allocFunc: #type ^proc "c" (_: rawptr, __: c.uint) -> rawptr, + freeFunc: #type ^proc "c" (_: rawptr, __: rawptr), + openFunc: rawptr, + closeFunc: rawptr, + readFunc: rawptr, + seekFunc: rawptr, + errorFunc: rawptr, + ioFinishFunc: rawptr, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceFontNewLibParams) == 0x2C) +} + +SceFontFamilyCode :: enum c.int { + DEFAULT = 0, + SANS_SERIF = 1, + SERIF = 2, + ROUNDED = 3, +} + +SceFontStyleCode :: enum c.int { + DEFAULT = 0, + REGULAR = 1, + ITALIC = 2, + NARROW = 3, + NARROW_ITALIC = 4, + BOLD = 5, + BOLD_ITALIC = 6, + BLACK = 7, + BLACK_ITALIC = 8, + L = 101, + M = 102, + DB = 103, //!< Demi-Bold / semi-bold + B = 104, + EB = 105, + UB = 106, +} + +SceFontLanguageCode :: enum c.int { + DEFAULT = 0, + JAPANESE = 1, + LATIN = 2, + KOREAN = 3, + CHINESE = 4, + CJK = 5, +} + +SceFontPixelFormatCode :: enum c.int { + PIXELFORMAT_4 = 0, //!< 2 pixels packed in 1 byte (natural order) + PIXELFORMAT_4_REV = 1, //!< 2 pixels packed in 1 byte (reversed order) + PIXELFORMAT_8 = 2, //!< 1 pixel in 1 byte + PIXELFORMAT_24 = 3, //!< 1 pixel in 3 bytes (RGB) + PIXELFORMAT_32 = 4, //!< 1 pixel in 4 bytes (RGBA) +} + +SceFontImageRect :: struct { + width: c.ushort, + height: c.ushort, +} +#assert(size_of(SceFontImageRect) == 4) + +SceFontGlyphImage :: struct { + pixelFormat: c.uint, + xPos64: c.int, + yPos64: c.int, + bufWidth: c.ushort, + bufHeight: c.ushort, + bytesPerLine: c.ushort, + pad: c.ushort, + bufferPtr: c.uint, +} +#assert(size_of(SceFontGlyphImage) == 0x18) + +SceFontStyle :: struct { + fontH: c.float, + fontV: c.float, + fontHRes: c.float, + fontVRes: c.float, + fontWeight: c.float, + fontFamily: c.ushort, + fontStyle: c.ushort, + // Check. + fontStyleSub: c.ushort, + fontLanguage: c.ushort, + fontRegion: c.ushort, + fontCountry: c.ushort, + fontName: [64]c.char, + fontFileName: [64]c.char, + fontAttributes: c.uint, + fontExpire: c.uint, +} +#assert(size_of(SceFontStyle) == 0xA8) + +SceFontCharInfo :: struct { + bitmapWidth: c.uint, + bitmapHeight: c.uint, + bitmapLeft: c.uint, + bitmapTop: c.uint, + // Glyph metrics (in 26.6 signed fixed-point). + sfp26Width: c.uint, + sfp26Height: c.uint, + sfp26Ascender: c.int, + sfp26Descender: c.int, + sfp26BearingHX: c.int, + sfp26BearingHY: c.int, + sfp26BearingVX: c.int, + sfp26BearingVY: c.int, + sfp26AdvanceH: c.int, + sfp26AdvanceV: c.int, + shadowFlags: c.short, + shadowId: c.short, +} +#assert(size_of(SceFontCharInfo) == 0x3C) + +SceFontInfo :: struct { + // Glyph metrics (in 26.6 signed fixed-point). + maxGlyphWidthI: c.uint, + maxGlyphHeightI: c.uint, + maxGlyphAscenderI: c.uint, + maxGlyphDescenderI: c.uint, + maxGlyphLeftXI: c.uint, + maxGlyphBaseYI: c.uint, + minGlyphCenterXI: c.uint, + maxGlyphTopYI: c.uint, + maxGlyphAdvanceXI: c.uint, + maxGlyphAdvanceYI: c.uint, + + // Glyph metrics (replicated as float). + maxGlyphWidthF: c.float, + maxGlyphHeightF: c.float, + maxGlyphAscenderF: c.float, + maxGlyphDescenderF: c.float, + maxGlyphLeftXF: c.float, + maxGlyphBaseYF: c.float, + minGlyphCenterXF: c.float, + maxGlyphTopYF: c.float, + maxGlyphAdvanceXF: c.float, + maxGlyphAdvanceYF: c.float, + + // Bitmap dimensions. + maxGlyphWidth: c.short, + maxGlyphHeight: c.short, + charMapLength: c.uint, //!< Number of elements in the font's charmap. + shadowMapLength: c.uint, //!< Number of elements in the font's shadow charmap. + + // Font style (used by font comparison functions). + fontStyle: SceFontStyle, + + BPP: c.uint8_t, //!< Font's BPP. + pad: [3]c.uint8_t, +} +#assert(size_of(SceFontInfo) == 0x108) + diff --git a/PhotoExport/PhotoExport.odin b/PhotoExport/PhotoExport.odin new file mode 100644 index 0000000..4f5e801 --- /dev/null +++ b/PhotoExport/PhotoExport.odin @@ -0,0 +1,20 @@ +package photoexport + +import "core:c" +import sce "../common" + +PhotoExportParam :: struct { + version: c.int, //!< Version + photoTitle: [^]sce.WChar32, //!< Photo title + gameTitle: [^]sce.WChar32, //!< Game title + gameComment: [^]sce.WChar32, //!< Game description + reserved: [8]c.int, //!< Reserved data +} + +foreign import photoexport "system:ScePhotoExport_stub" + +@(link_prefix = "scePhotoExport") +foreign photoexport { + FromData :: proc(data: rawptr, size: sce.Size, #by_ptr param: PhotoExportParam, workingMemory: rawptr, cancelCb: rawptr, user: rawptr, outPath: cstring, outPathSize: sce.Size) -> c.int --- + FromFile :: proc(path: cstring, #by_ptr param: PhotoExportParam, workingMemory: rawptr, cancelCb: rawptr, user: rawptr, outPath: cstring, outPathSize: sce.Size) -> c.int --- +} diff --git a/Power/Power.odin b/Power/Power.odin new file mode 100644 index 0000000..05428aa --- /dev/null +++ b/Power/Power.odin @@ -0,0 +1,239 @@ +package power + +import "core:c" +import sce "../common" + +foreign import power "system:ScePower_stub" + +@(link_prefix = "scePower") +foreign power { + /** + * Registers a ScePower Callback + * + * @param cbid - The UID of the specified callback + * + * @return 0 on success, < 0 on error + */ + RegisterCallback :: proc(cbid: sce.UID) -> c.int --- + + /** + * Unregister a callback + * + * @param cbid - The UID of the specified callback + * + * @return 0 on success, < 0 on error + */ + UnregisterCallback :: proc(cbid: sce.UID) -> c.int --- + + /** + * Returns battery charging status + * + * @return SCE_TRUE if under charge, SCE_FALSE otherwise + */ + IsBatteryCharging :: proc() -> sce.Bool --- + + /** + * Returns battery life percentage + * + * @return Battery life percentage + */ + GetBatteryLifePercent :: proc() -> c.int --- + + /** + * Set power configuration mode between: + * + * Mode A - This is the normal mode at process start-up. The clock frequency of the GPU core is the "normal" clock frequency. The WLAN/COM can be used. + * Mode B - This mode accelerates the GPU clock frequency. The clock frequency of the GPU core is the "high" clock frequency. The WLAN/COM cannot be used. + * Mode C - This mode accelerates the GPU clock frequency, and also uses the WLAN/COM. The clock frequency of the GPU core is the "high" clock frequency, and use of the WLAN/COM is possible. The screen (touchscreen) brightness, however, is limited. Also, camera cannot be used. + * + * @param conf One of ::ScePowerConfigurationMode + * + * @return 0 on success + */ + SetConfigurationMode :: proc(conf: c.int) -> c.int --- + + /** + * Check if a suspend is required + * + * @return SCE_TRUE if suspend is required, SCE_FALSE otherwise + */ + IsSuspendRequired :: proc() -> sce.Bool --- + + /** + * Check if AC is plugged in + * + * @return SCE_TRUE if plugged in, SCE_FALSE otherwise + */ + IsPowerOnline :: proc() -> sce.Bool --- + + /** + * Returns battery life time + * + * @return Battery life time in minutes + */ + GetBatteryLifeTime :: proc() -> c.int --- + + /** + * Returns battery remaining capacity + * + * @return battery remaining capacity in mAh (milliampere hour) + */ + GetBatteryRemainCapacity :: proc() -> c.int --- + + /** + * Returns battery state + * + * @return SCE_TRUE if battery is low, SCE_FALSE otherwise + */ + IsLowBattery :: proc() -> sce.Bool --- + + /** + * Returns battery full capacity + * + * @return battery full capacity in mAh (milliampere hour) + */ + GetBatteryFullCapacity :: proc() -> c.int --- + + /** + * Returns battery temperature + * + * @return temperature in degrees celcius * 100 + */ + GetBatteryTemp :: proc() -> c.int --- + + /** + * Returns battery voltage + * + * @return battery voltage in mV (millivolts) + */ + GetBatteryVolt :: proc() -> c.int --- + + /** + * Returns battery state of health + * + * @return battery state of health percent + */ + GetBatterySOH :: proc() -> c.int --- + + /** + * Returns battery cycle count + * + * @return battery cycle count + */ + GetBatteryCycleCount :: proc() -> c.int --- + + /** + * Returns CPU clock frequency + * + * @return CPU clock frequency in Mhz + */ + GetArmClockFrequency :: proc() -> c.int --- + + /** + * Returns BUS clock frequency + * + * @return BUS clock frequency in Mhz + */ + GetBusClockFrequency :: proc() -> c.int --- + + /** + * Returns GPU clock frequency + * + * @return GPU clock frequency in Mhz + */ + GetGpuClockFrequency :: proc() -> c.int --- + + /** + * Returns GPU crossbar clock frequency + * + * @return GPU crossbar clock frequency in Mhz + */ + GetGpuXbarClockFrequency :: proc() -> c.int --- + + /** + * Requests PS Vita to do a cold reset + * + * @return always 0 + */ + RequestColdReset :: proc() -> c.int --- + + /** + * Requests PS Vita to go into standby + * + * @return always 0 + */ + RequestStandby :: proc() -> c.int --- + + /** + * Requests PS Vita to suspend + * + * @return always 0 + */ + RequestSuspend :: proc() -> c.int --- + + /** + * Request display on + * + * @return always 0 + */ + RequestDisplayOn :: proc() -> c.int --- + + /** + * Request display off + * + * @return always 0 + */ + RequestDisplayOff :: proc() -> c.int --- + + /** + * Sets CPU clock frequency + * + * @param freq - Frequency to set in Mhz + * + * @return 0 on success, < 0 on error + */ + SetArmClockFrequency :: proc(freq: c.int) -> c.int --- + + /** + * Sets BUS clock frequency + * + * @param freq - Frequency to set in Mhz + * + * @return 0 on success, < 0 on error + */ + SetBusClockFrequency :: proc(freq: c.int) -> c.int --- + + /** + * Sets GPU clock frequency + * + * @param freq - Frequency to set in Mhz + * + * @return 0 on success, < 0 on error + */ + SetGpuClockFrequency :: proc(freq: c.int) -> c.int --- + + /** + * Sets GPU crossbar clock frequency + * + * @param freq - Frequency to set in Mhz + * + * @return 0 on success, < 0 on error + */ + SetGpuXbarClockFrequency :: proc(freq: c.int) -> c.int --- + + /** + * Sets wireless features usage + * + * @param enabled - SCE_TRUE to enable, SCE_FALSE to disable + * + * @return 0 on success, < 0 on error + */ + SetUsingWireless :: proc(enabled: sce.Bool) -> c.int --- + + /** + * Gets wireless features usage + * + * @return SCE_TRUE if enabled, SCE_FALSE otherwise + */ + GetUsingWireless :: proc() -> c.int --- +} diff --git a/Power/types.odin b/Power/types.odin new file mode 100644 index 0000000..76c2a1b --- /dev/null +++ b/Power/types.odin @@ -0,0 +1,56 @@ +package power + +import "core:c" +import sce "../common" + +// TODO: +ScePowerErrorCode :: enum c.uint { + INVALID_VALUE = 0x802B0000, + ALREADY_REGISTERED = 0x802B0001, + CALLBACK_NOT_REGISTERED = 0x802B0002, + CANT_SUSPEND = 0x802B0003, + NO_BATTERY = 0x802B0100, + DETECTING = 0x802B0101 +} +#assert(size_of(ScePowerErrorCode) == 4) + +ScePowerCallbackType :: enum c.uint { + AFTER_SYSTEM_RESUME = 0x00000080, /* TODO: confirm */ + BATTERY_ONLINE = 0x00000100, + THERMAL_SUSPEND = 0x00000200, /* TODO: confirm */ + LOW_BATTERY_SUSPEND = 0x00000400, /* TODO: confirm */ + LOW_BATTERY = 0x00000800, + POWER_ONLINE = 0x00001000, + SYSTEM_SUSPEND = 0x00010000, + SYSTEM_RESUMING = 0x00020000, + SYSTEM_RESUME = 0x00040000, + UNK_0x100000 = 0x00100000, /* Related to proc_event::display_switch */ + APP_RESUME = 0x00200000, + APP_SUSPEND = 0x00400000, + APP_RESUMING = 0x00800000, /* TODO: confirm */ + BUTTON_PS_START_PRESS = 0x04000000, + BUTTON_PS_POWER_PRESS = 0x08000000, + BUTTON_PS_HOLD = 0x10000000, + BUTTON_PS_PRESS = 0x20000000, + BUTTON_POWER_HOLD = 0x40000000, + BUTTON_POWER_PRESS = 0x80000000, + VALID_MASK_KERNEL = 0xFCF71F80, + VALID_MASK_SYSTEM = 0xFCF71F80, + VALID_MASK_NON_SYSTEM = 0x00361180 +} +#assert(size_of(ScePowerCallbackType) == 4) + +/* GPU, WLAN/COM configuration setting */ +ScePowerConfigurationMode :: enum c.uint { + SCE_POWER_CONFIGURATION_MODE_A = 0x00000080, /* GPU clock normal, WLAN/COM enabled */ + SCE_POWER_CONFIGURATION_MODE_B = 0x00000800, /* GPU clock high, WLAN/COM disabled */ + SCE_POWER_CONFIGURATION_MODE_C = 0x00010880, /* GPU clock high, WLAN/COM enabled (drains battery faster) */ + __SCE_POWER_CONFIGURATION_MODE = 0xFFFFFFFF +} +#assert(size_of(ScePowerConfigurationMode) == 4) + +/* Callbacks */ + +/** Callback function prototype */ +ScePowerCallback :: #type ^proc "c" (notifyId: c.int, notifyCount: c.int, powerInfo: c.int, userData: rawptr) + diff --git a/PromoterUtil/PromoterUtil.odin b/PromoterUtil/PromoterUtil.odin new file mode 100644 index 0000000..707cfb7 --- /dev/null +++ b/PromoterUtil/PromoterUtil.odin @@ -0,0 +1,98 @@ +package promoterutil + +import "core:c" +import sce "../common" + +foreign import promoterutil "system:ScePromoterUtil_stub" + +@(link_prefix = "scePromoterUtility") +foreign promoterutil { + /** + * Init the promoter utility. + * \note Needs to be called before using the other functions. + * + * @return 0 on success. + */ + Init :: proc() -> c.int --- + + /** + * Deinit the promoter utility. + * + * @return 0 on success. + */ + Exit :: proc() -> c.int --- + + /** + * Delete a package from the LiveArea. + * + * @param[in] *titleid + * + * @return 0 on success. + */ + DeletePkg :: proc(titleid: cstring) -> c.int --- + + /** + * Update the LiveArea resources of an app + * + * @param[in] *args - see ::ScePromoterUtilityLAUpdate + * + * @return 0 on success. + */ + UpdateLiveArea :: proc(args: ^ScePromoterUtilityLAUpdate) -> c.int --- + + /** + * Install Content Manager import contents and create bubbles without checking license files. + * + * @param[in] *params - see ::ScePromoterUtilImportParams + * + * @return 0 on success. + */ + PromoteImport :: proc(params: ^ScePromoterUtilityImportParams) -> c.int --- + + /** + * Install a package from a directory, and add an icon on the LiveArea. + * + * @param[in] *path - the path of the directory where the extracted content of the package is + * @param sync - pass 0 for asynchronous, 1 for synchronous + * + * @return 0 on success. + */ + PromotePkg :: proc(path: cstring, sync: c.int) -> c.int --- + + /** + * Install a package from a directory and generate a rif. + * + * @param[in] *path - the path of the directory where the extracted content of the package is + * @param sync - pass 0 for asynchronous, 1 for synchronous + * + * @return 0 on success. + */ + PromotePkgWithRif :: proc(path: cstring, sync: c.int) -> c.int --- + + /** + * Returns the state of an operation. + * + * @param[out] *state - the current status, 0 when finished + * + * @return < 0 if failed. + */ + GetState :: proc(state: ^c.int) -> c.int --- + + /** + * Returns the result of a finished operation + * + * @param[out] *res - the result, 0 on success + * + * @return < 0 if failed. + */ + GetResult :: proc(res: ^c.int) -> c.int --- + + /** + * Check if titleid exists + * + * @param[out] *res - the result, unknown meaning + * + * @return 0 if exists, < 0 otherwise. + */ + CheckExist :: proc(titleid: cstring, res: ^c.int) -> c.int --- +} diff --git a/PromoterUtil/types.odin b/PromoterUtil/types.odin new file mode 100644 index 0000000..35243fa --- /dev/null +++ b/PromoterUtil/types.odin @@ -0,0 +1,29 @@ +package promoterutil + +import "core:c" +import sce "../common" + +/** Avalible types for ::ScePromoterUtilityImportParams **/ +ScePromoterUtilityPackageType :: enum c.int { + VITA = 0x0001, //!< PSVita Apps + PSP = 0x0001, //!< PSP Games + PSM = 0x0003, //!< PlayStation Mobile +} + +/** Parameters for scePromoterUtilityUpdateLiveArea() */ +ScePromoterUtilityLAUpdate :: struct { + titleid: [12]c.char, //!< Target app. + path: [128]c.char, //!< Directory of extracted LA update data. +} +#assert(size_of(ScePromoterUtilityLAUpdate) == 0x8C) + +/** Parameters for scePromoterUtilityPromoteImport() */ +ScePromoterUtilityImportParams :: struct { + path: [0x80]c.char, //!< Install path (ux0:/temp/game on PSM/PSV, ux0:/pspemu/temp/game on PSP) + titleid: [0xC]c.char, //!< Game titleid + type: ScePromoterUtilityPackageType, //!< Package type + attribute: c.uint32_t, //!< Additional Attributes (Appears to be 0x1 on PSM content but 0x00 on Vita contents) + reserved: [0x1C]c.char, +} +#assert(size_of(ScePromoterUtilityImportParams) == 0xB0) + diff --git a/PspnetAdhoc/PspnetAdhoc.odin b/PspnetAdhoc/PspnetAdhoc.odin new file mode 100644 index 0000000..733222c --- /dev/null +++ b/PspnetAdhoc/PspnetAdhoc.odin @@ -0,0 +1,43 @@ +package pspnetadhoc + +import "core:c" +import sce "../common" +import sceNet "../Net" + +foreign import pspnetadhoc "system:ScePspnetAdhoc_stub" + +@(link_prefix = "sceNetAdhoc") +foreign pspnetadhoc { + Init :: proc() -> c.int --- + Term :: proc() -> c.int --- + + PollSocket :: proc(sds: ^SceNetAdhocPollSd, nsds: c.int, timeout: c.uint, flag: c.int) -> c.int --- + SetSocketAlert :: proc(id: c.int, flag: c.int) -> c.int --- + GetSocketAlert :: proc(id: c.int, flag: ^c.int) -> c.int --- + + PdpCreate :: proc(#by_ptr saddr: sceNet.SceNetEtherAddr, sport: sce.UShort16, bufsize: c.uint, flag: c.int) -> c.int --- + PdpSend :: proc(id: c.int, #by_ptr daddr: sceNet.SceNetEtherAddr, dport: sce.UShort16, data: rawptr, len: c.int, timeout: c.uint, flag: c.int) -> c.int --- + PdpRecv :: proc(id: c.int, saddr: ^sceNet.SceNetEtherAddr, sport: ^sce.UShort16, buf: rawptr, len: ^c.int, timeout: c.uint, flag: c.int) -> c.int --- + PdpDelete :: proc(id: c.int, flag: c.int) -> c.int --- + GetPdpStat :: proc(buflen: ^c.int, buf: rawptr) -> c.int --- + + PtpOpen :: proc(#by_ptr saddr: sceNet.SceNetEtherAddr, sport: sce.UShort16, #by_ptr daddr: sceNet.SceNetEtherAddr, dport: sce.UShort16, bufsize: c.uint, rexmt_int: c.uint, rexmt_cnt: c.int, flag: c.int) -> c.int --- + PtpConnect :: proc(id: c.int, timeout: c.uint, flag: c.int) -> c.int --- + PtpListen :: proc(#by_ptr saddr: sceNet.SceNetEtherAddr, sport: sce.UShort16, bufsize: c.uint, rexmt_int: c.uint, rexmt_cnt: c.int, backlog: c.int, flag: c.int) -> c.int --- + PtpAccept :: proc(id: c.int, addr: ^sceNet.SceNetEtherAddr, port: ^sce.UShort16, timeout: c.uint, flag: c.int) -> c.int --- + PtpSend :: proc(id: c.int, data: rawptr, len: ^c.int, timeout: c.uint, flag: c.int) -> c.int --- + PtpRecv :: proc(id: c.int, buf: rawptr, len: ^c.int, timeout: c.uint, flag: c.int) -> c.int --- + PtpFlush :: proc(id: c.int, timeout: c.uint, flag: c.int) -> c.int --- + PtpClose :: proc(id: c.int, flag: c.int) -> c.int --- + GetPtpStat :: proc(buflen: ^c.int, buf: rawptr) -> c.int --- + + ctlInit :: proc(#by_ptr adhocId: SceNetAdhocctlAdhocId) -> c.int --- + ctlTerm :: proc() -> c.int --- + ctlGetAdhocId :: proc(adhocId: ^SceNetAdhocctlAdhocId) -> c.int --- + ctlGetPeerList :: proc(buflen: ^c.int, buf: rawptr) -> c.int --- + ctlGetPeerInfo :: proc(#by_ptr addr: sceNet.SceNetEtherAddr, size: c.int, peerInfo: ^SceNetAdhocctlPeerInfo) -> c.int --- + ctlGetAddrByName :: proc(#by_ptr nickname: SceNetAdhocctlNickname, buflen: ^c.int, buf: rawptr) -> c.int --- + ctlGetNameByAddr :: proc(#by_ptr addr: sceNet.SceNetEtherAddr, nickname: ^SceNetAdhocctlNickname) -> c.int --- + ctlGetParameter :: proc(parameter: ^SceNetAdhocctlParameter) -> c.int --- + ctlGetEtherAddr :: proc(addr: ^sceNet.SceNetEtherAddr) -> c.int --- +} diff --git a/PspnetAdhoc/types.odin b/PspnetAdhoc/types.odin new file mode 100644 index 0000000..dd243f9 --- /dev/null +++ b/PspnetAdhoc/types.odin @@ -0,0 +1,163 @@ +package pspnetadhoc + +import "core:c" +import sce "../common" +import sceNet "../Net" + +SCE_NET_ADHOC_PDP_MFS :: 1444 +SCE_NET_ADHOC_PDP_MTU :: 65523 +SCE_NET_ADHOC_PTP_MSS :: 1444 +SCE_NET_ADHOCCTL_ADHOCID_LEN :: 9 +SCE_NET_ADHOCCTL_GROUPNAME_LEN :: 8 +SCE_NET_ADHOCCTL_NICKNAME_LEN :: 128 +SCE_NET_ADHOCCTL_BSSID_LEN :: 6 + +// TODO: +ScePspnetAdhocErrorCode :: enum c.uint { + INVALID_SOCKET_ID = 0x80410701, + INVALID_ADDR = 0x80410702, + INVALID_PORT = 0x80410703, + INVALID_BUFLEN = 0x80410704, + INVALID_DATALEN = 0x80410705, + NOT_ENOUGH_SPACE = 0x80410706, + SOCKET_DELETED = 0x80410707, + SOCKET_ALERTED = 0x80410708, + WOULD_BLOCK = 0x80410709, + PORT_IN_USE = 0x8041070A, + NOT_CONNECTED = 0x8041070B, + DISCONNECTED = 0x8041070C, + NOT_OPENED = 0x8041070D, + NOT_LISTENED = 0x8041070E, + SOCKET_ID_NOT_AVAIL = 0x8041070F, + PORT_NOT_AVAIL = 0x80410710, + INVALID_ARG = 0x80410711, + NOT_INITIALIZED = 0x80410712, + ALREADY_INITIALIZED = 0x80410713, + BUSY = 0x80410714, + TIMEOUT = 0x80410715, + NO_ENTRY = 0x80410716, + EXCEPTION_EVENT = 0x80410717, + CONNECTION_REFUSED = 0x80410718, + THREAD_ABORTED = 0x80410719, + ALREADY_CREATED = 0x8041071A, + NOT_IN_GAMEMODE = 0x8041071B, + NOT_CREATED = 0x8041071C, + INVALID_ALIGNMENT = 0x8041071D, +} + +SceNetAdhocPollSd :: struct { + id: c.int, + events: c.int, + revents: c.int, +} +#assert(size_of(SceNetAdhocPollSd) == 0xC) + +ScePspnetAdhocEvent :: enum c.int { + SEND = 0x0001, + RECV = 0x0002, + CONNECT = 0x0004, + ACCEPT = 0x0008, + FLUSH = 0x0010, + INVALID = 0x0100, + DELETE = 0x0200, + ALERT = 0x0400, + DISCONNECT = 0x0800, +} + +SceNetAdhocPdpStat :: struct { + next: ^SceNetAdhocPdpStat, + id: c.int, + laddr: sceNet.SceNetEtherAddr, + lport: sce.UShort16, + rcv_sb_cc: c.uint, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetAdhocPdpStat) == 0x14) +} + +ScePspnetAdhocPtpState :: enum c.int { + CLOSED = 0, + LISTEN = 1, + SYN_SENT = 2, + SYN_RCVD = 3, + ESTABLISHED = 4, +} + +SceNetAdhocPtpStat :: struct { + next: ^SceNetAdhocPtpStat, + id: c.int, + laddr: sceNet.SceNetEtherAddr, + paddr: sceNet.SceNetEtherAddr, + lport: sce.UShort16, + pport: sce.UShort16, + snd_sb_cc: c.uint, + rcv_sb_cc: c.uint, + state: c.int, +} + +ScePspnetAdhocFlags :: enum c.int { + NONBLOCK = 0x0001, + ALERTSEND = 0x0010, + ALERTRECV = 0x0020, + ALERTPOLL = 0x0040, + ALERTCONNECT = 0x0080, + ALERTACCEPT = 0x0100, + ALERTFLUSH = 0x0200, + ALERTALL = ALERTSEND | ALERTRECV | ALERTPOLL | ALERTCONNECT | ALERTACCEPT | ALERTFLUSH, +} + +// TODO: +ScePspnetAdhocctlErrorCode :: enum c.uint { + INVALID_ARG = 0x80410B04, + ALREADY_INITIALIZED = 0x80410B07, + NOT_INITIALIZED = 0x80410B08, +} + +ScePspnetAdhocctlAdhocType :: enum c.int { + PRODUCT_ID = 0, + RESERVED = 1, + SYSTEM = 2 +} + +SceNetAdhocctlAdhocId :: struct { + type: c.int, + data: [SCE_NET_ADHOCCTL_ADHOCID_LEN]sce.Char8, + padding: [3]sce.UChar8, +} +#assert(size_of(SceNetAdhocctlAdhocId) == 0x10) + +SceNetAdhocctlGroupName :: struct { + data: [SCE_NET_ADHOCCTL_GROUPNAME_LEN]sce.Char8, +} +#assert(size_of(SceNetAdhocctlGroupName) == 8) + +SceNetAdhocctlNickname :: struct { + data: [SCE_NET_ADHOCCTL_NICKNAME_LEN]sce.Char8, +} +#assert(size_of(SceNetAdhocctlNickname) == 0x80) + +SceNetAdhocctlPeerInfo :: struct { + next: ^SceNetAdhocctlPeerInfo, + nickname: SceNetAdhocctlNickname, + macAddr: sceNet.SceNetEtherAddr, + padding: [6]sce.UChar8, + lastRecv: sce.UInt64, +} +when size_of(rawptr) == 4 { + #assert(size_of(SceNetAdhocctlPeerInfo) == 0x98) +} + +SceNetAdhocctlBSSId :: struct { + data: [SCE_NET_ADHOCCTL_BSSID_LEN]sce.UChar8, + padding: [2]sce.UChar8, +} +#assert(size_of(SceNetAdhocctlBSSId) == 8) + +SceNetAdhocctlParameter :: struct { + channel: c.int, + groupName: SceNetAdhocctlGroupName, + nickname: SceNetAdhocctlNickname, + bssid: SceNetAdhocctlBSSId, +} +#assert(size_of(SceNetAdhocctlParameter) == 0x94) + diff --git a/Pvf/Pvf.odin b/Pvf/Pvf.odin new file mode 100644 index 0000000..a397af1 --- /dev/null +++ b/Pvf/Pvf.odin @@ -0,0 +1,45 @@ +package pvf + +import "core:c" +import sce "../common" + +foreign import pvf "system:ScePvf_stub" + +GetCharGlyphImageClip :: GetCharGlyphImage_Clip + +@(link_prefix = "scePvf") +foreign pvf { + NewLib :: proc(initParam: ^ScePvfInitRec, errorCode: ScePvfError) -> ScePvfLibId --- + DoneLib :: proc(libID: ScePvfLibId) -> ScePvfError --- + SetEM :: proc(libID: ScePvfLibId, emValue: ScePvfFloat32) -> ScePvfError --- + SetResolution :: proc(libID: ScePvfLibId, hResolution: ScePvfFloat32, vResolution: ScePvfFloat32) -> ScePvfError --- + GetNumFontList :: proc(libID: ScePvfLibId, errorCode: ScePvfError) -> ScePvfInt --- + GetFontList :: proc(libID: ScePvfLibId, fontStyleInfo: ^ScePvfFontStyleInfo, arraySize: ScePvfInt) -> ScePvfError --- + FindOptimumFont :: proc(libID: ScePvfLibId, fontStyleInfo: ^ScePvfFontStyleInfo, errorCode: ScePvfError) -> ScePvfFontIndex --- + FindFont :: proc(libID: ScePvfLibId, fontStyleInfo: ^ScePvfFontStyleInfo, errorCode: ScePvfError) -> ScePvfFontIndex --- + GetFontInfoByIndexNumber :: proc(libID: ScePvfLibId, fontStyleInfo: ^ScePvfFontStyleInfo, fontIndex: ScePvfFontIndex) -> ScePvfError --- + Open :: proc(libID: ScePvfLibId, fontIndex: ScePvfFontIndex, mode: ScePvfU32, errorCode: ScePvfError) -> ScePvfFontId --- + OpenUserFile :: proc(libID: ScePvfLibId, filename: ScePvfPointer, mode: ScePvfU32, errorCode: ScePvfError) -> ScePvfFontId --- + OpenUserFileWithSubfontIndex :: proc(libID: ScePvfLibId, filename: ScePvfPointer, mode: ScePvfU32, subFontIndex: ScePvfU32, errorCode: ScePvfError) -> ScePvfFontId --- + OpenUserMemory :: proc(libID: ScePvfLibId, addr: ScePvfPointer, size: ScePvfU32, errorCode: ScePvfError) -> ScePvfFontId --- + OpenUserMemoryWithSubfontIndex :: proc(libID: ScePvfLibId, addr: ScePvfPointer, size: ScePvfU32, subFontIndex: ScePvfU32, errorCode: ScePvfError) -> ScePvfFontId --- + OpenDefaultJapaneseFontOnSharedMemory :: proc(libID: ScePvfLibId, errorCode: ScePvfError) -> ScePvfFontId --- + OpenDefaultLatinFontOnSharedMemory :: proc(libID: ScePvfLibId, errorCode: ScePvfError) -> ScePvfFontId --- + Close :: proc(fontID: ScePvfFontId) -> ScePvfError --- + Flush :: proc(fontID: ScePvfFontId) -> ScePvfError --- + SetCharSize :: proc(fontID: ScePvfFontId, hSize: ScePvfFloat32, vSize: ScePvfFloat32) -> ScePvfError --- + SetEmboldenRate :: proc(fontID: ScePvfFontId, emboldenRate: ScePvfFloat32) -> ScePvfError --- + SetSkewValue :: proc(fontID: ScePvfFontId, angleX: ScePvfFloat32, angleY: ScePvfFloat32) -> ScePvfError --- + IsElement :: proc(fontID: ScePvfFontId, charCode: ScePvfCharCode) -> ScePvfBool --- + GetFontInfo :: proc(fontID: ScePvfFontId, fontInfo: ^ScePvfFontInfo) -> ScePvfError --- + GetCharInfo :: proc(fontID: ScePvfFontId, charCode: ScePvfCharCode, charInfo: ^ScePvfCharInfo) -> ScePvfError --- + GetKerningInfo :: proc(fontID: ScePvfFontId, leftCharCode: ScePvfCharCode, rightCharCode: ScePvfCharCode, pKerningInfo: ^ScePvfKerningInfo) -> ScePvfError --- + GetCharImageRect :: proc(fontID: ScePvfFontId, charCode: ScePvfCharCode, rect: ^ScePvfIrect) -> ScePvfError --- + GetCharGlyphImage :: proc(fontID: ScePvfFontId, charCode: ScePvfCharCode, imageBuffer: ^ScePvfUserImageBufferRec) -> ScePvfError --- + GetCharGlyphImage_Clip :: proc(fontID: ScePvfFontId, charCode: ScePvfCharCode, imageBuffer: ^ScePvfUserImageBufferRec, clipX: ScePvfS32, clipY: ScePvfS32, clipWidth: ScePvfU32, clipHeight: ScePvfU32) -> ScePvfError --- + PixelToPointH :: proc(libID: ScePvfLibId, pixel: ScePvfFloat32, errorCode: ScePvfError) -> ScePvfFloat32 --- + PixelToPointV :: proc(libID: ScePvfLibId, pixel: ScePvfFloat32, errorCode: ScePvfError) -> ScePvfFloat32 --- + PointToPixelH :: proc(libID: ScePvfLibId, point: ScePvfFloat32, errorCode: ScePvfError) -> ScePvfFloat32 --- + PointToPixelV :: proc(libID: ScePvfLibId, point: ScePvfFloat32, errorCode: ScePvfError) -> ScePvfFloat32 --- + SetAltCharacterCode :: proc(libID: ScePvfLibId, charCode: ScePvfCharCode) -> ScePvfError --- +} diff --git a/Pvf/types.odin b/Pvf/types.odin new file mode 100644 index 0000000..ca54aad --- /dev/null +++ b/Pvf/types.odin @@ -0,0 +1,305 @@ +package pvf + +import "core:c" + +SCE_PVF_MAX_OPEN :: 18 + +SCE_PVF_FONTNAME_LENGTH :: 64 +SCE_PVF_STYLENAME_LENGTH :: 64 +SCE_PVF_FONTFILENAME_LENGTH :: 64 + +SCE_PVF_MIN_EMBOLDEN_RATE :: -20.0 +SCE_PVF_MAX_EMBOLDEN_RATE :: 40.0 +SCE_PVF_MIN_SKEW_VALUE :: -30.0 +SCE_PVF_MAX_SKEW_VALUE :: 30.0 + +ScePvfErrorCode :: enum c.uint { + NOMEMORY = 0x80460001, + LIBID = 0x80460002, + ARG = 0x80460003, + NOFILE = 0x80460004, + FILEOPEN = 0x80460005, + FILECLOSE = 0x80460006, + FILEREAD = 0x80460007, + FILESEEK = 0x80460008, + TOOMANYOPENED = 0x80460009, + ILLEGALVERSION = 0x8046000A, + DATAINCONSISTENT = 0x8046000B, + EXPIRED = 0x8046000C, + NOSUPPORT = 0x8046000E, + NOGLYPH = 0x8046000F, + UNKNOWN = 0x8046FFFF +} + +ScePvfFamilyCode :: enum c.int { + DEFAULT_FAMILY_CODE = 0, + FAMILY_SANSERIF = 1, + FAMILY_SERIF = 2, + FAMILY_ROUNDED = 3 +} + +ScePvfStyleCode :: enum c.int { + DEFAULT_STYLE_CODE = 0, + STYLE_REGULAR = 1, + STYLE_OBLIQUE = 2, + STYLE_NARROW = 3, + STYLE_NARROW_OBLIQUE = 4, + STYLE_BOLD = 5, + STYLE_BOLD_OBLIQUE = 6, + STYLE_BLACK = 7, + STYLE_BLACK_OBLIQUE = 8, + STYLE_L = 101, + STYLE_M = 102, + STYLE_DB = 103, + STYLE_B = 104, + STYLE_EB = 105, + STYLE_UB = 106 +} + +ScePvfImageByfferPixelFormatType :: enum c.int { + USERIMAGE_DIRECT4_L = 0, + USERIMAGE_DIRECT8 = 2 +} + +ScePvfLanguageCode :: enum c.int { + DEFAULT_LANGUAGE_CODE = 0, + LANGUAGE_J = 1, + LANGUAGE_LATIN = 2, + LANGUAGE_K = 3, + LANGUAGE_C = 4, + LANGUAGE_CJK = 5 +} + +ScePvfRegionCode :: enum c.int { + GENERIC_REGION_CODE = 0, + REGION_001 = 1, + REGION_002 = 2, + REGION_003 = 3, + REGION_004 = 4, + REGION_005 = 5, + REGION_006 = 6, + REGION_007 = 7 +} + +ScePvfFontVendorCountryCode :: enum c.int { + GENERIC_COUNTRY_CODE = 0, + COUNTRY_JAPAN = 1, + COUNTRY_USA = 2, + COUNTRY_KOREA = 3 +} + +ScePvfBoolValue :: enum c.int { + FALSE = 0, + TRUE = 1 +} + +ScePvfSubstyle :: enum c.int { + VERTICALLAYOUT = 0x0001, + PSEUDO_BOLD = 0x0002, + PSEUDO_SLANT = 0x0004 +} + +ScePvfDataAccessMode :: enum c.int { + FILEBASEDSTREAM = 0, + MEMORYBASEDSTREAM = 1 +} + +ScePvfU32 :: c.uint +ScePvfS32 :: c.int +ScePvfU16 :: c.ushort +ScePvfU8 :: c.uchar +ScePvfFloat32 :: c.float +ScePvfBool :: ScePvfU32 +ScePvfLibId :: rawptr +ScePvfFontId :: rawptr +ScePvfPointer :: rawptr +ScePvfHandle :: rawptr +ScePvfError :: ScePvfS32 +ScePvfInt :: ScePvfS32 +ScePvfCharCode :: ScePvfU16 +ScePvfFontIndex :: ScePvfS32 + +ScePvfIrect :: struct { + width: ScePvfU16, + height: ScePvfU16, +} +#assert(size_of(ScePvfIrect) == 4) + +ScePvfRect :: struct { + width: ScePvfU32, + height: ScePvfU32, +} +#assert(size_of(ScePvfRect) == 8) + +ScePvfFontCacheLockFunc :: #type ^proc "c" (cacheInstance: ScePvfPointer) -> ScePvfS32 + +ScePvfFontChcheUnlockFunc :: #type ^proc "c" (cacheInstance: ScePvfPointer) -> ScePvfS32 + +ScePvfFontChcheFindFunc :: #type ^proc "c" ( + chcheInstance: ScePvfPointer, + hashValue: ScePvfU32, + key: ScePvfPointer, + result: ^ScePvfBool) -> ScePvfPointer + +ScePvfFontChcheWriteKeyValueToCacheFunc :: #type ^proc "c" ( + cacheInstance: ScePvfPointer, + chcheSlot: ScePvfPointer, + key: ScePvfPointer) -> ScePvfS32 + +ScePvfFontChcheWriteToCacheFunc :: #type ^proc "c" ( + cacheInstance: ScePvfPointer, + cacheSlot: ScePvfPointer, + data0: ScePvfPointer, + size: ScePvfInt) -> ScePvfS32 + +ScePvfFontChcheReadFromCacheFunc :: #type ^proc "c" ( + cacheInstance: ScePvfPointer, + cacheSlot: ScePvfPointer, + data0: ScePvfPointer) -> ScePvfS32 + +ScePvfCacheSystemInterface :: struct { + cacheInstance: ^ScePvfPointer, + lockFunc: ScePvfFontCacheLockFunc, + unlockFunc: ScePvfFontChcheUnlockFunc, + findFunc: ScePvfFontChcheFindFunc, + writeKeyValueToCacheFunc: ScePvfFontChcheWriteKeyValueToCacheFunc, + write0ToCacheFunc: ScePvfFontChcheWriteToCacheFunc, + write1ToCacheFunc: ScePvfFontChcheWriteToCacheFunc, + read0FromCacheFunc: ScePvfFontChcheReadFromCacheFunc, + read1FromCacheFunc: ScePvfFontChcheReadFromCacheFunc, +} +when size_of(rawptr) == 4 { + #assert(size_of(ScePvfCacheSystemInterface) == 0x24) +} + +ScePvfAllocFunc :: #type ^proc "c" (userData: ScePvfPointer, size: ScePvfU32) -> ScePvfPointer + +ScePvfReallocFunc :: #type ^proc "c" ( + userData: ScePvfPointer, + old_ptr: ScePvfPointer, + size: ScePvfU32) -> ScePvfPointer + +ScePvfFreeFunc :: #type ^proc "c" (userData: ScePvfPointer, ptr: ScePvfPointer) + +ScePvfInitRec :: struct { + userData: ScePvfPointer, + maxNumFonts: ScePvfU32, + cache: ^ScePvfCacheSystemInterface, + reserved: ScePvfPointer, + allocFunc: ScePvfAllocFunc, + reallocFunc: ScePvfReallocFunc, + freeFunc: ScePvfFreeFunc, +} +when size_of(rawptr) == 4 { + #assert(size_of(ScePvfInitRec) == 0x1C) +} + +ScePvfFontStyleInfo :: struct { + weight: ScePvfFloat32, + familyCode: ScePvfU16, + style: ScePvfU16, + subStyle: ScePvfU16, // c.int --- + + /** + * Sets the buffer in which to store gpu live debugging results for the current frame + * + * @param[in] buffer - The buffer to use + * @param[in] buf_size - The buffer size in bytes + * @param[out] results - The debugging results of the previous frame + * + * @return 0, <0 on error. + */ + SetBuffer :: proc(buffer: rawptr, buf_size: sce.Size, results: ^SceRazorGpuLiveResultInfo) -> c.int --- + + /** + * Starts gpu live debugging + * + * @return 0, <0 on error. + */ + Start :: proc() -> c.int --- + + /** + * Stops gpu live debugging + * + * @return 0, <0 on error. + */ + Stop :: proc() -> c.int --- +} diff --git a/RazorHud/types.odin b/RazorHud/types.odin new file mode 100644 index 0000000..d1388c4 --- /dev/null +++ b/RazorHud/types.odin @@ -0,0 +1,132 @@ +package razorhud + +import "core:c" +import sce "../common" + +/** Enumeration for the gpu live metrics groups */ +SceRazorGpuLiveMetricsGroup :: enum c.int { + PBUFFER_USAGE, + OVERVIEW_1, + OVERVIEW_2, + OVERVIEW_3 +} + +/** Enumeration for the gpu live results entry types */ +SceRazorLiveTraceMetricEntryType :: enum c.int { + JOB, + PARAMETER_BUFFER, + FRAME +} + +/** Enumeration for the gpu live results job types */ +SceRazorLiveTraceMetricJobType :: enum c.int { + FIRMWARE, + VERTEX1, + FRAGMENT1, + VERTEX2, + FRAGMENT2, + VERTEX3, + FRAGMENT3, + VERTEX0, + FRAGMENT0 +} + +SceRazorGpuLiveResultInfo :: struct { + result_data: rawptr, //!< Pointer to the raw data results entries. + entry_count: sce.Size, //!< Number of elements stored in the results buffer + overflow_count: sce.Size, //|< Number of results elements not included in the results buffer due to buffer overflow + buffer_size: sce.Size, //!< Size of the results buffer in bytes + start_time: c.uint64_t, //!< Start time of the results collection in microseconds + end_time: c.uint64_t, //!< End time of the results collection in microseconds + metric_group: c.uint32_t, //!< Metrics group used for the results + reserved: c.int, //!< Reserved data +} + +SceRazorGpuLiveEntryHeader :: struct { + entry_size: c.uint16_t, //!< Entry size in bytes + entry_type: c.uint16_t, //!< Entry type (One of ::SceRazorLiveTraceMetricEntryType) + reserved: c.int, //!< Reserved data +} +#assert(size_of(SceRazorGpuLiveEntryHeader) == 8) + +SceRazorGpuLiveEntryJobVertexValues1 :: struct { + usse_vertex_processing_percent: c.float, //!< USSE vertex processing percentage +} +#assert(size_of(SceRazorGpuLiveEntryJobVertexValues1) == 4) + +SceRazorGpuLiveEntryJobFragmentValues1 :: struct { + usse_fragment_processing_percent: c.float, //!< USSE fragment processing percentage + usse_dependent_texture_reads_percent: c.float, //!< USSE dependant texture reads requests percentage + usse_non_dependent_texture_reads_percent: c.float, //!< USSE non-dependant texture reads requests percentage +} +#assert(size_of(SceRazorGpuLiveEntryJobFragmentValues1) == 0xC) + +SceRazorGpuLiveEntryJobVertexValues2 :: struct { + vdm_primitives_input_num: c.uint32_t, //!< VDM input primitives number + mte_primitives_output_num: c.uint32_t, //!< MTE output primitives number + vdm_vertices_input_num: c.uint32_t, //!< VDM input vertices number + mte_vertices_output_num: c.uint32_t, //!< MTE output vertices number +} +#assert(size_of(SceRazorGpuLiveEntryJobVertexValues2) == 0x10) + +SceRazorGpuLiveEntryJobFragmentValues2 :: struct { + rasterized_pixels_before_hsr_num: c.uint32_t, //!< Number of rasterized pixels before Hidden Surface Removal + rasterized_output_pixels_num: c.uint32_t, //!< Number of rasterized pixels + rasterized_output_samples_num: c.uint32_t, //!< Number of rasterized samples +} +#assert(size_of(SceRazorGpuLiveEntryJobFragmentValues2) == 0xC) + +SceRazorGpuLiveEntryJobVertexValues3 :: struct { + tiling_accelerated_mem_writes: c.uint32_t, //!< Amount of tiling accelerated memory writes in bytes +} +#assert(size_of(SceRazorGpuLiveEntryJobVertexValues3) == 4) + +SceRazorGpuLiveEntryJobFragmentValues3 :: struct { + isp_parameter_fetches_mem_reads: c.uint32_t, //!< Amount of ISP parameter fetches memory reads in bytes +} +#assert(size_of(SceRazorGpuLiveEntryJobFragmentValues3) == 4) + +SceRazorGpuLiveEntryJobValues :: struct { + vertex_values_type1: SceRazorGpuLiveEntryJobVertexValues1, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_VERTEX1 type + fragment_values_type1: SceRazorGpuLiveEntryJobFragmentValues1, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_FRAGMENT1 type + vertex_values_type2: SceRazorGpuLiveEntryJobVertexValues2, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_VERTEX2 type + fragment_values_type2: SceRazorGpuLiveEntryJobFragmentValues2, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_FRAGMENT2 type + vertex_values_type3: SceRazorGpuLiveEntryJobVertexValues3, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_VERTEX3 type + fragment_values_type3: SceRazorGpuLiveEntryJobFragmentValues3, //!< Values for a job of SCE_RAZOR_LIVE_TRACE_METRIC_JOB_TYPE_FRAGMENT3 type + reserved: [8]c.int, //!< Reserved data +} +#assert(size_of(SceRazorGpuLiveEntryJobValues) == 0x54) + +SceRazorGpuLiveEntryJob :: struct { + header: SceRazorGpuLiveEntryHeader, //!< Distinguishing header for the entry + start_time: c.uint64_t, //!< Start time of the entry in microseconds + end_time: c.uint64_t, //!< End time of the entry in microseconds + type: c.uint8_t, //!< The type of the job (One of ::SceRazorLiveTraceMetricJobType) + core: c.int8_t, //!< Core number on which the job got executed + scene_index: c.uint16_t, //!< Index of the scene in which the job got executed + frame_number: c.uint32_t, //!< Frame number in which the job got executed + job_values: SceRazorGpuLiveEntryJobValues, //!< Reported values by the job + process_id: c.uint32_t, //!< ID of the process which executed the job + unk: c.int, //!< Unknown data +} +#assert(size_of(SceRazorGpuLiveEntryJob) == 0x80) + +SceRazorGpuLiveEntryParameterBuffer :: struct { + header: SceRazorGpuLiveEntryHeader, //!< Distinguishing header for the entry + peak_usage_timestamp: c.uint64_t, //!< Time of param buffer peak usage in microseconds + peak_usage_value: c.uint32_t, //!< Memory peak usage of the param buffer in bytes + partial_render: c.uint8_t, //!< Flag indicating wether a partial render occurred or not + vertex_job_paused: c.uint8_t, //!< Flag indicating wether a vertex job had been paused or not +} +#assert(size_of(SceRazorGpuLiveEntryParameterBuffer) == 0x18) + +SceRazorGpuLiveEntryFrame :: struct { + header: SceRazorGpuLiveEntryHeader, //!< Distinguishing header for the entry + start_time: c.uint64_t, //!< Start time of the entry in microseconds + duration: c.uint32_t, //!< Duration of the frame in microseconds + frame_number: c.uint32_t, //!< Number of the frame + gpu_activity_duration_time: c.uint32_t, //!< Duration of GPU activity for the frame in microseconds + reserved: c.int, //!< Reserved data +} +#assert(size_of(SceRazorGpuLiveEntryFrame) == 0x20) + diff --git a/RegistryMgr/RegistryMgr.odin b/RegistryMgr/RegistryMgr.odin new file mode 100644 index 0000000..947c265 --- /dev/null +++ b/RegistryMgr/RegistryMgr.odin @@ -0,0 +1,143 @@ +package registrymgr + +import "core:c" + +foreign import registrymgr "system:SceRegistryMgr_stub" + +@(link_prefix = "sceRegMgr") +foreign registrymgr { + /** + * Get a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to a buffer to hold the value + * @param size - The size of the buffer + * + * @return 0 on success, < 0 on error + */ + GetKeyBin :: proc(category: cstring, name: cstring, buf: rawptr, size: c.int) -> c.int --- + + /** + * Get a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to a int buffer to hold the value + * + * @return 0 on success, < 0 on error + */ + GetKeyInt :: proc(category: cstring, name: cstring, buf: ^c.int) -> c.int --- + + /** + * Get a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to a char buffer to hold the value + * @param size - The size of the buffer + * + * @return 0 on success, < 0 on error + */ + GetKeyStr :: proc(category: cstring, name: cstring, buf: [^]c.char, size: c.int) -> c.int --- + + /** + * Set a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to a buffer to hold the value + * @param size - The size of the buffer + * + * @return 0 on success, < 0 on error + */ + SetKeyBin :: proc(category: cstring, name: cstring, buf: rawptr, size: c.int) -> c.int --- + + /** + * Set a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to an int buffer to hold the value + * + * @return 0 on success, < 0 on error + */ + SetKeyInt :: proc(category: cstring, name: cstring, buf: c.int) -> c.int --- + + /** + * Set a key's information by category and name + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param name - Name of the key + * @param buf - Pointer to a char buffer to hold the value + * @param size - The size of the buffer + * + * @return 0 on success, < 0 on error + */ + SetKeyStr :: proc(category: cstring, name: cstring, buf: [^]c.char, size: c.int) -> c.int --- + + /** + * Get all keys' initial information by category (from os0:kd/registry.db0) + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param buf[out] - Pointer to a char buffer to hold the values + * @param elements_number - The number of elements of the buffer + * + * @return 0 on success, < 0 on error + */ + GetInitVals :: proc(category: cstring, buf: [^]c.char, elements_number: c.int) -> c.int --- + + /** + * Get all keys' information by category + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param buf[out] - Pointer to a char buffer to hold the values + * @param elements_number - The number of elements of the buffer + * + * @return 0 on success, < 0 on error + */ + GetKeys :: proc(category: cstring, buf: [^]c.char, elements_number: c.int) -> c.int --- + + /** + * Set all keys' information by category + * + * @param category - The path to the directory to be opened (e.g. /CONFIG/SYSTEM) + * @param buf[out] - Pointer to a char buffer that holds the values + * @param elements_number - The number of elements of the buffer + * + * @return 0 on success, < 0 on error + */ + SetKeys :: proc(category: cstring, buf: [^]c.char, elements_number: c.int) -> c.int --- + + /** + * Get a system param key's information by id + * + * @param id - The id of the key + * @param buf[out] - Pointer to an int to hold the value + * + * @return 0 on success, < 0 on error + */ + SystemParamGetInt :: proc(id: c.int, buf: ^c.int) -> c.int --- + + /** + * Get a system param key's information by id + * + * @param id - The id of the key + * @param buf[out] - Pointer to a char buffer to hold the value + * @param size - The size of the buffer + * + * @return 0 on success, < 0 on error + */ + SystemParamGetStr :: proc(id: c.int, buf: [^]c.char, size: c.int) -> c.int --- + + + /** + * Get the registry version + * + * @param id - The id of the key + * @param buf[out] - Pointer to a char buffer to hold the value + * + * @return 0 on success, < 0 on error + */ + GetRegVersion :: proc(version: c.int, buf: [^]c.char) -> c.int --- +} diff --git a/Rtc/Rtc.odin b/Rtc/Rtc.odin new file mode 100644 index 0000000..88cb5ac --- /dev/null +++ b/Rtc/Rtc.odin @@ -0,0 +1,301 @@ +package rtc + +import "core:c" +import sce "../common" + +foreign import rtc "system:SceRtc_stub" + +/* Aliases */ +sceRtcGetCurrentTickUtc :: sceRtcGetCurrentTick +sceRtcGetCurrentClockUtc :: proc(_p: ^sce.DateTime) -> c.int { + return sceRtcGetCurrentClock(_p,0) +} +sceRtcGetCurrentNetworkTickUtc :: sceRtcGetCurrentNetworkTick +sceRtcConvertTime_tToDateTime :: sceRtcSetTime_t +sceRtcConvertTime64_tToDateTime :: sceRtcSetTime64_t +sceRtcConvertDateTimeToTime_t :: sceRtcGetTime_t +sceRtcConvertDateTimeToTime64_t :: sceRtcGetTime64_t +sceRtcConvertDosTimeToDateTime :: sceRtcSetDosTime +sceRtcConvertDateTimeToDosTime :: sceRtcGetDosTime +sceRtcConvertWin32TimeToDateTime :: sceRtcSetWin32FileTime +sceRtcConvertDateTimeToWin32Time :: sceRtcGetWin32FileTime +sceRtcConvertTickToDateTime :: sceRtcSetTick +sceRtcConvertDateTimeToTick :: sceRtcGetTick + +/* Inline SceDateTime Getters */ + +/** +* Get current year. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current year. +*/ +sceRtcGetYear :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.year +} + +/** +* Get current month. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current month. +*/ +sceRtcGetMonth :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.month +} + +/** +* Get current day. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current day. +*/ +sceRtcGetDay :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.day +} + +/** +* Get current hour. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current hour. +*/ +sceRtcGetHour :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.hour +} + +/** +* Get current minute. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current minute. +*/ +sceRtcGetMinute :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.minute +} + +/** +* Get current second. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current second. +*/ +sceRtcGetSecond :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return auto_cast time.second +} + +/** +* Get current microsecond. +* +* @param[in] time - see ::SceDateTime. +* +* @return Current microsecond. +*/ +sceRtcGetMicrosecond :: #force_inline proc "c" (#by_ptr time: sce.DateTime) -> c.int { + return cast(c.int)time.microsecond +} + +/* Inline SceDateTime Setters */ + +sceRtcSetYear :: #force_inline proc "c" (time: ^sce.DateTime, year: c.int) -> c.uint { + if (year<1 || year>9999) { + return auto_cast sce.RtcErrorCode.INVALID_YEAR + } + time.year = cast(c.ushort)year + return 0 +} + +sceRtcSetMonth :: #force_inline proc "c" (time: ^sce.DateTime, month: c.int) -> c.uint { + if (month<1 || month>12) { + return auto_cast sce.RtcErrorCode.INVALID_MONTH + } + time.month = cast(c.ushort)month + return 0 +} + +sceRtcSetDay :: #force_inline proc "c" (time: ^sce.DateTime, day: c.int) -> c.uint { + if (day<1 || day>31) { + return auto_cast sce.RtcErrorCode.INVALID_DAY + } + time.day = cast(c.ushort)day + return 0 +} + +sceRtcSetHour :: #force_inline proc "c" (time: ^sce.DateTime, hour: c.int) -> c.uint { + if (hour<0 || hour>23) { + return auto_cast sce.RtcErrorCode.INVALID_HOUR + } + time.hour = cast(c.ushort)hour + return 0 +} + +sceRtcSetMinute :: #force_inline proc "c" (time: ^sce.DateTime, minute: c.int) -> c.uint { + if (minute<0 || minute>59) { + return auto_cast sce.RtcErrorCode.INVALID_MINUTE + } + time.minute = cast(c.ushort)minute + return 0 +} + +sceRtcSetSecond :: #force_inline proc "c" (time: ^sce.DateTime, second: c.int) -> c.uint { + if (second<0 || second>59) { + return auto_cast sce.RtcErrorCode.INVALID_SECOND + } + time.second = cast(c.ushort)second + return 0 +} + +sceRtcSetMicrosecond :: #force_inline proc "c" (time: ^sce.DateTime, microsecond: c.int) -> c.uint { + if (microsecond<0 || microsecond>999999) { + return auto_cast sce.RtcErrorCode.INVALID_MICROSECOND + } + time.microsecond = cast(c.uint)microsecond + return 0 +} + +foreign rtc { + sceRtcGetTickResolution :: proc() -> c.uint --- + + sceRtcGetCurrentTick :: proc(tick: ^sce.RtcTick) -> c.int --- + + /** + * Get current real time clock time. + * + * @param[out] time - see ::SceDateTime. + * @param[in] time_zone - The time zone the return value will be. + * + * @return 0 on success, < 0 on error. + */ + sceRtcGetCurrentClock :: proc(time: ^sce.DateTime, time_zone: c.int) -> c.int --- + + /** + * Get current real time clock time with system time zone. + * + * @param[out] time - see ::SceDateTime. + * + * @return 0 on success, < 0 on error. + */ + sceRtcGetCurrentClockLocalTime :: proc(time: sce.DateTime) -> c.int --- + + sceRtcGetCurrentNetworkTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcConvertUtcToLocalTime :: proc(#by_ptr utc: sce.RtcTick, local_time: ^sce.RtcTick) -> c.int --- + sceRtcConvertLocalTimeToUtc :: proc(#by_ptr local_time: sce.RtcTick, utc: ^sce.RtcTick) -> c.int --- + sceRtcIsLeapYear :: proc(year: c.int) -> c.int --- + sceRtcCheckValid :: proc(#by_ptr time: sce.DateTime) -> c.int --- + sceRtcGetDaysInMonth :: proc(year: c.int, month: c.int) -> c.int --- + sceRtcGetDayOfWeek :: proc(year: c.int, month: c.int, day: c.int) -> c.int --- + + /* Win/POSIX compliant function */ + sceRtcSetTime_t :: proc(time: ^sce.DateTime, iTime: c.long) -> c.int --- + sceRtcSetTime64_t :: proc(time: ^sce.DateTime, ullTime: sce.UInt64) -> c.int --- + sceRtcGetTime_t :: proc(#by_ptr time: sce.DateTime, piTime: ^c.long) -> c.int --- + sceRtcGetTime64_t :: proc(#by_ptr time: sce.DateTime, pullTime: ^sce.UInt64) -> c.int --- + sceRtcSetDosTime :: proc(time: ^sce.DateTime, uiDosTime: c.uint) -> c.int --- + sceRtcGetDosTime :: proc(#by_ptr time: sce.DateTime, puiDosTime: ^c.uint) -> c.int --- + sceRtcSetWin32FileTime :: proc(time: ^sce.DateTime, ulWin32Time: sce.UInt64) -> c.int --- + sceRtcGetWin32FileTime :: proc(#by_ptr time: sce.DateTime, ulWin32Time: ^sce.UInt64) -> c.int --- + sceRtcSetTick :: proc(time: ^sce.DateTime, #by_ptr tick: sce.RtcTick) -> c.int --- + sceRtcGetTick :: proc(#by_ptr time: sce.DateTime, tick: ^sce.RtcTick) -> c.int --- + + /* Arithmetic function */ + sceRtcCompareTick :: proc(#by_ptr pTick1: sce.RtcTick, #by_ptr pTick2: sce.RtcTick) -> c.int --- + sceRtcTickAddTicks :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: sce.Long64) -> c.int --- + sceRtcTickAddMicroseconds :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: sce.Long64) -> c.int --- + sceRtcTickAddSeconds :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: sce.Long64) -> c.int --- + sceRtcTickAddMinutes :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: sce.Long64) -> c.int --- + sceRtcTickAddHours :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: c.int) -> c.int --- + sceRtcTickAddDays :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: c.int) -> c.int --- + sceRtcTickAddWeeks :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: c.int) -> c.int --- + sceRtcTickAddMonths :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: c.int) -> c.int --- + sceRtcTickAddYears :: proc(pTick0: ^sce.RtcTick, #by_ptr pTick1: sce.RtcTick, lAdd: c.int) -> c.int --- + + /* Formating function */ + sceRtcFormatRFC2822 :: proc(pszDateTime: [^]c.char, #by_ptr utc: sce.RtcTick, iTimeZoneMinutes: c.int) -> c.int --- + sceRtcFormatRFC2822LocalTime :: proc(pszDateTime: [^]c.char, #by_ptr utc: sce.RtcTick) -> c.int --- + sceRtcFormatRFC3339 :: proc(pszDateTime: [^]c.char, #by_ptr utc: sce.RtcTick, iTimeZoneMinutes: c.int) -> c.int --- + sceRtcFormatRFC3339LocalTime :: proc(pszDateTime: [^]c.char, #by_ptr utc: sce.RtcTick) -> c.int --- + sceRtcParseDateTime :: proc(utc: ^sce.RtcTick, pszDateTime: cstring) -> c.int --- + sceRtcParseRFC3339 :: proc(utc: ^sce.RtcTick, pszDateTime: cstring) -> c.int --- + + + + /** + * Convert localtime to UTC + * + * @param[in] localtime - The localtime buffer pointer + * @param[out] utc - The UTC buffer pointer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcConvertLocalTimeToUtc :: proc(#by_ptr localtime: sce.RtcTick, utc: ^sce.RtcTick) -> c.int --- + + /** + * Convert UTC to localtime + * + * @param[in] utc - The UTC buffer pointer + * @param[out] localtime - The localtime buffer pointer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcConvertUtcToLocalTime :: proc(#by_ptr utc: sce.RtcTick, localtime: ^sce.RtcTick) -> c.int --- + + /** + * Convert RFC2822 time string from UTC + * + * @param[out] datetime - The datetime string buffer + * @param[in] utc - The UTC time tick pointer + * @param[in] offset - A timezone offset. this value have to minute value + * @param[in] a4 - The Syscall validity buffer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcFormatRFC2822 :: proc(datetime: [^]c.char, #by_ptr utc: sce.RtcTick, offset: c.int, a4: ^sce.UInt64) -> c.int --- + + /** + * Convert RFC2822 time string from UTC with localtime + * + * @param[out] datetime - The datetime string buffer + * @param[in] utc - The UTC time tick pointer + * @param[in] a3 - The Syscall validity buffer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcFormatRFC2822LocalTime :: proc(datetime: [^]c.char, #by_ptr utc: sce.RtcTick, a3: ^sce.UInt64) -> c.int --- + + /** + * Convert RFC3339 time string from UTC + * + * @param[out] datetime - The datetime string buffer + * @param[in] utc - The UTC time tick pointer + * @param[in] offset - A timezone offset. this value have to minute value + * @param[in] a4 - The Syscall validity buffer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcFormatRFC3339 :: proc(datetime: [^]c.char, #by_ptr utc: sce.RtcTick, offset: c.int, a4: ^sce.UInt64) -> c.int --- + + /** + * Convert RFC3339 time string from UTC with localtime + * + * @param[out] datetime - The datetime string buffer + * @param[in] utc - The UTC time tick pointer + * @param[in] a3 - The Syscall validity buffer + * + * @return 0 on success, < 0 on error. + */ + _sceRtcFormatRFC3339LocalTime :: proc(datetime: [^]c.char, #by_ptr utc: sce.RtcTick, a3: ^sce.UInt64) -> c.int --- + + sceRtcGetCurrentAdNetworkTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetCurrentDebugNetworkTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetCurrentGpsTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetCurrentRetainedNetworkTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetLastAdjustedTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetLastReincarnatedTick :: proc(tick: ^sce.RtcTick) -> c.int --- + sceRtcGetAccumulativeTime :: proc() -> sce.ULong64 --- +} diff --git a/SblACMgr/SblACMgr.odin b/SblACMgr/SblACMgr.odin new file mode 100644 index 0000000..cc27c49 --- /dev/null +++ b/SblACMgr/SblACMgr.odin @@ -0,0 +1,10 @@ +package sblacmgr + +import sce "../common" + +foreign import sblacmgr "system:SceSblACMgr_stub" + +@(link_prefix = "sceSblACMgr") +foreign sblacmgr { + IsGameProgram :: proc(result: ^sce.Bool) -> sce.Int32 --- +} diff --git a/SblUpdateMgr/SblUpdateMgr.odin b/SblUpdateMgr/SblUpdateMgr.odin new file mode 100644 index 0000000..1e1f728 --- /dev/null +++ b/SblUpdateMgr/SblUpdateMgr.odin @@ -0,0 +1,47 @@ +package sblupdatemgr + +import "core:c" + +foreign import sblupdatemgr "system:SceSblUpdateMgr_stub" + +SCE_UPDATE_MODE_SWU_GUI :: 0x10 +SCE_UPDATE_MODE_SWU_CUI :: 0x30 + +SceUpdateMode :: c.char + +GetBootMode :: GetUpdateMode +SetBootMode :: SetUpdateMode + +@(link_prefix = "sceSblUs") +foreign sblupdatemgr { + /** + * Getting system update mode on boot + * + * @param[out] mode - The pointer of SceUpdateMode variable + * + * @return 0 on success, < 0 on error. + */ + GetUpdateMode :: proc(mode: ^SceUpdateMode) -> c.int --- + + + /** + * Setting system update mode on boot + * + * @param[in] mode - The update mode + * + * @return 0 on success, < 0 on error. + */ + SetUpdateMode :: proc(mode: SceUpdateMode) -> c.int --- + + + /** + * Verify PUP + * + * @param[in] path - The PUP path + * + * @return 0 on success, < 0 on error. + * + * note - If verify CEX PUP on Devkit system, got error. + */ + VerifyPup :: proc(path: cstring) -> c.int --- +} diff --git a/ScreenShot/ScreenShot.odin b/ScreenShot/ScreenShot.odin new file mode 100644 index 0000000..3ceee3b --- /dev/null +++ b/ScreenShot/ScreenShot.odin @@ -0,0 +1,19 @@ +package screenshot + +import "core:c" + +foreign import screenshot "system:SceScreenShot_stub" + +foreign screenshot { + //! Set screenshot params + sceScreenShotSetParam :: proc(#by_ptr param: SceScreenShotParam) -> c.int --- + + //! Set overlay image + sceScreenShotSetOverlayImage :: proc(filepath: cstring, offsetX: c.int, offsetY: c.int) -> c.int --- + + //! Disable screenshot + sceScreenShotDisable :: proc() -> c.int --- + + //! Enable screenshot + sceScreenShotEnable :: proc() -> c.int --- +} diff --git a/ScreenShot/types.odin b/ScreenShot/types.odin new file mode 100644 index 0000000..f820394 --- /dev/null +++ b/ScreenShot/types.odin @@ -0,0 +1,44 @@ +package screenshot + +import "core:c" +import sce "../common" + +//! Max size of path strings (includes device name and NULL terminator) +SCE_SCREENSHOT_MAX_FS_PATH :: (1024) + +//! Max length of photo title +SCE_SCREENSHOT_MAX_PHOTO_TITLE_LEN :: (64) + +//! Max size of photo title (includes NULL terminator) +SCE_SCREENSHOT_MAX_PHOTO_TITLE_SIZE :: (SCE_SCREENSHOT_MAX_PHOTO_TITLE_LEN * 4) + +//! Max length of game title +SCE_SCREENSHOT_MAX_GAME_TITLE_LEN :: (64) + +//! Max size of game title (includes NUL terminator) +SCE_SCREENSHOT_MAX_GAME_TITLE_SIZE :: (SCE_SCREENSHOT_MAX_GAME_TITLE_LEN * 4) + +//! Max length of comment (description) +SCE_SCREENSHOT_MAX_GAME_COMMENT_LEN :: (128) + +//! Max size of comment (description) (includes NUL terminator) +SCE_SCREENSHOT_MAX_GAME_COMMENT_SIZE :: (SCE_SCREENSHOT_MAX_GAME_COMMENT_LEN * 4) + +// TODO: +SceScreenshotErrorCode :: enum c.uint { + INVALID_ARGUMENT = 0x80102F01, + NO_MEMORY = 0x80102F02, + FILE_NOT_FOUND = 0x80102F03, + NOT_SUPPORTED_FORMAT = 0x80102F04, + MEDIA_FULL = 0x80102F05, + INTERNAL = 0x80102F06 +} + + +SceScreenShotParam :: struct { + photoTitle: [^]sce.WChar32, //!< Photo title + gameTitle: [^]sce.WChar32, //!< Game title + gameComment: [^]sce.WChar32, //!< Game description + reserved: rawptr, //!< Reserved range (Must be NULL) +} + diff --git a/ShaccCg/ShaccCg.odin b/ShaccCg/ShaccCg.odin new file mode 100644 index 0000000..d1903fc --- /dev/null +++ b/ShaccCg/ShaccCg.odin @@ -0,0 +1,23 @@ +package shacccg + +import "core:c" +import sce "../common" + +foreign import shacccg "system:SceShaccCg_stub" + +@(link_prefix = "sceShaccCg") +foreign shacccg { + InitializeCompileOptions :: proc(options: ^SceShaccCgCompileOptions) -> c.int --- + + CompileProgram :: proc(#by_ptr options: SceShaccCgCompileOptions, #by_ptr callbacks: SceShaccCgCallbackList, unk: c.int) -> ^SceShaccCgCompileOutput --- + + SetDefaultAllocator :: proc(malloc_cb: #type ^proc "c" (_: c.uint) -> rawptr, free_cb: #type ^proc "c" (_: rawptr)) -> c.int --- + + InitializeCallbackList :: proc(callbacks: ^SceShaccCgCallbackList, defaults: SceShaccCgCallbackDefaults) --- + + DestroyCompileOutput :: proc(output: ^SceShaccCgCompileOutput) --- + + ReleaseCompiler :: proc() --- + + GetVersionString :: proc() -> cstring --- +} diff --git a/ShaccCg/types.odin b/ShaccCg/types.odin new file mode 100644 index 0000000..d5354df --- /dev/null +++ b/ShaccCg/types.odin @@ -0,0 +1,126 @@ +package shacccg + +import "core:c" +import sce "../common" + +SceShaccCgParameter :: rawptr + +SceShaccCgCallbackOpenFile :: #type ^proc "c" ( + fileName: cstring, + #by_ptr includedFrom: SceShaccCgSourceLocation, + #by_ptr compileOptions: SceShaccCgCompileOptions, + errorString: ^cstring) -> ^SceShaccCgSourceFile + +SceShaccCgCallbackReleaseFile :: #type ^proc "c" ( + #by_ptr file: SceShaccCgSourceFile, + #by_ptr compileOptions: SceShaccCgCompileOptions) + +SceShaccCgCallbackLocateFile :: #type ^proc "c" ( + fileName: cstring, + #by_ptr includedFrom: SceShaccCgSourceLocation, + searchPathCount: sce.UInt32, + searchPaths: [^]cstring, + #by_ptr compileOptions: SceShaccCgCompileOptions, + errorString: ^cstring) -> cstring + +SceShaccCgCallbackAbsolutePath :: #type ^proc "c" ( + fileName: cstring, + #by_ptr includedFrom: SceShaccCgSourceLocation, + #by_ptr compileOptions: SceShaccCgCompileOptions) -> cstring + +SceShaccCgCallbackReleaseFileName :: #type ^proc "c" ( + fileName: cstring, + #by_ptr compileOptions: SceShaccCgCompileOptions) + +SceShaccCgCallbackFileDate :: #type ^proc "c" ( + #by_ptr file: SceShaccCgSourceFile, + #by_ptr includedFrom: SceShaccCgSourceLocation, + #by_ptr compileOptions: SceShaccCgCompileOptions, + timeLastStatusChange: ^c.int64_t, + timeLastModified: ^c.int64_t) -> sce.Int32 + +SceShaccCgDiagnosticLevel :: enum c.int { + INFO, + WARNING, + ERROR +} + +SceShaccCgTargetProfile :: enum c.int { + VP, + FP +} + +SceShaccCgCallbackDefaults :: enum c.int { + SYSTEM_FILES, + TRIVIAL +} + +SceShaccCgLocale :: enum c.int { + ENGLISH, + JAPANESE +} + +SceShaccCgSourceFile :: struct { + fileName: cstring, + text: cstring, + size: sce.UInt32, +} + +SceShaccCgSourceLocation :: struct { + file: ^SceShaccCgSourceFile, + lineNumber: sce.UInt32, + columnNumber: sce.UInt32, +} + +SceShaccCgCallbackList :: struct { + openFile: SceShaccCgCallbackOpenFile, + releaseFile: SceShaccCgCallbackReleaseFile, + locateFile: SceShaccCgCallbackLocateFile, + absolutePath: SceShaccCgCallbackAbsolutePath, + releaseFileName: SceShaccCgCallbackReleaseFileName, + fileDate: SceShaccCgCallbackFileDate, +} + +SceShaccCgCompileOptions :: struct { + mainSourceFile: cstring, + targetProfile: SceShaccCgTargetProfile, + entryFunctionName: cstring, + searchPathCount: sce.UInt32, + searchPaths: [^]cstring, + macroDefinitionCount: sce.UInt32, + macroDefinitions: [^]cstring, + includeFileCount: sce.UInt32, + includeFiles: [^]cstring, + suppressedWarningsCount: sce.UInt32, + suppressedWarnings: [^]sce.UInt32, + locale: SceShaccCgLocale, + useFx: sce.Int32, + noStdlib: sce.Int32, + optimizationLevel: sce.Int32, + useFastmath: sce.Int32, + useFastprecision: sce.Int32, + useFastint: sce.Int32, + field_48: c.int, + warningsAsErrors: sce.Int32, + performanceWarnings: sce.Int32, + warningLevel: sce.Int32, + pedantic: sce.Int32, + pedanticError: sce.Int32, + field_60: c.int, + field_64: c.int, +} + +SceShaccCgDiagnosticMessage :: struct { + level: SceShaccCgDiagnosticLevel, + code: sce.UInt32, + location: ^SceShaccCgSourceLocation, + message: cstring, +} + +SceShaccCgCompileOutput :: struct { + programData: [^]c.uint8_t, + programSize: sce.UInt32, + diagnosticCount: sce.Int32, + diagnostics: ^SceShaccCgDiagnosticMessage, +} + diff --git a/ShellSvc/ShellSvc.odin b/ShellSvc/ShellSvc.odin new file mode 100644 index 0000000..021e090 --- /dev/null +++ b/ShellSvc/ShellSvc.odin @@ -0,0 +1,50 @@ +package shellsvc + +import "core:c" + +foreign import shellsvc "system:SceShellSvc_stub" + +@(link_prefix = "sceShellUtil") +foreign shellsvc { + /** + * Init events + * + * @param[in] unk - Unknown, use 0 + * + * @return 0 on success, < 0 on error. + */ + InitEvents :: proc(unk: c.int) -> c.int --- + + /** + * Register event handler + * + * @param[in] handler - Event handler + * + * @param[in] userData - The user data passed to the handler + * + * @return 0 on success, < 0 on error. + */ + RegisterEventHandler :: proc(handler: ^SceShellUtilEventHandler, userData: rawptr) -> c.int --- + + /** + * Lock event + * + * @param[in] type - One of ::SceShellUtilLockType + * + * @return 0 on success, < 0 on error. + */ + Lock :: proc(type: SceShellUtilLockType) -> c.int --- + + /** + * Unlock event + * + * @param[in] type - One of ::SceShellUtilLockType + * + * @return 0 on success, < 0 on error. + */ + Unlock :: proc(type: SceShellUtilLockType) -> c.int --- + + + RequestLaunchApp :: proc(param: ^SceShellUtilLaunchAppParam) -> c.int --- + LaunchAppRequestLaunchApp :: proc(param: ^SceShellUtilLaunchAppParam) -> c.int --- +} diff --git a/ShellSvc/types.odin b/ShellSvc/types.odin new file mode 100644 index 0000000..9ad46b2 --- /dev/null +++ b/ShellSvc/types.odin @@ -0,0 +1,29 @@ +package shellsvc + +import "core:c" + +SceShellUtilLockType :: enum c.int { + PS_BTN = 0x1, + QUICK_MENU = 0x2, + POWEROFF_MENU = 0x4, + UNK8 = 0x8, + USB_CONNECTION = 0x10, + MC_INSERTED = 0x20, + MC_REMOVED = 0x40, + UNK80 = 0x80, + UNK100 = 0x100, + UNK200 = 0x200, + MUSIC_PLAYER = 0x400, + PS_BTN_2 = 0x800, //! without the stop symbol +} + +SceShellUtilLockMode :: enum c.int { + LOCK = 1, + UNLOCK = 2 +} + +SceShellUtilEventHandler :: #type proc "c" (result: c.int, mode: SceShellUtilLockMode, type: SceShellUtilLockType, userData: rawptr) + +SceShellUtilLaunchAppParam :: struct { + cmd: cstring, +} diff --git a/ShutterSound/ShutterSound.odin b/ShutterSound/ShutterSound.odin new file mode 100644 index 0000000..8e6e8c9 --- /dev/null +++ b/ShutterSound/ShutterSound.odin @@ -0,0 +1,31 @@ +package shuttersound + +import "core:c" + +foreign import shuttersound "system:SceShutterSound_stub" + +// TODO: +SceShutterSoundErrorCode :: enum c.uint { + INVALID_ARGUMENT = 0x80105201, //!< Invalid argument + INTERNAL = 0x80105202, //!< Internal error + FATAL = 0x80105203 //!< Fatal error +} + +SceShutterSoundType :: enum c.uint { + SAVE_IMAGE = 0, + SAVE_VIDEO_START = 1, + SAVE_VIDEO_END = 2, +} + + +@(link_prefix = "sceShutterSound") +foreign shuttersound { + /** + * Plays a shutter sound + * + * @param[in] type - The sound type to play (One of ::SceShutterSoundType) + * + * @return 0 on success, < 0 on error. + */ + Play :: proc(type: SceShutterSoundType) -> c.int --- +} diff --git a/Sqlite/Sqlite.odin b/Sqlite/Sqlite.odin new file mode 100644 index 0000000..90781f9 --- /dev/null +++ b/Sqlite/Sqlite.odin @@ -0,0 +1,23 @@ +package sqlite + +import "core:c" + +foreign import sqlite "system:SceSqlite_stub" + +SceSqliteMallocMethods :: struct { + xMalloc: #type ^proc "c" (_: c.int) -> rawptr, + xRealloc: #type ^proc "c" (_: rawptr, __: c.int) -> rawptr, + xFree: #type ^proc "c" (_: rawptr), +} + +@(link_prefix = "sceSqlite") +foreign sqlite { + /** + * Wrapper for sqlite3_config(SQLITE_CONFIG_MALLOC) + * + * @param[in] methods - A proper set of memory allocation methods + * + * @return 0 on success, < 0 on error. + */ + ConfigMallocMethods :: proc(methods: ^SceSqliteMallocMethods) -> c.int --- +} diff --git a/Ssl/Ssl.odin b/Ssl/Ssl.odin new file mode 100644 index 0000000..5d469c4 --- /dev/null +++ b/Ssl/Ssl.odin @@ -0,0 +1,39 @@ +package ssl + +import "core:c" +import sce "../common" + +foreign import ssl "system:SceSsl_stub" + +// TODO: should be c.int +SceSslErrorCode :: enum c.uint { + BEFORE_INIT = 0x80435001, + ALREADY_INITED = 0x80435020, + OUT_OF_MEMORY = 0x80435022, + NOT_FOUND = 0x80435025, + INTERNAL = 0x80435026, + INVALID_FORMAT = 0x80435108, + INVALID_VALUE = 0x804351FE +} + +SceSslMemoryPoolStats :: struct { + poolSize: c.uint, + maxInuseSize: c.uint, + currentInuseSize: c.uint, + reserved: c.int, +} +#assert(size_of(SceSslMemoryPoolStats) == 0x10) + +foreign ssl { + sceSslInit :: proc(poolSize: c.uint) -> c.int --- + sceSslTerm :: proc() -> c.int --- + sceSslGetMemoryPoolStats :: proc(currentStat: ^SceSslMemoryPoolStats) -> c.int --- + sceSslGetSerialNumber :: proc(sslCert: rawptr, sboData: ^cstring, sboLen: ^c.uint) -> c.int --- + sceSslGetNotBefore :: proc(sslCert: rawptr, begin: ^sce.RtcTick) -> c.int --- + sceSslGetNotAfter :: proc(sslCert: rawptr, limit: ^sce.RtcTick) -> c.int --- + sceSslGetNameEntryCount :: proc(certName: rawptr) -> c.int --- + sceSslGetNameEntryInfo :: proc(certName: rawptr, entryNum: c.int, oidname: cstring, maxOidnameLen: c.uint, value: cstring, maxValueLen: c.uint, valueLen: ^c.uint) -> c.int --- + sceSslGetSubjectName :: proc(sslCert: rawptr) -> rawptr --- + sceSslGetIssuerName :: proc(sslCert: rawptr) -> rawptr --- + sceSslFreeSslCertName :: proc(certName: rawptr) -> c.int --- +} diff --git a/Sysmodule/Sysmodule.odin b/Sysmodule/Sysmodule.odin new file mode 100644 index 0000000..73fc33e --- /dev/null +++ b/Sysmodule/Sysmodule.odin @@ -0,0 +1,87 @@ +package sysmodule + +import "core:c" +import sce "../common" + +foreign import sysmodule "system:SceSysmodule_stub" + +@(link_prefix = "sceSysmodule") +foreign sysmodule { + /** + * Load a module. + * + * @param[in] id - Module ID to load. + * + * @return 0 on success, <0 on error. + */ + LoadModule :: proc(id: SceSysmoduleModuleId) -> c.int --- + + /** + * Unload a module. + * + * @param[in] id - Module ID to unload. + * + * @return 0 on success, <0 on error. + */ + UnloadModule :: proc(id: SceSysmoduleModuleId) -> c.int --- + + /** + * Check if a module is loaded. + * + * @param[in] id - Module ID to check. + * + * @return 0 if loaded, <0 otherwise. + */ + IsLoaded :: proc(id: SceSysmoduleModuleId) -> c.int --- + + /** + * Load an internal module. + * + * @param[in] id - Module ID to load. + * + * @return 0 on success, <0 on error. + */ + LoadModuleInternal :: proc(id: SceSysmoduleInternalModuleId) -> c.int --- + + /** + * Unload an internal module. + * + * @param[in] id - Module ID to unload. + * + * @return 0 on success, <0 on error. + */ + UnloadModuleInternal :: proc(id: SceSysmoduleInternalModuleId) -> c.int --- + + /** + * Check if an internal module is loaded. + * + * @param[in] id - Module ID to check. + * + * @return 0 if loaded, <0 otherwise. + */ + IsLoadedInternal :: proc(id: SceSysmoduleInternalModuleId) -> c.int --- + + /** + * Load an internal module with custom arguments. + * + * @param[in] id - Module ID to check. + * @param[in] args - Size of passed arguments. + * @param[in] argp - Pointer to arguments to pass. + * @param[in] option - Module load option. + * + * @return 0 on success, <0 otherwise. + */ + LoadModuleInternalWithArg :: proc(id: SceSysmoduleInternalModuleId, args: sce.Size, argp: rawptr, #by_ptr option: SceSysmoduleOpt) -> c.int --- + + /** + * Unload an internal module with custom arguments. + * + * @param[in] id - Module ID to check. + * @param[in] args - Size of passed arguments. + * @param[in] argp - Pointer to arguments to pass. + * @param[in] option - Module load option. + * + * @return 0 on success, <0 otherwise. + */ + UnloadModuleInternalWithArg :: proc(id: SceSysmoduleInternalModuleId, args: sce.Size, argp: rawptr, #by_ptr option: SceSysmoduleOpt) -> c.int --- +} diff --git a/Sysmodule/types.odin b/Sysmodule/types.odin new file mode 100644 index 0000000..21192f0 --- /dev/null +++ b/Sysmodule/types.odin @@ -0,0 +1,152 @@ +package sysmodule + +import "core:c" + +/** Errorcodes for SceSysmodule */ +// TODO: +SceSysmoduleErrorCode :: enum c.uint { + LOADED = 0, //!< Module is already loaded + ERROR_INVALID_VALUE = 0x805A1000, //!< Invalid value + ERROR_UNLOADED = 0x805A1001, //!< Module is not loaded + ERROR_FATAL = 0x805A10FF //!< Fatal error +} + +/** Available modules ID for ::sceSysmoduleLoadModule */ +SceSysmoduleModuleId :: enum c.int { + INVALID = 0x0000, //!< Invalid module + NET = 0x0001, //!< Net module + HTTP = 0x0002, //!< HTTP module + SSL = 0x0003, //!< SSL module + HTTPS = 0x0004, //!< HTTPS module + PERF = 0x0005, //!< Perf module + FIBER = 0x0006, //!< Fiber module + ULT = 0x0007, //!< Ult module + DBG = 0x0008, //!< DBG module + RAZOR_CAPTURE = 0x0009, //!< Razor Capture module + RAZOR_HUD = 0x000A, //!< Razor HUD module + NGS = 0x000B, //!< NGS module + SULPHA = 0x000C, //!< Sulpha module + SAS = 0x000D, //!< Sas module + PGF = 0x000E, //!< Pgf module + APPUTIL = 0x000F, //!< AppUtil module + FIOS2 = 0x0010, //!< Fios2 module + IME = 0x0011, //!< Ime module + NP_BASIC = 0x0012, //!< NpBasic module + SYSTEM_GESTURE = 0x0013, //!< System Gesture module + LOCATION = 0x0014, //!< Location module + NP = 0x0015, //!< Np module + PHOTO_EXPORT = 0x0016, //!< Photo Export module + XML = 0x0017, //!< XML module + NP_COMMERCE2 = 0x0018, //!< NPCommerce2 module + NP_UTILITY = 0x0019, //!< NpUtility module + VOICE = 0x001A, //!< Voice module + VOICEQOS = 0x001B, //!< VoiceQos module + NP_MATCHING2 = 0x001C, //!< NpMatching2 module + SCREEN_SHOT = 0x001D, //!< ScreenShot module + NP_SCORE_RANKING = 0x001E, //!< NpScoreRanking module + SQLITE = 0x001F, //!< Sqlite module + TRIGGER_UTIL = 0x0020, //!< TriggerUtil module + RUDP = 0x0021, //!< Rudp module + CODECENGINE_PERF = 0x0022, //!< CodecEngine Perf module + LIVEAREA = 0x0023, //!< Livearea module + NP_ACTIVITY = 0x0024, //!< NpActivity module + NP_TROPHY = 0x0025, //!< NpTrophy module + NP_MESSAGE = 0x0026, //!< NpMessage module + SHUTTER_SOUND = 0x0027, //!< Shutter Sound module + CLIPBOARD = 0x0028, //!< Clipboard module + NP_PARTY = 0x0029, //!< NpParty module + NET_ADHOC_MATCHING = 0x002A, //!< NetAdhoc Matching module + NEAR_UTIL = 0x002B, //!< NearUtil module + NP_TUS = 0x002C, //!< NpTus module + MP4 = 0x002D, //!< MP4 module + AACENC = 0x002E, //!< AacEnc module + HANDWRITING = 0x002F, //!< Handwriting module + ATRAC = 0x0030, //!< Atrac module + NP_SNS_FACEBOOK = 0x0031, //!< NpSns Facebook module + VIDEO_EXPORT = 0x0032, //!< Video Export module + NOTIFICATION_UTIL = 0x0033, //!< NotificationUtil module + BG_APP_UTIL = 0x0034, //!< BgAppUtil module + INCOMING_DIALOG = 0x0035, //!< Incoming Dialog module + IPMI = 0x0036, //!< IPMI module + AUDIOCODEC = 0x0037, //!< AudioCodec module + FACE = 0x0038, //!< Face module + SMART = 0x0039, //!< Smart module + MARLIN = 0x003A, //!< Marlin module + MARLIN_DOWNLOADER = 0x003B, //!< Marlin Downloader module + MARLIN_APP_LIB = 0x003C, //!< Marlin AppLib module + TELEPHONY_UTIL = 0x003D, //!< TelephonyUtil module + SHACCCG = 0x003E, //!< ShaccCg module + MONO_BRIDGE = 0x003F, //!< Mono bridge module + MONO = 0x0040, //!< Mono module + PSM = 0x0041, //!< Psm module + PSM_DEVAGENT = 0x0042, //!< Psm devagent module + PSPNET_ADHOC = 0x0043, //!< PSPNet Adhoc module + DTCP_IP = 0x0044, //!< DTCP/IP module + VIDEO_SEARCH_EMPR = 0x0045, //!< VideoSearch module + NP_SIGNALING = 0x0046, //!< NpSignaling module + BEISOBMF = 0x0047, //!< BEISOBMF module + BEMP2SYS = 0x0048, //!< BEMP2SYS module + MUSIC_EXPORT = 0x0049, //!< Music Export module + NEAR_DIALOG_UTIL = 0x004A, //!< NearDialogUtil module + LOCATION_EXTENSION = 0x004B, //!< LocationExt module + AVPLAYER = 0x004C, //!< AVPlayer module + GAME_UPDATE = 0x004D, //!< Game Update module + MAIL_API = 0x004E, //!< Mail Api module + TELEPORT_CLIENT = 0x004F, //!< Teleport Client module + TELEPORT_SERVER = 0x0050, //!< Teleport Server module + MP4_RECORDER = 0x0051, //!< MP4 Recorder module + APPUTIL_EXT = 0x0052, //!< AppUtilExt module + NP_WEBAPI = 0x0053, //!< NpWebApi module + AVCDEC = 0x0054, //!< AVCDec module + JSON = 0x0055 //!< JSON module +} + +/** Available internal modules ID for ::sceSysmoduleLoadModuleInternal */ +SceSysmoduleInternalModuleId :: enum c.uint { + JPEG_ENC_ARM = 0x80000001, //!< sceJpegEncArm module + AUDIOCODEC = 0x80000002, //!< AudioCodec module + JPEG_ARM = 0x80000003, //!< sceJpegArm module + G729 = 0x80000004, //!< G729 module + BXCE = 0x80000005, //!< BXCE module + INI_FILE_PROCESSOR = 0x80000006, //!< INI File Processor module + NP_ACTIVITY_NET = 0x80000007, //!< NpActivityNet module + PAF = 0x80000008, //!< Paf module + SQLITE_VSH = 0x80000009, //!< sceSqliteVsh module + DBUTIL = 0x8000000A, //!< DBUtil module + ACTIVITY_DB = 0x8000000B, //!< ActivityDB module + COMMON_GUI_DIALOG = 0x8000000C, //!< Common Gui Dialog module + STORE_CHECKOUT = 0x8000000D, //!< Store Checkout module + IME_DIALOG = 0x8000000E, //!< Ime Dialog module + PHOTO_IMPORT_DIALOG = 0x8000000F, //!< Photo Import Dialog module + PHOTO_REVIEW_DIALOG = 0x80000010, //!< Photo Review Dialog module + CHECKOUT_DIALOG = 0x80000011, //!< Checkout Dialog module + COMMON_DIALOG_MAIN = 0x80000012, //!< Common Dialog Main module + MSG_DIALOG = 0x80000013, //!< sceMsgDialog module + NET_CHECK_DIALOG = 0x80000014, //!< NetCheck Dialog module + SAVEDATA_DIALOG = 0x80000015, //!< SaveData Dialog module + NP_MESSAGE_DIALOG = 0x80000016, //!< NpMessage Dialog module + TROPHY_SETUP_DIALOG = 0x80000017, //!< Trophy Setup Dialog module + FRIEND_LIST_DIALOG = 0x80000018, //!< FriendList Dialog module + NEAR_PROFILE = 0x8000001A, //!< Near Profile module + NP_FRIEND_PRIVACY_LEVEL = 0x8000001B, //!< NpFriend Privacy Level module + NP_COMMERCE2 = 0x8000001D, //!< NpCommerce2 module + NP_KDC = 0x8000001E, //!< NpKdc module + MUSIC_EXPORT = 0x8000001F, //!< Music Export module + VIDEO_EXPORT = 0x80000020, //!< Video Export module + NP_MESSAGE_DIALOG_IMPL = 0x80000021, //!< NpMessageDlg module + NP_MESSAGE_CONTACTS = 0x80000022, //!< NpMessageContacts module + DB_RECOVERY_UTILITY = 0x80000023, //!< DBRecoveryUtil module + PROMOTER_UTIL = 0x80000024, //!< scePromoterUtil module + PARTY_MEMBER_LIST = 0x80000026, //!< Party Member List module + ULT = 0x80000025, //!< Ult module + DRM_PSM_KDC = 0x80000027, //!< DRM PSM KDC module + LOCATION_INTERNAL = 0x80000028, //!< sceLocation module + LOCATION_FACTORY = 0x80000029 //!< Location Factory module +} + +SceSysmoduleOpt :: struct { + flags: c.int, + result: ^c.int, + unused: [2]c.int, +} + diff --git a/Touch/Touch.odin b/Touch/Touch.odin new file mode 100644 index 0000000..73f21b5 --- /dev/null +++ b/Touch/Touch.odin @@ -0,0 +1,69 @@ +package touch + +import "core:c" +import sce "../common" + +foreign import touch "system:SceTouch_stub" + +@(link_prefix = "sceTouch") +foreign touch { + /** + * Get Touch Panel information + * + * @param[in] port Port number. + * @param[out] pPanelInfo The buffer to get the Touch Panel information. + */ + GetPanelInfo :: proc(port: sce.UInt32, pPanelInfo: ^SceTouchPanelInfo) -> c.int --- + + /** + * Get touch data (Blocking) + * + * @param[in] port Port Number. + * @param[out] pData Buffer to receive touch data. + * @param[in] nBufs Number of buffers to receive touch data. + * + * @return Buffers count, between 1 and 'nBufs'. <0 on error. + */ + Read :: proc(port: sce.UInt32, pData: ^SceTouchData, nBufs: sce.UInt32) -> c.int --- + + /** + * Get touch data (Polling) + * + * @param[in] port port number. + * @param[out] pData Buffer to receive touch data. + * @param[in] nBufs Number of buffers to receive touch data. + * + * @return Buffers count, between 1 and 'nBufs'. <0 on error. + */ + Peek :: proc(port: sce.UInt32, pData: ^SceTouchData, nBufs: sce.UInt32) -> c.int --- + + /** + * Set sampling state of touch panel. + * + * @param[in] port Port number. + * @param[in] state Sampling state. + */ + SetSamplingState :: proc(port: sce.UInt32, state: SceTouchSamplingState) -> c.int --- + + /** + * Get sampling state of touch panel. + * + * @param[in] port Port number. + * @param[out] pState The buffer to receive sampling state. + */ + GetSamplingState :: proc(port: sce.UInt32, pState: ^SceTouchSamplingState) -> c.int --- + + /** + * Enable touch force output. + * + * @param[in] port Port number. + */ + EnableTouchForce :: proc(port: sce.UInt32) -> c.int --- + + /** + * Disable touch force output. + * + * @param[in] port Port number. + */ + DisableTouchForce :: proc(port: sce.UInt32) -> c.int --- +} diff --git a/Touch/types.odin b/Touch/types.odin new file mode 100644 index 0000000..8ac5db6 --- /dev/null +++ b/Touch/types.odin @@ -0,0 +1,79 @@ +package touch + +import "core:c" +import sce "../common" + +SCE_TOUCH_MAX_REPORT :: 8 //!< FIXME 6 on front | 4 on back + +/** Touch error codes */ +SceTouchErrorCode :: enum c.uint { + INVALID_ARG = 0x80350001, + PRIV_REQUIRED = 0x80350002, + FATAL = 0x803500FF +} + + +/** + * Port numbers of touch panels + * + * @see ::sceTouchRead + * @see ::sceTouchPeek + */ +SceTouchPortType :: enum c.int { + FRONT = 0, //!< Front touch panel id + BACK = 1, //!< Back touch panel id + MAX_NUM = 2 //!< Number of touch panels +} + +/** + * Sampling port setting of the touch panel + * + * @see ::sceTouchSetSamplingState + */ +SceTouchSamplingState :: enum c.int { + STOP = 0, + START = 1 +} + +/** + * Info field of ::SceTouchReport structure + * + * @see ::SceTouchReport + */ +SceTouchReportInfo :: enum c.int { + HIDE_UPPER_LAYER = 0x0001 +} + +SceTouchPanelInfo :: struct { + minAaX: sce.Int16, //!< Min active area X position + minAaY: sce.Int16, //!< Min active area Y position + maxAaX: sce.Int16, //!< Max active area X position + maxAaY: sce.Int16, //!< Max active area Y position + minDispX: sce.Int16, //!< Min display X origin (top left) + minDispY: sce.Int16, //!< Min display Y origin (top left) + maxDispX: sce.Int16, //!< Max display X origin (bottom right) + maxDispY: sce.Int16, //!< Max display Y origin (bottom right) + minForce: sce.UInt8, //!< Min touch force value + maxForce: sce.UInt8, //!< Max touch force value + reserved: [30]sce.UInt8, //!< Reserved +} +#assert(size_of(SceTouchPanelInfo) == 0x30) + +SceTouchReport :: struct { + id: sce.UInt8, //!< Touch ID + force: sce.UInt8, //!< Touch force + x: sce.Int16, //!< X position + y: sce.Int16, //!< Y position + reserved: [8]sce.UInt8, //!< Reserved + info: sce.UInt16, //!< Information of this touch +} +#assert(size_of(SceTouchReport) == 0x10) + +SceTouchData :: struct { + timeStamp: sce.UInt64, //!< Data timestamp + status: sce.UInt32, //!< Unused + reportNum: sce.UInt32, //!< Number of touch reports + report: [SCE_TOUCH_MAX_REPORT]SceTouchReport, //!< Touch reports +} +#assert(size_of(SceTouchData) == 0x90) + diff --git a/TriggerUtil/TriggerUtil.odin b/TriggerUtil/TriggerUtil.odin new file mode 100644 index 0000000..103a0c7 --- /dev/null +++ b/TriggerUtil/TriggerUtil.odin @@ -0,0 +1,145 @@ +package triggerutil + +import "core:c" +import sce "../common" + +/** + * @note Last two params in all of the functions are never used, + * probably callbacks since all sceTriggerUtil functions are non-blocking + */ + +/** + * @note Max number of events (eventId) per application is 6 + */ + +foreign import triggerutil "system:SceTriggerUtil_stub" + +@(link_prefix = "sceTriggerUtil") +foreign triggerutil { + /** + * Register application start event that will be repeated on certain days + * + * @param[in] titleid - title ID of application to register event for. + * @param[in] param - event parameters. + * @param[in] eventId - ID number of event. + * @param[in] a4 - Unknown, set to 0. + * @param[in] a5 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + RegisterDailyEvent :: proc(titleid: cstring, #by_ptr param: SceTriggerUtilEventParamDaily, eventId: c.int, a4: c.int, a5: c.int) -> c.int --- + + /** + * Register one time application start event + * + * @param[in] titleid - title ID of application to register event for. + * @param[in] param - event parameters. + * @param[in] eventId - ID number of event. + * @param[in] a4 - Unknown, set to 0. + * @param[in] a5 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + RegisterOneTimeEvent :: proc(titleid: cstring, #by_ptr param: SceTriggerUtilEventParamOneTime, eventId: c.int, a4: c.int, a5: c.int) -> c.int --- + + /** + * Unregister daily event for caller application + * + * @param[in] eventId - ID number of event to unregister. + * @param[in] a2 - Unknown, set to 0. + * @param[in] a3 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + UnregisterDailyEvent :: proc(eventId: c.int, a2: c.int, a3: c.int) -> c.int --- + + /** + * Unregister one time event for caller application + * + * @param[in] eventId - ID number of event to unregister. + * @param[in] a2 - Unknown, set to 0. + * @param[in] a3 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + UnregisterOneTimeEvent :: proc(eventId: c.int, a2: c.int, a3: c.int) -> c.int --- + + /** + * Get value from "Settings->System->Auto-Start Settings" for caller application. Required to be 1 to use + * + * @param[out] status - auto-start status. Required to be 1 to use . + * @param[in] a2 - Unknown, set to 0. + * @param[in] a3 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + GetAutoStartStatus :: proc(status: ^c.int, a2: c.int, a3: c.int) -> c.int --- + + /** + * Get one time event info for caller application + * + * @param[in] eventId - ID number of event to get information for. + * @param[out] triggerTime - SceRtcTick, UTC + * @param[in] a4 - Unknown, set to 0. + * @param[in] a5 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + GetOneTimeEventInfo :: proc(eventId: c.int, triggerTime: ^sce.RtcTick, a4: c.int, a5: c.int) -> c.int --- + + /** + * Get daily event info for caller application + * + * @param[in] eventId - ID number of event to get information for. + * @param[out] param - event parameters. + * @param[in] a5 - Unknown, set to 0. + * @param[in] a6 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + GetDailyEventInfo :: proc(eventId: c.int, param: ^SceTriggerUtilEventParamDaily, a5: c.int, a6: c.int) -> c.int --- + + /** + * Get info for user application that has registered events + * + * @param[in] titleid - title ID of application to get info for. + * @param[out] appInfo - application information + * @param[in] a4 - Unknown, set to 0. + * @param[in] a5 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + GetUserAppInfo :: proc(titleid: cstring, appInfo: ^SceTriggerUtilUserAppInfo, a4: c.int, a5: c.int) -> c.int --- + + /** + * Get list of user applications that has registered events. List contains null-separated title IDs + * + * @param[out] titleIdBuffer - pointer to buffer to recieve title ID list. Max size is 0x1000, min size is unlimited + * @param[out] numOfIds - number of title IDs stored in the list + * + * @return 0 on success, <0 otherwise. + */ + GetRegisteredUserTitleIdList :: proc(titleIdBuffer: [^]c.char, numOfIds: c.int) -> c.int --- + + /** + * Get info for system application that has registered events + * + * @param[in] titleid - title ID of application to get info for. + * @param[out] appInfo - application information + * @param[in] a4 - Unknown, set to 0. + * @param[in] a5 - Unknown, set to 0. + * + * @return 0 on success, <0 otherwise. + */ + GetSystemAppInfo :: proc(titleid: cstring, appInfo: ^SceTriggerUtilSystemAppInfo, a4: c.int, a5: c.int) -> c.int --- + + /** + * Get list of system applications that has registered events. List contains null-separated fake title IDs + * + * @param[out] titleIdBuffer - pointer to buffer to recieve fake title ID list. Max size is 0x140, min size is unlimited + * @param[out] numOfIds - number of fake title IDs stored in the list + * + * @return 0 on success, <0 otherwise. + */ + GetRegisteredSystemTitleIdList :: proc(buffer: [^]c.char, numOfIds: c.int) -> c.int --- +} diff --git a/TriggerUtil/types.odin b/TriggerUtil/types.odin new file mode 100644 index 0000000..8e8dfae --- /dev/null +++ b/TriggerUtil/types.odin @@ -0,0 +1,65 @@ +package triggerutil + +import "core:c" +import sce "../common" + +SCE_TRIGGER_UTIL_VERSION :: 0x3200000 + +/** + * Days of the week for use in repeatDays member of ::SceTriggerUtilEventParamDaily + */ +SceTriggerUtilDays :: enum c.int { + SUNDAY = 0x1, + MONDAY = 0x2, + TUESDAY = 0x4, + WEDNESDAY = 0x8, + THURSDAY = 0x10, + FRIDAY = 0x20, + SATURDAY = 0x40, +} + +/** + * Error Codes + */ +SceTriggerUtilErrorCode :: enum c.uint { + BUSY = 0x80103600, + NOT_FOUND_USER = 0x80103611, + NOT_FOUND_SYSTEM = 0x80103614, + NOT_REGISTERED = 0x80103621, + EVENT_TYPE_MISMATCH = 0x80103624, + INVALID_ARG = 0x80103660 +} + +SceTriggerUtilEventParamDaily :: struct { // size is 0x50 + ver: sce.UInt32, + extraParam1: sce.Int16, // set to 1 + extraParam2: sce.Int16, // set to 0 + triggerTime: sce.Int32, // POSIX time + repeatDays: sce.UInt16, // bitwise + reserved: [0x40]sce.Char8, +} +#assert(size_of(SceTriggerUtilEventParamDaily) == 0x50) + +SceTriggerUtilEventParamOneTime :: struct { // size is 0x54 + ver: sce.UInt32, + triggerTime: sce.RtcTick, // SceRtcTick, UTC + extraParam1: sce.UInt8, // set to 1 + extraParam2: sce.UInt8, // set to 0 + reserved: [0x44]sce.Char8, +} +#assert(size_of(SceTriggerUtilEventParamOneTime) == 0x58) + +SceTriggerUtilUserAppInfo :: struct { // size is 0x46A + name: [0x34]sce.WChar16, + iconPath: [0x400]sce.Char8, + unk: c.short, +} +#assert(size_of(SceTriggerUtilUserAppInfo) == 0x46A) + +SceTriggerUtilSystemAppInfo :: struct { // size is 0x602 + name: [0x100]sce.WChar16, + iconPath: [0x400]sce.Char8, + reserved: [2]c.char, +} +#assert(size_of(SceTriggerUtilSystemAppInfo) == 0x602) + diff --git a/Udcd/Udcd.odin b/Udcd/Udcd.odin new file mode 100644 index 0000000..a327275 --- /dev/null +++ b/Udcd/Udcd.odin @@ -0,0 +1,65 @@ +package udcd + +import "core:c" +import sce "../common" + +foreign import udcd "system:SceUdcd_stub" + +@(link_prefix = "sceUdcd") +foreign udcd { + /** + * Get device state + * + * @param[out] state - Device state + * + * @return 0 on success, < 0 on error. + */ + GetDeviceState :: proc(state: ^SceUdcdDeviceState) -> c.int --- + + /** + * Get device information + * + * @param[out] devInfo - Device information + * + * @return 0 on success, < 0 on error. + */ + GetDeviceInfo :: proc(devInfo: ^SceUdcdDeviceInfo) -> c.int --- + + /** + * Get state of a specific USB driver + * + * @param driverName - name of USB driver to get status from + * + * @return SCE_UDCD_STATUS_DRIVER_STARTED if the driver has been started, SCE_UDCD_STATUS_DRIVER_REGISTERED if it is stopped + */ + GetDrvState :: proc(driverName: cstring) -> c.int --- + + /** + * Register callback + * + * @param[in] cbid - Callback UID + * @param[in] state - State + * + * @return 0 on success, < 0 on error. + */ + RegisterCallback :: proc(cbid: sce.UID, state: c.int) -> c.int --- + + /** + * Unregister callback + * + * @param[in] cbid - Callback UID + * + * @return 0 on success, < 0 on error. + */ + UnregisterCallback :: proc(cbid: sce.UID) -> c.int --- + + /** + * Wait for state + * + * @param[in] waitParam - Wait parameter + * @param[in] timeout - Timeout + * + * @return 0 on success, < 0 on error. + */ + WaitState :: proc(waitParam: ^SceUdcdWaitParam, timeout: c.uint) -> c.int --- +} diff --git a/Udcd/types.odin b/Udcd/types.odin new file mode 100644 index 0000000..50cbc10 --- /dev/null +++ b/Udcd/types.odin @@ -0,0 +1,48 @@ +package udcd + +import "core:c" +import sce "../common" + +SceUdcdStatus :: enum c.int { + CONNECTION_NEW = 0x0001, + CONNECTION_ESTABLISHED = 0x0002, + CONNECTION_SUSPENDED = 0x0004, + CABLE_DISCONNECTED = 0x0010, + CABLE_CONNECTED = 0x0020, + DEACTIVATED = 0x0100, + ACTIVATED = 0x0200, + IS_CHARGING = 0x0400, + USE_USB_CHARGING = 0x0800, + UNKNOWN_1000 = 0x1000, + UNKNOWN_2000 = 0x2000 +} + +SceUdcdStatusDriver :: enum c.int { + STARTED = 0x01, + REGISTERED = 0x02, +} + +SceUdcdDeviceInfo :: struct { + info: [64]c.uchar, +} +#assert(size_of(SceUdcdDeviceInfo) == 0x40) + +SceUdcdWaitParam :: struct { + unk_00: c.int, + status: c.int, + unk_08: c.int, + unk_0C: c.int, + unk_10: c.int, + driverName: cstring, +} + +SceUdcdDeviceState :: struct { + unk_00: c.int, + state: c.int, + cable: c.int, + connection: c.int, + use_usb_charging: c.int, + unk_14: c.int, +} +#assert(size_of(SceUdcdDeviceState) == 0x18) + diff --git a/UsbAudioIn/UsbAudioIn.odin b/UsbAudioIn/UsbAudioIn.odin new file mode 100644 index 0000000..f44670f --- /dev/null +++ b/UsbAudioIn/UsbAudioIn.odin @@ -0,0 +1,101 @@ +package usbaudioin + +import "core:c" +import sce "../common" + +foreign import usbaudioin "system:SceUsbAudioIn_stub" + +@(link_prefix = "sceUsbAudioIn") +foreign usbaudioin { + /** + * Open usb audio device + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[in] bits - Bits per sample. Only 16 allowed + * @param[in] rate - Bitrate in Hz. Only 48000 allowed + */ + OpenDevice :: proc(device_id: sce.UInt32, bits: c.int, rate: c.int) -> sce.Int32 --- + + /** + * Close usb audio device + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + */ + CloseDevice :: proc(device_id: sce.UInt32) -> sce.Int32 --- + + /** + * Get available audio usb devices + * + * @return 0 on success, < 0 on error + * + * @param[out] list - pointer to array of SceUsbAudioInDeviceListItem + * @param[out] device_count - connected device count + * @param[in] list_size - number of items in SceUsbAudioInDeviceListItem array + * + * @note While function accepts up to 127 as list_size it can only return maximum 7 devices + */ + GetDeviceIdList :: proc(list: ^SceUsbAudioInDeviceListItem, device_count: ^sce.UInt32, list_size: sce.UInt32) -> sce.Int32 --- + + /** + * Get usb audio device info + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[out] info - pointer to SceUsbAudioInDeviceInfo + */ + GetDeviceInformation :: proc(device_id: sce.UInt32, info: ^SceUsbAudioInDeviceInfo) -> sce.Int32 --- + + /** + * Get usb audio device max volume + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[out] volume - maximum device volume + * + * @note You should OpenDevice first to use this function + */ + GetMaxValueOfVolume :: proc(device_id: sce.UInt32, volume: ^sce.UInt32) -> sce.Int32 --- + + /** + * Get usb audio device min volume + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[out] volume - minimum device volume + * + * @note You should OpenDevice first to use this function + */ + GetMinValueOfVolume :: proc(device_id: sce.UInt32, volume: ^sce.UInt32) -> sce.Int32 --- + + /** + * Set usb audio device volume + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[in] volume - new device volume + * + * @note You should OpenDevice first to use this function + */ + SetCurrentValueOfVolume :: proc(device_id: sce.UInt32, volume: sce.UInt32) -> sce.Int32 --- + + /** + * Receive sound data from usb device + * + * @return 0 on success, < 0 on error + * + * @param[in] device_id - Device id + * @param[out] buffer - buffer for received data. Should be 0x600 bytes in size. + * + * @note You should call OpenDevice first to use this function + * @note Data is in S16_MONO format. Granularity is 768 (thus buffer is 768*2) + */ + Input :: proc(device_id: sce.UInt32, buffer: rawptr) -> sce.Int32 --- +} diff --git a/UsbAudioIn/types.odin b/UsbAudioIn/types.odin new file mode 100644 index 0000000..34298b3 --- /dev/null +++ b/UsbAudioIn/types.odin @@ -0,0 +1,36 @@ +package usbaudioin + +import "core:c" +import sce "../common" + +// TODO: +SceUsbAudioInErrorCode :: enum c.uint { + INVALID_ARGUMENT = 0x803e0001, + DUPLICATE_ID = 0x803e0002, + NO_MEMORY = 0x803e0003, + DEVICE_NOT_FOUND = 0x803e0004, + NOT_SUPPORTED = 0x803e0005, + CANNOT_GET_PORT_OWNERSHIP = 0x803e0006, + PORT_IS_ALREADY_OPENED = 0x803e0007, + PROCESS_HAS_NOT_A_DEVICE_OWNERSHIP = 0x803e0008, + FAILED_TO_READ_STREAM = 0x803e0009, + DEVICE_WAS_HALTED = 0x803e000a, + NO_DATA_TO_READ = 0x803e000b, + FAILED_TO_COPY_BUFFER = 0x803e000c, + FAILED_TO_REQUEST_ISOCHRONOUS = 0x803e000d, + TIMEOUT = 0x803e000e, + PROCESS_CANNOT_OPEN_MORE_DEVICE = 0x803e000f, +} + +SceUsbAudioInDeviceInfo :: struct { + vendor: c.uint16_t, + product: c.uint16_t, + _reserved: [5]sce.UInt32, +} +#assert(size_of(SceUsbAudioInDeviceInfo) == 0x18) + +SceUsbAudioInDeviceListItem :: struct { + device_id: sce.UInt32, +} +#assert(size_of(SceUsbAudioInDeviceListItem) == 4) + diff --git a/UsbSerial/UsbSerial.odin b/UsbSerial/UsbSerial.odin new file mode 100644 index 0000000..cbcdeea --- /dev/null +++ b/UsbSerial/UsbSerial.odin @@ -0,0 +1,78 @@ +package usbserial + +import "core:c" + +foreign import usbserial "system:SceUsbSerial_stub" + +@(link_prefix = "sceUsbSerial") +foreign usbserial { + /** + * Activate USB serial device + * + * @return 0 on success, < 0 on error + * + * @note The user is responsible for making sure no other UDC driver is active. This activates UDC as a "PS Vita" Type D device. + * + * @note Wrapper for kernel function StartForDriver() + */ + Start :: proc() -> c.int --- + + /** + * Setup USB serial device + * + * @return 0 on success, < 0 on error + * + * @param unk Unknown + * + * @note Wrapper for kernel function SetupForDriver() + */ + Setup :: proc(unk: c.int) -> c.int --- + + /** + * Close USB serial device + * + * @note Wrapper for kernel function CloseForDriver() + */ + Close :: proc() -> c.int --- + + /** + * Close USB serial device + * + * @return Returns 1 when serial port is open + * + * @note Wrapper for kernel function StatusForDriver() + */ + Status :: proc() -> c.int --- + + /** + * Get receive buffer length + * + * @return Returns length of USB rx buffer + * + * @note Wrapper for kernel function GetLenForDriver() + */ + GetRecvBufferSize :: proc() -> c.uint --- + + /** + * Send data + * @param[in] *buffer data to send over usb + * @param len int len of serial buffer data + * @param unk1 Unknown + * @param unk2 Unknown + * @note max send length is 0x10000 + * @note Wrapper for kernel function SendForDriver() + */ + Send :: proc(buffer: rawptr, len: c.uint, unk1: c.int, unk2: c.int) -> c.uint --- + + /** + * Receive Data + * + * @param[out] *buffer buffer for incoming data + * @param max_len max data length to receive + * @param unk1 Unknown + * @param unk2 Unknown + * @note max recv length is 0x10000 + * @note Wrapper for kernel function RecvForDriver() + */ + Recv :: proc(buffer: rawptr, max_len: c.uint, unk1: c.int, unk2: c.int) -> c.uint --- +} diff --git a/UsbServ/UsbServ.odin b/UsbServ/UsbServ.odin new file mode 100644 index 0000000..79e0682 --- /dev/null +++ b/UsbServ/UsbServ.odin @@ -0,0 +1,32 @@ +package usbserv + +import "core:c" + +foreign import usbserv "system:SceUsbServ_stub" + +// TODO: +SceUsbservErrorCode :: enum c.uint { + UNAVAILABLE = 0x80248002, + INVALID_PARAM = 0x80248003, + NOT_SUPPORTED = 0x80248004, + FATAL = 0x802480FF +} + +@(link_prefix = "sceUsbServ") +foreign usbserv { + /** + * Enable accessory port + * + * @return 0 on success, < 0 on error + * + */ + AccessoryActivate :: proc() -> c.int --- + + /** + * Disable accessory port + * + * @return 0 on success, < 0 on error + * + */ + AccessoryDeactivate :: proc() -> c.int --- +} diff --git a/UsbStor/UsbStor.odin b/UsbStor/UsbStor.odin new file mode 100644 index 0000000..d24688b --- /dev/null +++ b/UsbStor/UsbStor.odin @@ -0,0 +1,48 @@ +package usbstor + +import "core:c" + +foreign import usbstor "system:SceUsbstorVStorDriver_stub" + +SceUsbstorVstorType :: enum c.int { + FAT = 0, + CDROM = 5 +} + +@(link_prefix = "sceUsbstorVStor") +foreign usbstor { + /** + * Set image file path + * + * @param[in] path - Image file path + * + * @return 0 on success, < 0 on error. + */ + SetImgFilePath :: proc(path: cstring) -> c.int --- + + /** + * Set USB descriptor device information + * + * @param[in] name - Name + * @param[in] version - Version + * + * @return 0 on success, < 0 on error. + */ + SetDeviceInfo :: proc(name: cstring, version: cstring) -> c.int --- + + /** + * Start USB virtual storage + * + * @param[in] type - One of ::SceUsbstorVstorType + * + * @return 0 on success, < 0 on error. + */ + Start :: proc(type: SceUsbstorVstorType) -> c.int --- + + /** + * Stop USB virtual storage + * + * @return 0 on success, < 0 on error. + */ + Stop :: proc() -> c.int --- +} diff --git a/Usbd/Usbd.odin b/Usbd/Usbd.odin new file mode 100644 index 0000000..22f2b15 --- /dev/null +++ b/Usbd/Usbd.odin @@ -0,0 +1,279 @@ +package usbd + +import "core:c" +import sce "../common" + +foreign import usbd "system:SceUsbd_stub" + +@(link_prefix = "sceUsbd") +foreign usbd { + /** + * Init usb subsystem + * + * @return 0 on success, < 0 on error + * + * @param[out] uid Pointer to uid + * + */ + Init :: proc(uid: ^sce.UID) -> c.int --- + + /** + * Stop usb subsystem + * + * @return 0 on success, < 0 on error + * + * @param uid uid + * + */ + End :: proc(uid: sce.UID) -> c.int --- + + /** + * Get usb devices list + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] num max number of devices to return (8 max) + * @param[out] info pointer to receive device info + * + */ + GetDeviceList :: proc(uid: sce.UID, num: sce.Size, info: ^SceUsbdDeviceInfo) -> c.int --- // 8 devices max + + + /** + * Get usb device descriptors data size + * + * @return size on success, < 0 on error + * + * @param uid uid + * @param device_id device id + * + */ + GetDescriptorSize :: proc(uid: sce.UID, device_id: c.uint) -> c.int --- + + /** + * Get usb device descriptors (all) + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] device_id device id + * @param[out] descriptor buffer for descriptor data + * @param[in] size buffer size + * + */ + GetDescriptor :: proc(uid: sce.UID, device_id: sce.UID, descriptor: ^c.uint, size: sce.Size) -> c.int --- + + + /** + * Get usb device speed + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] device_id device id + * @param[out] speed device speed + * + */ + GetDeviceSpeed :: proc(uid: sce.UID, device_id: sce.UID, speed: ^c.uint) -> c.int --- + + /** + * Register callback to usb event + * + * @return 0 on success, < 0 on error + * + * @param[in] cbid callback uid + * @param[in] flag if 1 - trigger events immediately + * + * @note there may be only one callback registered through whole system. + * And it's currently taken up by shell. + * + */ + RegisterCallback :: proc(cbid: sce.UID, flag: c.int) -> c.int --- + + /** + * Remove callback to usb event + * + * @return 0 on success, < 0 on error + * + * @param[in] cbid callback uid + * + * @note this checks process id + * + */ + UnregisterCallback :: proc(cbid: sce.UID) -> c.int --- + + /** + * Reset usb device + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] device_id device id + * + */ + ResetDevice :: proc(uid: sce.UID, device_id: sce.UID) -> c.int --- + + /** + * Attach specified driver to device + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] driver_id driver id (result of Register(Composite)Ldd) + * @param[in] bus usb port number + * @param[in] device usb device number + * + * @note device_id = (bus << 16) + device + */ + Attach :: proc(uid: sce.UID, driver_id: sce.UID, bus: sce.UInt, device: sce.UInt) -> c.int --- + + /** + * Get device address + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] device_id device id + * @param[out] addr buffer for return value + * + * @note it is unknown what that function actually returns in addr, observed only 0 + */ + GetDeviceAddress :: proc(uid: sce.UID, device_id: sce.UID, addr: ^SceUsbdDeviceAddress) -> c.int --- + + /** + * Get transfer status + * + * @return 0 on success, < 0 on error + * + * @param[in] transfer_id transfer uid + * @param[out] status buffer for return value + * + * @note it is unknown what that function actually returns in addr, observed only 0 + */ + GetTransferStatus :: proc(transfer_id: sce.UID, status: ^SceUsbdTransferStatus) -> c.int --- + + /** + * Get isochronous transfer status + * + * @return 0 on success, < 0 on error + * + * @param[in] transfer_id transfer uid + * @param[out] status buffer for return value + * + * @note it is unknown what that function actually returns in addr, observed only 0 + */ + GetIsochTransferStatus :: proc(transfer_id: sce.UID, status: ^SceUsbdIsochTransferStatus) -> c.int --- + + + /** + * Open endpoint communication pipe + * + * @return pipe_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] pipe endpoint to open + * + */ + OpenPipe :: proc(uid: sce.UID, pipe: ^SceUsbdDevicePipe) -> sce.UID --- + + /** + * Open endpoint communication pipe for default config endpoint + * + * @return pipe_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] device_id device id + * + */ + OpenDefaultPipe :: proc(uid: sce.UID, device_id: sce.UID) -> sce.UID --- + + /** + * Close endpoint communication pipe + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] pipe_id pipe uid + * + */ + ClosePipe :: proc(uid: sce.UID, pipe_id: sce.UID) -> c.int --- + + /** + * Transfer data to/from endpoint + * + * @return transfer_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] data data to transfer + * + */ + TransferData :: proc(uid: sce.UID, data: ^SceUsbdTransferData) -> sce.UID --- + + /** + * Transfer data to/from endpoint isochronously + * + * @return transfer_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] pipe_id pipe uid + * @param[in] transfer data to transfer + * + */ + IsochTransferData :: proc(uid: sce.UID, pipe_id: sce.UID, transfer: ^SceUsbdIsochTransfer) -> c.int --- + + /** + * Receive usb event + * + * @return transfer_id on success, < 0 on error + * + * @param[in] uid uid + * @param[out] event + * + */ + ReceiveEvent :: proc(uid: sce.UID, event: ^SceUsbdReceiveEvent) -> c.int --- + + /** + * Register logical device driver + * + * @return driver_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] name driver name, 255 max + * + */ + RegisterLdd :: proc(uid: sce.UID, name: cstring) -> sce.UID --- + + /** + * Register logical device driver for composite devices + * + * @return driver_id on success, < 0 on error + * + * @param[in] uid uid + * @param[in] name driver name, 255 max + * + */ + RegisterCompositeLdd :: proc(uid: sce.UID, name: cstring) -> sce.UID --- + + /** + * De-register logical device driver + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] name driver name, 255 max + * + */ + UnregisterLdd :: proc(uid: sce.UID, name: cstring) -> c.int --- + + /** + * Attach composite driver to device + * + * @return 0 on success, < 0 on error + * + * @param[in] uid uid + * @param[in] param parameters + * + */ + AttachCompositeLdd :: proc(uid: sce.UID, param: ^SceUsbdAttachCompositeParam) -> c.int --- +} diff --git a/Usbd/types.odin b/Usbd/types.odin new file mode 100644 index 0000000..d4b5e54 --- /dev/null +++ b/Usbd/types.odin @@ -0,0 +1,243 @@ +package usbd + +import "core:c" + +SCE_USBD_CLASS_PER_INTERFACE :: 0x00 +SCE_USBD_CLASS_AUDIO :: 0x01 +SCE_USBD_CLASS_COMMUNICATIONS :: 0x02 +SCE_USBD_CLASS_HID :: 0x03 +SCE_USBD_CLASS_MONITOR :: 0x04 +SCE_USBD_CLASS_PHYSICAL :: 0x05 +SCE_USBD_CLASS_POWER :: 0x06 +SCE_USBD_CLASS_PRINTER :: 0x07 +SCE_USBD_CLASS_STORAGE :: 0x08 +SCE_USBD_CLASS_HUB :: 0x09 +SCE_USBD_CLASS_DATA :: 0x0a +SCE_USBD_CLASS_VENDOR_SPECIFIC :: 0xff + +SCE_USBD_CONFIGURATION_RESERVED_ZERO :: 0x1f +SCE_USBD_CONFIGURATION_REMOTE_WAKEUP :: 0x20 +SCE_USBD_CONFIGURATION_SELF_POWERED :: 0x40 +SCE_USBD_CONFIGURATION_RESERVED_ONE :: 0x80 + +/* bmAttributes */ +SCE_USBD_ENDPOINT_TRANSFER_TYPE_BITS :: 0x03 +SCE_USBD_ENDPOINT_TRANSFER_TYPE_SHIFT :: 0 +SCE_USBD_ENDPOINT_TRANSFER_TYPE_CONTROL :: 0x00 + +SCE_USBD_ENDPOINT_TRANSFER_TYPE_ISOCHRONOUS :: 0x01 +SCE_USBD_ENDPOINT_TRANSFER_TYPE_BULK :: 0x02 +SCE_USBD_ENDPOINT_TRANSFER_TYPE_INTERRUPT :: 0x03 + +/* bEndpointAddress */ +SCE_USBD_ENDPOINT_NUMBER_BITS :: 0x1f +SCE_USBD_ENDPOINT_NUMBER_SHIFT :: 0 +SCE_USBD_ENDPOINT_DIRECTION_BITS :: 0x80 +SCE_USBD_ENDPOINT_DIRECTION_SHIFT :: 7 +SCE_USBD_ENDPOINT_DIRECTION_OUT :: 0x00 +SCE_USBD_ENDPOINT_DIRECTION_IN :: 0x80 + +USB_DESCRIPTOR_DEVICE :: 0x01 // bDescriptorType for a Device Descriptor. +USB_DESCRIPTOR_CONFIGURATION :: 0x02 // bDescriptorType for a Configuration Descriptor. +USB_DESCRIPTOR_STRING :: 0x03 // bDescriptorType for a String Descriptor. +USB_DESCRIPTOR_INTERFACE :: 0x04 // bDescriptorType for an Interface Descriptor. +USB_DESCRIPTOR_ENDPOINT :: 0x05 // bDescriptorType for an Endpoint Descriptor. + +USB_DESCRIPTOR_DEVICE_QUALIFIER :: 0x06 // bDescriptorType for a Device Qualifier. +USB_DESCRIPTOR_OTHER_SPEED :: 0x07 // bDescriptorType for a Other Speed Configuration. +USB_DESCRIPTOR_INTERFACE_POWER :: 0x08 // bDescriptorType for Interface Power. +USB_DESCRIPTOR_OTG :: 0x09 // bDescriptorType for an OTG Descriptor. + +SCE_USBD_DEVICE_SPEED_LS :: 0 +SCE_USBD_DEVICE_SPEED_FS :: 1 +SCE_USBD_DEVICE_SPEED_HS :: 2 + +// TODO: +SceUsbdErrorCode :: enum c.uint { + ERROR_NOT_INITIALIZED = 0x80240001, + ERROR_ALREADY_INITIALIZED = 0x80240002, + ERROR_INVALID_PARAM = 0x80240003, + ERROR_PIPE_NOT_FOUND = 0x80240004, + ERROR_NO_MEMORY = 0x80240005, + ERROR_DEVICE_NOT_FOUND = 0x80240006, + ERROR_80240007 = 0x80240007, + ERROR_80240009 = 0x80240009, + ERROR_8024000A = 0x8024000A, + ERROR_FATAL = 0x802400FF +} + +SceUsbdDescriptorType :: enum c.int { + DEVICE = 0x01, // bDescriptorType for a Device Descriptor. + CONFIGURATION = 0x02, // bDescriptorType for a Configuration Descriptor. + STRING = 0x03, // bDescriptorType for a String Descriptor. + INTERFACE = 0x04, // bDescriptorType for an Interface Descriptor. + ENDPOINT = 0x05, // bDescriptorType for an Endpoint Descriptor. + + DEVICE_QUALIFIER = 0x06, // bDescriptorType for a Device Qualifier. + OTHER_SPEED = 0x07, // bDescriptorType for a Other Speed Configuration. + INTERFACE_POWER = 0x08, // bDescriptorType for Interface Power. + OTG = 0x09, // bDescriptorType for an OTG Descriptor. + HID = 0x21, // bDescriptorType for an HID descriptor. + REPORT = 0x22 // bDescriptorType for an HID report descriptor. +} + +SceUsbdDeviceDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + bcdUSB: c.uint16_t, + bDeviceClass: c.uint8_t, + bDeviceSubclass: c.uint8_t, + bDeviceProtocol: c.uint8_t, + bMaxPacketSize0: c.uint8_t, + idVendor: c.uint16_t, + idProduct: c.uint16_t, + bcdDevice: c.uint16_t, + iManufacturer: c.uint8_t, + iProduct: c.uint8_t, + iSerialNumber: c.uint8_t, + bNumConfigurations: c.uint8_t, +} +#assert(size_of(SceUsbdDeviceDescriptor) == 0x12) + +SceUsbdConfigurationDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + wTotalLength: c.uint16_t, + bNumInterfaces: c.uint8_t, + bConfigurationValue: c.uint8_t, + iConfiguration: c.uint8_t, + bmAttributes: c.uint8_t, + MaxPower: c.uint8_t, +} +#assert(size_of(SceUsbdConfigurationDescriptor) == 0xA) + +SceUsbdInterfaceDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + bInterfaceNumber: c.uint8_t, + bAlternateSetting: c.uint8_t, + bNumEndpoints: c.uint8_t, + bInterfaceClass: c.uint8_t, + bInterfaceSubclass: c.uint8_t, + bInterfaceProtocol: c.uint8_t, + iInterface: c.uint8_t, +} +#assert(size_of(SceUsbdInterfaceDescriptor) == 9) + +SceUsbdEndpointDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + bEndpointAddress: c.uint8_t, + bmAttributes: c.uint8_t, + wMaxPacketSize: c.uint16_t, + bInterval: c.uint8_t, +} +#assert(size_of(SceUsbdEndpointDescriptor) == 8) + +SceUsbdStringDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + bString: [0]c.uint8_t, +} +#assert(size_of(SceUsbdStringDescriptor) == 2) + +SceUsbdHidSubDescriptorInfo :: struct { + bDescriptorType: c.uint8_t, + wDescriptorLength0: c.uint8_t, + wDescriptorLength1: c.uint8_t, +} +#assert(size_of(SceUsbdHidSubDescriptorInfo) == 3) + +SceUsbdHidDescriptor :: struct { + bLength: c.uint8_t, + bDescriptorType: c.uint8_t, + bcdHID0: c.uint8_t, + bcdHID1: c.uint8_t, + bCountryCode: c.uint8_t, + bNumDescriptors: c.uint8_t, /* SubDescriptor count */ + SubDescriptorInfo: [0]SceUsbdHidSubDescriptorInfo, +} +#assert(size_of(SceUsbdHidDescriptor) == 6) + +SceUsbdDeviceAddress :: struct #packed { + unk0: c.uint, + unk1: c.ushort, +} +#assert(size_of(SceUsbdDeviceAddress) == 6) + + +SceUsbdDeviceInfo :: struct { + port: c.uint, + device_num: c.uint, + unk3: c.uint, // handled? 0, 1, 2 +} +#assert(size_of(SceUsbdDeviceInfo) == 0xC) + +SceUsbdTransferData :: struct { + pipe: c.uint, // 0x00 + data: rawptr, // 0x04 + data_size: c.uint, // 0x08 + transferred: rawptr, // // 0x0C // ptr to 8 bytes? + timeout: c.uint, // 0x10 // size of above ptr? only 8 allowed? +} + +SceUsbdReceiveEvent :: struct { + unk0: c.uint, // 0 + unk1: c.uint, // next ptr? + unk2: c.uint, // != 8, set to 1, 2, 4? // transfer flags? type? + unk3: c.uint, + unk4: c.uint, + unk5: c.uint, + transfer_id: c.uint, +} +#assert(size_of(SceUsbdReceiveEvent) == 0x1C) + +SceUsbdAttachCompositeParam :: struct { + driver_id: c.uint32_t, + bus: c.uint32_t, + device: c.uint32_t, + unk3: c.uint32_t, // num devices? + unk4: c.uint32_t, +} +#assert(size_of(SceUsbdAttachCompositeParam) == 0x14) + +SceUsbdIsochTransfer :: struct { + unk0: c.uint, // array of num_packets? ptrs to 4 + unk1: c.uint, // num packets? + unk2: c.uint, + unk3: c.uint, + + unk4: c.uint, + unk5: c.uint, + unk6: c.uint, + unk7: c.uint, + + unk8: c.uint, + unk9: c.uint, +} +#assert(size_of(SceUsbdIsochTransfer) == 0x28) + +SceUsbdDevicePipe :: struct { + device_id: c.uint, + unk1: c.uint, + unk2: c.uint, + unk3: c.uint, + unk4: c.uint, + unk5: c.uint, +} +#assert(size_of(SceUsbdDevicePipe) == 0x18) + +SceUsbdTransferStatus :: struct { + unk0: c.uint32_t, // < 0x40 - transfer id (result of sceUsbdTransferData) + unk1: c.uint32_t, // unused + unk2: c.uint32_t, // ret 4. ptr? // status? + unk3: c.uint32_t, // ret 4. ptr? // transferred? +} +#assert(size_of(SceUsbdTransferStatus) == 0x10) + +SceUsbdIsochTransferStatus :: struct { + unk0: c.uint32_t, // < 0x40 - size? pipe? transfer id? + unk1: c.uint32_t, // unused + unk2: ^c.uintptr_t, // ret up to 0x28 buff. 10 * 4 bytes. or 8*5 bytes + unk3: c.uint32_t, // ret 4. ptr? +} diff --git a/VideoExport/VideoExport.odin b/VideoExport/VideoExport.odin new file mode 100644 index 0000000..53a5675 --- /dev/null +++ b/VideoExport/VideoExport.odin @@ -0,0 +1,44 @@ +package videoexport + +import "core:c" + +foreign import videoexport "system:SceVideoExport_stub" + +VideoExportInputParam :: struct { + path: [1024]c.char, //!< Path of file to be exported + reserved: [64]c.char, //!< Reserved data +} +#assert(size_of(VideoExportInputParam) == 0x440) + +VideoExportOutputParam :: struct { + path: [1024]c.char, //!< Path of exported file + reserved: [8]c.char, //!< Reserved data +} +#assert(size_of(VideoExportOutputParam) == 0x408) + +@(link_prefix = "sceVideoExport") +foreign videoexport { + /** + * Export video file + * + * @param[in] in_param - Input param + * @param[in] unk - Unknown, pass 1 + * @param[in] workingMemory - Working memory + * @param[in] cancelCb - Cancel callback + * @param[in] progress - Progress callback + * @param[in] user - User data passed to the callbacks + * @param[in] unk2 - Unknown, pass 0 + * @param[out] out_param - Output param + * + * @return 0 on success, < 0 on error. + */ + FromFile :: proc( + #by_ptr in_param: VideoExportInputParam, + unk: c.int, + workingMemory: rawptr, + cancelCb: rawptr, + progress: #type ^proc "c" (_: rawptr, __: c.int), + user: rawptr, + unk2: c.int, + out_param: ^VideoExportOutputParam) -> c.int --- +} diff --git a/Videodec/Videodec.odin b/Videodec/Videodec.odin new file mode 100644 index 0000000..8017af8 --- /dev/null +++ b/Videodec/Videodec.odin @@ -0,0 +1,57 @@ +package videodec + +import "core:c" + +foreign import videodec "system:SceVideodec_stub" + +foreign videodec { + /** + * @param[in] codec - See ::SceVideodecType + * @param[in] initInfo - See ::SceVideodecQueryInitInfoHwAvcdec + * + * @return 0 on success, < 0 on error. + */ + sceVideodecInitLibrary :: proc(codec: SceVideodecType, #by_ptr initInfo: SceVideodecQueryInitInfoHwAvcdec) -> c.int --- + + /** + * @param[in] codec - See ::SceVideodecType + * + * @return 0 on success, < 0 on error. + */ + sceVideodecTermLibrary :: proc(codec: SceVideodecType) -> c.int --- + + /** + * @param[in] codec - See ::SceVideodecType + * @param[in] query - Should be copy from ::SceVideodecQueryInitInfoHwAvcdec. + * @param[out] decoderInfo - Must be initialized with zeros. + * + * @return 0 on success, < 0 on error. + */ + sceAvcdecQueryDecoderMemSize :: proc(codec: SceVideodecType, #by_ptr query: SceAvcdecQueryDecoderInfo, decoderInfo: ^SceAvcdecDecoderInfo) -> c.int --- + + /** + * @param[in] codec - See ::SceVideodecType + * @param[out] decoder - Must be initialized frameBuf.size and frameBuf.pBuf + * @param[in] query - Should be copy from ::SceVideodecQueryInitInfoHwAvcdec. + * + * @return 0 on success, < 0 on error. + */ + sceAvcdecCreateDecoder :: proc(codec: SceVideodecType, decoder: ^SceAvcdecCtrl, #by_ptr query: SceAvcdecQueryDecoderInfo) -> c.int --- + + /** + * @param[in] decoder - A ::SceAvcdecCtrl decoder initialized with ::sceAvcdecCreateDecoder + * + * @return 0 on success, < 0 on error. + */ + sceAvcdecDeleteDecoder :: proc(decoder: ^SceAvcdecCtrl) -> c.int --- + + /** + * @param[in] decoder + * @param[in] au - Must set buffer information(es) and be initialized timestamps with 0xFFFFFFFF + * @param[out] array_picture - Must set numOfElm and pPicture. See ::SceAvcdecArrayPicture + * + * @return 0 on success, < 0 on error. + */ + sceAvcdecDecode :: proc(#by_ptr decoder: SceAvcdecCtrl, #by_ptr au: SceAvcdecAu, array_picture: [^]SceAvcdecArrayPicture) -> c.int --- +} + diff --git a/Videodec/types.odin b/Videodec/types.odin new file mode 100644 index 0000000..f5cc6c3 --- /dev/null +++ b/Videodec/types.odin @@ -0,0 +1,167 @@ +package videodec + +import "core:c" + +// TODO: +SceVideodecErrorCode :: enum c.uint { + INVALID_TYPE = 0x80620801, + INVALID_PARAM = 0x80620802, + OUT_OF_MEMORY = 0x80620803, + INVALID_STATE = 0x80620804, + UNSUPPORT_IMAGE_SIZE = 0x80620805, + INVALID_COLOR_FORMAT = 0x80620806, + NOT_PHY_CONTINUOUS_MEMORY = 0x80620807, + ALREADY_USED = 0x80620808, + INVALID_POINTER = 0x80620809, + ES_BUFFER_FULL = 0x8062080A, + INITIALIZE = 0x8062080B, + NOT_INITIALIZE = 0x8062080C, + INVALID_STREAM = 0x8062080D, + INVALID_ARGUMENT_SIZE = 0x8062080E +} + +SceVideodecType :: enum c.int { + HW_AVCDEC = 0x1001 +} + +// TODO: +SceAvcdecErrorCode :: enum c.uint { + INVALID_TYPE = 0x80620001, + INVALID_PARAM = 0x80620002, + OUT_OF_MEMORY = 0x80620003, + INVALID_STATE = 0x80620004, + UNSUPPORT_IMAGE_SIZE = 0x80620005, + INVALID_COLOR_FORMAT = 0x80620006, + NOT_PHY_CONTINUOUS_MEMORY = 0x80620007, + ALREADY_USED = 0x80620008, + INVALID_POINTER = 0x80620009, + ES_BUFFER_FULL = 0x8062000A, + INITIALIZE = 0x8062000B, + NOT_INITIALIZE = 0x8062000C, + INVALID_STREAM = 0x8062000D, + INVALID_ARGUMENT_SIZE = 0x8062000E +} + +SceAvcdecPixelFormat :: enum c.int { + RGBA8888 = 0x00, + RGBA565 = 0x01, + RGBA5551 = 0x02, + YUV420_RASTER = 0x10, + YUV420_PACKED_RASTER = 0x20 +} + +SceVideodecQueryInitInfoHwAvcdec :: struct { + size: c.uint32_t, //!< sizeof(SceVideodecQueryInitInfoHwAvcdec) + horizontal: c.uint32_t, + vertical: c.uint32_t, + numOfRefFrames: c.uint32_t, //!< Number of reference frames to use + numOfStreams: c.uint32_t, //!< Must be set to 1 +} +#assert(size_of(SceVideodecQueryInitInfoHwAvcdec) == 0x14) + +SceVideodecQueryInitInfo :: struct #raw_union { + reserved: [32]c.uint8_t, + hwAvc: SceVideodecQueryInitInfoHwAvcdec, +} +#assert(size_of(SceVideodecQueryInitInfo) == 0x20) + +SceVideodecTimeStamp :: struct { + upper: c.uint32_t, + lower: c.uint32_t, +} +#assert(size_of(SceVideodecTimeStamp) == 8) + +SceAvcdecQueryDecoderInfo :: struct { + horizontal: c.uint32_t, + vertical: c.uint32_t, + numOfRefFrames: c.uint32_t, //!< Number of reference frames +} +#assert(size_of(SceAvcdecQueryDecoderInfo) == 0xC) + +SceAvcdecDecoderInfo :: struct { + frameMemSize: c.uint32_t, +} +#assert(size_of(SceAvcdecDecoderInfo) == 4) + +SceAvcdecBuf :: struct { + pBuf: rawptr, + size: c.uint32_t, +} + +SceAvcdecCtrl :: struct { + handle: c.uint32_t, + frameBuf: SceAvcdecBuf, +} + +SceAvcdecAu :: struct { + pts: SceVideodecTimeStamp, + dts: SceVideodecTimeStamp, + es: SceAvcdecBuf, +} + +SceAvcdecInfo :: struct { + numUnitsInTick: c.uint32_t, + timeScale: c.uint32_t, + fixedFrameRateFlag: c.uint8_t, + + aspectRatioIdc: c.uint8_t, + sarWidth: c.uint16_t, + sarHeight: c.uint16_t, + + colourPrimaries: c.uint8_t, + transferCharacteristics: c.uint8_t, + matrixCoefficients: c.uint8_t, + + videoFullRangeFlag: c.uint8_t, + + picStruct: [2]c.uint8_t, + ctType: c.uint8_t, + + pts: SceVideodecTimeStamp, +} +#assert(size_of(SceAvcdecInfo) == 0x20) + +SceAvcdecFrameOptionRGBA :: struct { + alpha: c.uint8_t, + cscCoefficient: c.uint8_t, + reserved: [14]c.uint8_t, +} +#assert(size_of(SceAvcdecFrameOptionRGBA) == 0x10) + +SceAvcdecFrameOption :: struct #raw_union { + reserved: [16]c.uint8_t, + rgba: SceAvcdecFrameOptionRGBA, +} +#assert(size_of(SceAvcdecFrameOption) == 0x10) + +SceAvcdecFrame :: struct { + pixelType: c.uint32_t, //!< One of ::SceAvcdecPixelFormat + framePitch: c.uint32_t, + frameWidth: c.uint32_t, + frameHeight: c.uint32_t, + + horizontalSize: c.uint32_t, + verticalSize: c.uint32_t, + + frameCropLeftOffset: c.uint32_t, + frameCropRightOffset: c.uint32_t, + frameCropTopOffset: c.uint32_t, + frameCropBottomOffset: c.uint32_t, + + opt: SceAvcdecFrameOption, + + pPicture: [2]rawptr, //!< address of picture buffer +} + +SceAvcdecPicture :: struct { + size: c.uint32_t, + frame: SceAvcdecFrame, + info: SceAvcdecInfo, +} + +SceAvcdecArrayPicture :: struct { + numOfOutput: c.uint32_t, //!< Number of outputs + numOfElm: c.uint32_t, //!< Number of elements + pPicture: ^^SceAvcdecPicture, +} + diff --git a/VshBridge/VshBridge.odin b/VshBridge/VshBridge.odin new file mode 100644 index 0000000..059021f --- /dev/null +++ b/VshBridge/VshBridge.odin @@ -0,0 +1,190 @@ +package vshbridge + +import "core:c" +import sce "../common" +import sceKernel "../Kernel" + +foreign import vshbridge "system:SceVshBridge_stub" + +foreign vshbridge { + /** + * Gets real system firmware information. + * + * @param[out] data - firmware information. + */ + _vshSblGetSystemSwVersion :: proc(data: ^sceKernel.SceKernelFwInfo) -> c.int --- + + /** + * @brief Get service/manufacturing information (factory/minimum firmware). + * + * @param[out] info - The info output pointer + * + * @return 0 on success, < 0 on error. + */ + _vshSblAimgrGetSMI :: proc(info: ^sce.UInt32) -> c.int --- + + _vshSblAimgrGetConsoleId :: proc(CID: [32]c.char) -> c.int --- + + /** + * @brief Check if a module is loaded. + * + * @param[in] module_name - The module's name + * @param[in] buffer - Set a buffer with a size of 8 bytes + * + * @return the SceUID of the module on success, < 0 on error. + */ + _vshKernelSearchModuleByName :: proc(module_name: cstring, buffer: rawptr) -> sce.UID --- + + /** + * @param[in] id - mount id + * @param[in] path - mount path + * @param[in] permission - 1/RO 2/RW + * @param[in] buf - work buffer + * + * @return 0 >= on success, < 0 on error. + */ + _vshIoMount :: proc(id: c.int, path: cstring, permission: c.int, buf: rawptr) -> c.int --- + + + /** + * @param[in] id - mount id + * @param[in] force - Set to 1 to force umount + * @param[in] unk2 - Unknown, set 0 + * @param[in] unk3 - Unknown, set 0 + * + * @return 0 >= on success, < 0 on error. + */ + vshIoUmount :: proc(id: c.int, force: c.int, unk2: c.int, unk3: c.int) -> c.int --- + + vshIdStorageIsDirty :: proc() -> c.int --- + vshIdStorageIsFormatted :: proc() -> c.int --- + vshIdStorageIsReadOnly :: proc() -> c.int --- + + /** + * @param[in] leafnum - The read target leaf number + * @param[out] buf - The leaf data buffer pointer, size is 512 byte + * + * @return 0 on success, < 0 on error. + */ + vshIdStorageReadLeaf :: proc(leafnum: sce.Size, buf: rawptr) -> c.int --- + + /** + * @param[in] leafnum - The write target leaf number + * @param[in] buf - The leaf data buffer pointer, size is 512 byte + * + * @return 0 on success, < 0 on error. + * + * note - Writing to leaf requires manufacturing mode. + */ + vshIdStorageWriteLeaf :: proc(leafnum: sce.Size, buf: rawptr) -> c.int --- + + /** + * Verify a eboot.pbp signature "__sce_ebootpbp" + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] eboot_signature - The pointer of data of __sce_ebootpbp signature. size is 0x200 + * @param[in] eboot_signature_magic - The pointer of a pointer of magic number within __sce_ebootpbp, "NPUMDSIG" or "PSISOSIG" + * + * @return 0 on success, < 0 on error. + */ + _vshNpDrmEbootSigVerify :: proc(eboot_pbp_path: cstring, eboot_signature: cstring, eboot_signature_header: ^cstring) -> c.int --- + + /** + * Verify an older 0x100 byte eboot.pbp signature "__sce_ebootpbp" from firmware <2.00 + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] eboot_signature - The pointer of data of __sce_ebootpbp signature. size is 0x100 + * @param[in] eboot_signature_magic - The pointer of a pointer of magic number within __sce_ebootpbp, "NPUMDSIG" or "PSISOSIG" + * + * @return 0 on success, < 0 on error. + */ + _vshNpDrmPspEbootVerify :: proc(eboot_pbp_path: cstring, eboot_signature: cstring, eboot_signature_header: ^cstring) -> c.int --- + + /** + * Generate an older 0x100 byte eboot.pbp signature "__sce_ebootpbp" for a PSP game - this is unused in firmware >2.00 + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] eboot_sha256 - The pointer of SHA256 hash of first (data.psar offset + 0x1C0000) bytes into the EBOOT.PBP file + * @param[out] eboot_signature - The pointer of the output eboot signature data. size is 0x100 + * + * @return eboot_signature size on success, < 0 on error. + */ + _vshNpDrmPspEbootSigGen :: proc(eboot_pbp_path: cstring, eboot_sha256: rawptr, eboot_signature: rawptr) -> c.int --- + + /** + * Convert an older 0x100 byte eboot.pbp signature "__sce_ebootpbp" to a 0x200 byte one used in firmwares >2.00 + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] old_eboot_signature - The pointer of old eboot signature data. size is 0x100 + * @param[out] new_eboot_signature - The pointer of new eboot signature data. size is 0x200 + * + * @return eboot_signature size on success, < 0 on error. + */ + _vshNpDrmEbootSigConvert :: proc(eboot_pbp_path: cstring, old_eboot_signature: rawptr, new_eboot_signature: rawptr) -> c.int --- + + + /** + * Generate eboot.pbp signature "__sce_ebootpbp" for a PSP game + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] eboot_sha256 - The pointer of SHA256 hash of first (data.psar offset + 0x1C0000) bytes into the EBOOT.PBP file + * @param[out] eboot_signature - The pointer of the output eboot signature data. size is 0x200 + * @param[in] sw_version - The pointer of the minimum firmware version the signature can be used on. cannot be lower than current firmware + * + * @return eboot_signature size on success, < 0 on error. + */ + _vshNpDrmEbootSigGenPsp :: proc(eboot_pbp_path: cstring, eboot_sha256: rawptr, eboot_signature: rawptr, sw_version: ^c.int) -> c.int --- + + + /** + * Generate eboot.pbp signature "__sce_ebootpbp" for a single-disc PS1 game + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] eboot_sha256 - The pointer of SHA256 hash of first (data.psar offset + 0x1C0000) bytes into the EBOOT.PBP file + * @param[out] eboot_signature - The pointer of the output eboot signature data. size is 0x200 + * @param[in] sw_version - The pointer of the minimum firmware version the signature can be used on. cannot be lower than current firmware + * + * @return eboot_signature size on success, < 0 on error. + */ + _vshNpDrmEbootSigGenPs1 :: proc(eboot_pbp_path: cstring, eboot_sha256: rawptr, eboot_signature: rawptr, sw_version: ^c.int) -> c.int --- + + /** + * Generate eboot.pbp signature "__sce_discinfo" for a multi-disc PS1 game + * + * @param[in] eboot_pbp_path - The pointer of the file path of the EBOOT.PBP file + * @param[in] sce_discinfo - The pointer of contents of vs0:/app/NPXS10028/__sce_discinfo + * @param[out] eboot_signature - The pointer of the output eboot signature data. size is 0x100 + * @param[in] sw_version - The pointer of the minimum firmware version the signature can be used on. cannot be lower than current firmware + * + * @return eboot_signature size on success, < 0 on error. + */ + _vshNpDrmEbootSigGenMultiDisc :: proc(eboot_pbp_path: cstring, sce_discinfo: rawptr, eboot_signature: rawptr, sw_version: ^c.int) -> c.int --- + + vshSblAimgrIsCEX :: proc() -> c.int --- + vshSblAimgrIsDEX :: proc() -> c.int --- + vshSblAimgrIsVITA :: proc() -> c.int --- + vshSblAimgrIsGenuineVITA :: proc() -> c.int --- + vshSblAimgrIsDolce :: proc() -> c.int --- + vshSblAimgrIsGenuineDolce :: proc() -> c.int --- + vshSblAimgrIsTest :: proc() -> c.int --- + vshSblAimgrIsTool :: proc() -> c.int --- + vshSblSsIsDevelopmentMode :: proc() -> c.int --- + + vshSysconHasWWAN :: proc() -> c.int --- + + vshSysconIsDownLoaderMode :: proc() -> c.int --- + vshSysconIsIduMode :: proc() -> c.int --- + vshSysconIsMCEmuCapable :: proc() -> c.int --- + vshSysconIsShowMode :: proc() -> c.int --- + + vshSysconIduModeSet :: proc() -> c.int --- + vshSysconIduModeClear :: proc() -> c.int --- + + vshSysconShowModeSet :: proc() -> c.int --- + vshSysconShowModeClear :: proc() -> c.int --- + + vshMemoryCardGetCardInsertState :: proc() -> c.int --- + vshRemovableMemoryGetCardInsertState :: proc() -> c.int --- + + vshMsifGetMsInfo :: proc(info: ^sce.MsInfo) -> c.int --- +} diff --git a/common/types.odin b/common/types.odin new file mode 100644 index 0000000..c9445ab --- /dev/null +++ b/common/types.odin @@ -0,0 +1,254 @@ +package sce + +import "core:c" + +PSP2_SDK_VERSION :: 0x03570011 + +SCE_KERNEL_THREAD_ID_SELF :: 0 //!< Current thread's UID - pass to APIs expecting a thread ID to operate on calling thread +SCE_KERNEL_PROCESS_ID_SELF :: 0 //!< Current process's UID - pass to APIs expecting a process ID to operate on calling process +SCE_UID_NAMELEN :: 31 //!< Maximum length for kernel object names + +UID :: distinct c.int +PID :: distinct c.int +NID :: distinct c.uint + +Size :: distinct c.uint +SSize :: distinct c.int + +Bool :: c.int +Char8 :: c.int8_t +UChar8 :: c.int8_t +Int :: c.int +UInt :: c.uint +Int8 :: c.int8_t +UInt8 :: c.uint8_t +Int16 :: c.int16_t +UInt16 :: c.uint16_t +Int32 :: c.int32_t +UInt32 :: c.uint32_t +Int64 :: c.int64_t +UInt64 :: c.uint64_t + +UShort16 :: c.uint16_t +Long64 :: c.int64_t +ULong64 :: c.uint64_t + +Float :: c.float +Float32 :: c.float +Double :: c.double +Double64 :: c.double + +WChar16 :: c.uint16_t +WChar32 :: c.uint32_t + +IntPtr :: distinct c.int +UIntPtr :: distinct c.uint +UIntVAddr :: UIntPtr + +PVoid :: rawptr + +Mode :: distinct c.int +Off :: Int64 +KernelSysClock :: UInt64 + +DateTime :: struct { + year: c.ushort, + month: c.ushort, + day: c.ushort, + hour: c.ushort, + minute: c.ushort, + second: c.ushort, + microsecond: c.uint, +} +#assert(size_of(DateTime) == 0x10) + +FVector3 :: struct { + x: Float, + y: Float, + z: Float, +} +#assert(size_of(FVector3) == 0xC) + +FVector4 :: struct { + x: Float, + y: Float, + z: Float, + w: Float, +} +#assert(size_of(FVector4) == 0x10) + +FMatrix4 :: struct { + x: FVector4, + y: FVector4, + z: FVector4, + w: FVector4, +} +#assert(size_of(FMatrix4) == 0x40) + +FQuaternion :: struct { + x: Float, + y: Float, + z: Float, + w: Float, +} +#assert(size_of(FQuaternion) == 0x10) + + +// +// system_param.h start +// + +/** System param id */ +SceSystemParamId :: enum c.int { + //!< Language settings + LANG = 1, + //!< Enter button assignment + ENTER_BUTTON, + //!< Username string + USERNAME, + //!< Date format + DATE_FORMAT, + //!< Time format + TIME_FORMAT, + //!< Time zone + TIME_ZONE, + //!< Daylight savings time (0 = Disabled, 1 = Enabled) + DAYLIGHT_SAVINGS, + //!< Max allowed value + MAX_VALUE = -1 // 0xFFFFFFFF +} + +/** Language settings */ +SceSystemParamLang :: enum c.int { + //! Japanese + JAPANESE, + //! American English + ENGLISH_US, + //! French + FRENCH, + //! Spanish + SPANISH, + //! German + G_GERMAN, + //! Italian + ITALIAN, + //! Dutch + DUTCH, + //! Portugal Portuguese + PORTUGUESE_PT, + //! Russian + RUSSIAN, + //! Korean + KOREAN, + //! Traditional Chinese + CHINESE_T, + //! Simplified Chinese + CHINESE_S, + //! Finnish + FINNISH, + //! Swedish + SWEDISH, + //! Danish + DANISH, + //! Norwegian + NORWEGIAN, + //! Polish + POLISH, + //! Brazil Portuguese + PORTUGUESE_BR, + //! British English + ENGLISH_GB, + //! Turkish + TURKISH, + //! Max allowed value + MAX_VALUE = -1 // 0xFFFFFFFF +} + +/** Assignment of enter button */ +SceSystemParamEnterButtonAssign :: enum c.int { + CIRCLE, + CROSS, + MAX_VALUE = -1 // 0xFFFFFFFF +} + +/* Username */ +SCE_SYSTEM_PARAM_USERNAME_MAXSIZE :: 17 //!< Max size of username + +/** Date display format */ +SceSystemParamDateFormat :: enum c.int { + YYYYMMDD, //!< Year/Month/Day + DDMMYYYY, //!< Day/Month/Year + MMDDYYYY //!< Month/Day/Year +} + +/** Time display format */ +SceSystemParamTimeFormat :: enum c.int { + FORMAT_12HR, //!< 12-hour clock + FORMAT_24HR //!< 24-hour clock +} + +// +// system_param.h end +// + + +// +// rtc.h start +// + +// TODO: should be c.int +RtcErrorCode :: enum c.uint { + INVALID_VALUE = 0x80251000, + INVALID_POINTER = 0x80251001, + NOT_INITIALIZED = 0x80251002, + ALREADY_REGISTERD = 0x80251003, + NOT_FOUND = 0x80251004, + BAD_PARSE = 0x80251080, + INVALID_YEAR = 0x80251081, + INVALID_MONTH = 0x80251082, + INVALID_DAY = 0x80251083, + INVALID_HOUR = 0x80251084, + INVALID_MINUTE = 0x80251085, + INVALID_SECOND = 0x80251086, + INVALID_MICROSECOND = 0x80251087 +} +#assert(size_of(RtcErrorCode) == 4) + +/* As returned by sceRtcGetDayOfWeek */ +RtcDayOfWeek :: enum c.int { + SCE_RTC_DAYOFWEEK_SUNDAY = 0, + SCE_RTC_DAYOFWEEK_MONDAY = 1, + SCE_RTC_DAYOFWEEK_TUESDAY = 2, + SCE_RTC_DAYOFWEEK_WEDNESDAY = 3, + SCE_RTC_DAYOFWEEK_THURSDAY = 4, + SCE_RTC_DAYOFWEEK_FRIDAY = 5, + SCE_RTC_DAYOFWEEK_SATURDAY = 6, + __SCE_RTC_DAYOFWEEK = -1 // 0xFFFFFFFF +} +#assert(size_of(RtcDayOfWeek) == 4) + +RtcTick :: struct { + tick: UInt64, +} +#assert(size_of(RtcTick) == 8) + +// +// rtc.h end +// + + +MsInfo :: struct { + unk_0x00: c.int, + unk_0x04: c.int, + nbytes: UInt64, + nbytes2: UInt64, + sector_size: UInt32, + unk_0x1C: c.int, + fs_offset: UInt32, + unk_0x24: UInt32, + unk_0x28: UInt32, + unk_0x2C: UInt32, + id: [0x10]UInt8, +} +#assert(size_of(MsInfo) == 0x40) + diff --git a/vita-headers b/vita-headers new file mode 160000 index 0000000..96b8721 --- /dev/null +++ b/vita-headers @@ -0,0 +1 @@ +Subproject commit 96b8721d90b2d3e0422b13129d33b46c9bfd812d