├── ICON0.PNG ├── .gitattributes ├── libs ├── lib │ ├── libopus.a │ ├── libtiff.a │ ├── libarchive.a │ ├── libglib2d.a │ ├── libintrafont.a │ ├── libopusfile.a │ ├── libpspkubridge.a │ ├── libpspusbdevice.a │ ├── libpspsystemctrl_kernel.a │ ├── libpspsystemctrl_user.a │ └── libpspusbdevice_driver.a ├── libnsgif │ ├── utils │ │ └── log.h │ ├── COPYING │ └── lzw.h ├── libnsbmp │ ├── utils │ │ └── log.h │ └── COPYING └── include │ ├── libtiff │ ├── LICENSE.md │ ├── tiffvers.h │ ├── tif_hash_set.h │ ├── tiffconf.h │ └── tif_config.h │ ├── rapidjson │ ├── internal │ │ ├── swap.h │ │ ├── clzll.h │ │ ├── strfunc.h │ │ ├── ieee754.h │ │ └── pow10.h │ ├── cursorstreamwrapper.h │ ├── ostreamwrapper.h │ ├── memorybuffer.h │ ├── memorystream.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── stringbuffer.h │ ├── istreamwrapper.h │ └── fwd.h │ ├── pspusbdevice.h │ ├── libccc.h │ ├── kubridge.h │ ├── opus │ └── opus_types.h │ └── systemctrl_se.h ├── app ├── data │ ├── ftp_icon.png │ ├── about_icon.png │ ├── battery_20.png │ ├── battery_30.png │ ├── battery_50.png │ ├── battery_60.png │ ├── battery_80.png │ ├── bg_header.png │ ├── ic_play_btn.png │ ├── sort_icon.png │ ├── battery_full.png │ ├── ftp_icon_dark.png │ ├── ic_fso_folder.png │ ├── about_icon_dark.png │ ├── dark_theme_icon.png │ ├── default_artwork.png │ ├── dev_options_icon.png │ ├── ic_fso_default.png │ ├── ic_fso_type_app.png │ ├── ic_fso_type_text.png │ ├── sort_icon_dark.png │ ├── btn_playback_pause.png │ ├── btn_playback_play.png │ ├── ic_fso_folder_dark.png │ ├── ic_fso_type_audio.png │ ├── ic_fso_type_image.png │ ├── ic_material_dialog.png │ ├── battery_20_charging.png │ ├── battery_30_charging.png │ ├── battery_50_charging.png │ ├── battery_60_charging.png │ ├── battery_80_charging.png │ ├── battery_full_charging.png │ ├── btn_playback_forward.png │ ├── btn_playback_repeat.png │ ├── btn_playback_rewind.png │ ├── btn_playback_shuffle.png │ ├── dark_theme_icon_dark.png │ ├── default_artwork_blur.png │ ├── dev_options_icon_dark.png │ ├── ic_arrow_back_normal.png │ ├── ic_fso_type_compress.png │ ├── ic_material_light_usb.png │ ├── ic_material_dialog_dark.png │ ├── ic_material_light_sdcard.png │ ├── ic_material_light_secure.png │ ├── ic_material_options_dialog.png │ ├── btn_playback_repeat_overlay.png │ ├── btn_playback_shuffle_overlay.png │ ├── ic_material_light_sdcard_dark.png │ ├── ic_material_light_secure_dark.png │ ├── ic_material_options_dialog_dark.png │ ├── ic_material_properties_dialog.png │ ├── btn_material_light_check_off_normal.png │ ├── btn_material_light_check_on_normal.png │ ├── btn_material_light_radio_off_normal.png │ ├── btn_material_light_radio_on_normal.png │ ├── btn_material_light_toggle_off_normal.png │ ├── btn_material_light_toggle_on_normal.png │ ├── ic_material_light_navigation_drawer.png │ ├── ic_material_properties_dialog_dark.png │ ├── btn_material_light_check_off_normal_dark.png │ ├── btn_material_light_check_on_normal_dark.png │ ├── btn_material_light_radio_off_normal_dark.png │ ├── btn_material_light_radio_on_normal_dark.png │ └── btn_material_light_toggle_on_normal_dark.png ├── include │ ├── screenshot.h │ ├── log.h │ ├── texteditor.h │ ├── net.h │ ├── game_launcher.h │ ├── audioplayer.h │ ├── archive_helper.h │ ├── config.h │ ├── mutex.h │ ├── g2d.h │ ├── colours.h │ ├── textures.h │ ├── kernel_functions.h │ ├── fs.h │ ├── utils.h │ ├── pspaudiolib_cm.h │ ├── gui.h │ ├── ftppsp.h │ └── audio.h ├── drivers │ └── mutex-imports.S ├── source │ ├── colours.cpp │ ├── log.cpp │ ├── kernel_functions.cpp │ ├── audio │ │ ├── wav.cpp │ │ ├── xm.cpp │ │ ├── opus.cpp │ │ └── ogg.cpp │ ├── gui │ │ ├── properties.cpp │ │ ├── delete.cpp │ │ ├── archive_helper.cpp │ │ └── imageviewer.cpp │ ├── config.cpp │ ├── main.cpp │ ├── screenshot.cpp │ ├── g2d.cpp │ ├── pspaudiolib_cm.cpp │ ├── gui.cpp │ └── audio.cpp └── Makefile ├── Makefile ├── audio_driver ├── audio_driver.c ├── exports.exp └── Makefile ├── display_driver ├── exports.exp ├── Makefile ├── sceDisplay_driver.S └── display_driver.c ├── fs_driver ├── Makefile ├── exports.exp └── fs_driver.c ├── launcher ├── source │ └── main.c └── Makefile ├── .gitignore ├── .github └── workflows │ └── c-cpp.yml └── README.MD /ICON0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/ICON0.PNG -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /libs/lib/libopus.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libopus.a -------------------------------------------------------------------------------- /libs/lib/libtiff.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libtiff.a -------------------------------------------------------------------------------- /app/data/ftp_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ftp_icon.png -------------------------------------------------------------------------------- /libs/lib/libarchive.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libarchive.a -------------------------------------------------------------------------------- /libs/lib/libglib2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libglib2d.a -------------------------------------------------------------------------------- /app/data/about_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/about_icon.png -------------------------------------------------------------------------------- /app/data/battery_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_20.png -------------------------------------------------------------------------------- /app/data/battery_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_30.png -------------------------------------------------------------------------------- /app/data/battery_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_50.png -------------------------------------------------------------------------------- /app/data/battery_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_60.png -------------------------------------------------------------------------------- /app/data/battery_80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_80.png -------------------------------------------------------------------------------- /app/data/bg_header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/bg_header.png -------------------------------------------------------------------------------- /app/data/ic_play_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_play_btn.png -------------------------------------------------------------------------------- /app/data/sort_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/sort_icon.png -------------------------------------------------------------------------------- /app/include/screenshot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Screenshot { 4 | int Capture(void); 5 | } 6 | -------------------------------------------------------------------------------- /libs/lib/libintrafont.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libintrafont.a -------------------------------------------------------------------------------- /libs/lib/libopusfile.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libopusfile.a -------------------------------------------------------------------------------- /app/data/battery_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_full.png -------------------------------------------------------------------------------- /app/data/ftp_icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ftp_icon_dark.png -------------------------------------------------------------------------------- /app/data/ic_fso_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_folder.png -------------------------------------------------------------------------------- /app/include/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Log { 4 | int Error(const char *format, ...); 5 | } 6 | -------------------------------------------------------------------------------- /libs/lib/libpspkubridge.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libpspkubridge.a -------------------------------------------------------------------------------- /libs/lib/libpspusbdevice.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libpspusbdevice.a -------------------------------------------------------------------------------- /app/data/about_icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/about_icon_dark.png -------------------------------------------------------------------------------- /app/data/dark_theme_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/dark_theme_icon.png -------------------------------------------------------------------------------- /app/data/default_artwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/default_artwork.png -------------------------------------------------------------------------------- /app/data/dev_options_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/dev_options_icon.png -------------------------------------------------------------------------------- /app/data/ic_fso_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_default.png -------------------------------------------------------------------------------- /app/data/ic_fso_type_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_type_app.png -------------------------------------------------------------------------------- /app/data/ic_fso_type_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_type_text.png -------------------------------------------------------------------------------- /app/data/sort_icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/sort_icon_dark.png -------------------------------------------------------------------------------- /app/data/btn_playback_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_pause.png -------------------------------------------------------------------------------- /app/data/btn_playback_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_play.png -------------------------------------------------------------------------------- /app/data/ic_fso_folder_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_folder_dark.png -------------------------------------------------------------------------------- /app/data/ic_fso_type_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_type_audio.png -------------------------------------------------------------------------------- /app/data/ic_fso_type_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_type_image.png -------------------------------------------------------------------------------- /app/data/ic_material_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_dialog.png -------------------------------------------------------------------------------- /app/include/texteditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace TextViewer { 4 | int Edit(const std::string &path); 5 | } 6 | -------------------------------------------------------------------------------- /app/data/battery_20_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_20_charging.png -------------------------------------------------------------------------------- /app/data/battery_30_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_30_charging.png -------------------------------------------------------------------------------- /app/data/battery_50_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_50_charging.png -------------------------------------------------------------------------------- /app/data/battery_60_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_60_charging.png -------------------------------------------------------------------------------- /app/data/battery_80_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_80_charging.png -------------------------------------------------------------------------------- /app/data/battery_full_charging.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/battery_full_charging.png -------------------------------------------------------------------------------- /app/data/btn_playback_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_forward.png -------------------------------------------------------------------------------- /app/data/btn_playback_repeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_repeat.png -------------------------------------------------------------------------------- /app/data/btn_playback_rewind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_rewind.png -------------------------------------------------------------------------------- /app/data/btn_playback_shuffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_shuffle.png -------------------------------------------------------------------------------- /app/data/dark_theme_icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/dark_theme_icon_dark.png -------------------------------------------------------------------------------- /app/data/default_artwork_blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/default_artwork_blur.png -------------------------------------------------------------------------------- /app/data/dev_options_icon_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/dev_options_icon_dark.png -------------------------------------------------------------------------------- /app/data/ic_arrow_back_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_arrow_back_normal.png -------------------------------------------------------------------------------- /app/data/ic_fso_type_compress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_fso_type_compress.png -------------------------------------------------------------------------------- /app/data/ic_material_light_usb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_usb.png -------------------------------------------------------------------------------- /libs/lib/libpspsystemctrl_kernel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libpspsystemctrl_kernel.a -------------------------------------------------------------------------------- /libs/lib/libpspsystemctrl_user.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libpspsystemctrl_user.a -------------------------------------------------------------------------------- /libs/lib/libpspusbdevice_driver.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/libs/lib/libpspusbdevice_driver.a -------------------------------------------------------------------------------- /app/data/ic_material_dialog_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_dialog_dark.png -------------------------------------------------------------------------------- /app/include/net.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Net { 4 | bool InitFTP(char *string); 5 | void ExitFTP(void); 6 | } 7 | -------------------------------------------------------------------------------- /app/data/ic_material_light_sdcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_sdcard.png -------------------------------------------------------------------------------- /app/data/ic_material_light_secure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_secure.png -------------------------------------------------------------------------------- /app/data/ic_material_options_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_options_dialog.png -------------------------------------------------------------------------------- /app/include/game_launcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace GameLauncher { 4 | int DisplayLauncher(const std::string &path); 5 | } 6 | -------------------------------------------------------------------------------- /app/data/btn_playback_repeat_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_repeat_overlay.png -------------------------------------------------------------------------------- /app/data/btn_playback_shuffle_overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_playback_shuffle_overlay.png -------------------------------------------------------------------------------- /app/include/audioplayer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "gui.h" 4 | 5 | namespace AudioPlayer { 6 | int Play(MenuItem &item); 7 | } 8 | -------------------------------------------------------------------------------- /app/data/ic_material_light_sdcard_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_sdcard_dark.png -------------------------------------------------------------------------------- /app/data/ic_material_light_secure_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_secure_dark.png -------------------------------------------------------------------------------- /app/data/ic_material_options_dialog_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_options_dialog_dark.png -------------------------------------------------------------------------------- /app/data/ic_material_properties_dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_properties_dialog.png -------------------------------------------------------------------------------- /app/data/btn_material_light_check_off_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_check_off_normal.png -------------------------------------------------------------------------------- /app/data/btn_material_light_check_on_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_check_on_normal.png -------------------------------------------------------------------------------- /app/data/btn_material_light_radio_off_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_radio_off_normal.png -------------------------------------------------------------------------------- /app/data/btn_material_light_radio_on_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_radio_on_normal.png -------------------------------------------------------------------------------- /app/data/btn_material_light_toggle_off_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_toggle_off_normal.png -------------------------------------------------------------------------------- /app/data/btn_material_light_toggle_on_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_toggle_on_normal.png -------------------------------------------------------------------------------- /app/data/ic_material_light_navigation_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_light_navigation_drawer.png -------------------------------------------------------------------------------- /app/data/ic_material_properties_dialog_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/ic_material_properties_dialog_dark.png -------------------------------------------------------------------------------- /app/include/archive_helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ArchiveHelper { 6 | int Extract(const std::string &path); 7 | } 8 | -------------------------------------------------------------------------------- /app/data/btn_material_light_check_off_normal_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_check_off_normal_dark.png -------------------------------------------------------------------------------- /app/data/btn_material_light_check_on_normal_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_check_on_normal_dark.png -------------------------------------------------------------------------------- /app/data/btn_material_light_radio_off_normal_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_radio_off_normal_dark.png -------------------------------------------------------------------------------- /app/data/btn_material_light_radio_on_normal_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_radio_on_normal_dark.png -------------------------------------------------------------------------------- /app/data/btn_material_light_toggle_on_normal_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel16/CMFileManager-PSP/HEAD/app/data/btn_material_light_toggle_on_normal_dark.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = audio_driver display_driver fs_driver app launcher 2 | 3 | all: 4 | @for dir in $(SUBDIRS); do $(MAKE) -C $$dir; done 5 | 6 | clean: 7 | @for dir in $(SUBDIRS); do $(MAKE) clean -C $$dir; done 8 | -------------------------------------------------------------------------------- /app/include/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef struct { 6 | int sort = 0; 7 | bool dark_theme = false; 8 | bool dev_options = false; 9 | std::string cwd; 10 | } config_t; 11 | 12 | extern config_t cfg; 13 | 14 | namespace Config { 15 | int Save(config_t config); 16 | int Load(void); 17 | } 18 | -------------------------------------------------------------------------------- /app/drivers/mutex-imports.S: -------------------------------------------------------------------------------- 1 | .set noreorder 2 | 3 | #include "pspstub.s" 4 | 5 | STUB_START "ThreadManForUser",0x40010000,0x00040005 6 | STUB_FUNC 0xB7D098C6,sceKernelCreateMutex 7 | STUB_FUNC 0xF8170FBE,sceKernelDeleteMutex 8 | STUB_FUNC 0xB011B11F,sceKernelLockMutex 9 | STUB_FUNC 0x6B30100F,sceKernelUnlockMutex 10 | STUB_END 11 | -------------------------------------------------------------------------------- /app/include/mutex.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PSP_MUTEX_ATTR_FIFO 0 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | int sceKernelCreateMutex(const char *name, uint attributes, int initial_count, void *options); 10 | int sceKernelDeleteMutex(int mutexId); 11 | int sceKernelLockMutex(int mutexId, int count, uint *timeout); 12 | int sceKernelUnlockMutex(int mutexId, int count); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /audio_driver/audio_driver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | PSP_MODULE_INFO("audio_driver", PSP_MODULE_KERNEL, 1, 4); 5 | PSP_NO_CREATE_MAIN_THREAD(); 6 | 7 | int pspAudioSetFrequency(int frequency) { 8 | u32 k1 = pspSdkSetK1(0); 9 | int ret = sceAudioSetFrequency(frequency); 10 | pspSdkSetK1(k1); 11 | return ret; 12 | } 13 | 14 | int module_start(SceSize args, void *argp) { 15 | return 0; 16 | } 17 | 18 | int module_stop(void) { 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /audio_driver/exports.exp: -------------------------------------------------------------------------------- 1 | # Define the exports for the prx 2 | PSP_BEGIN_EXPORTS 3 | 4 | # These four lines are mandatory (although you can add other functions like module_stop) 5 | # syslib is a psynonym for the single mandatory export. 6 | PSP_EXPORT_START(syslib, 0, 0x8000) 7 | PSP_EXPORT_FUNC(module_start) 8 | PSP_EXPORT_FUNC(module_stop) 9 | PSP_EXPORT_VAR(module_info) 10 | PSP_EXPORT_END 11 | 12 | PSP_EXPORT_START(audio_driver, 0, 0x4001) 13 | PSP_EXPORT_FUNC(pspAudioSetFrequency) 14 | PSP_EXPORT_END 15 | 16 | PSP_END_EXPORTS 17 | -------------------------------------------------------------------------------- /display_driver/exports.exp: -------------------------------------------------------------------------------- 1 | # Define the exports for the prx 2 | PSP_BEGIN_EXPORTS 3 | 4 | # These four lines are mandatory (although you can add other functions like module_stop) 5 | # syslib is a psynonym for the single mandatory export. 6 | PSP_EXPORT_START(syslib, 0, 0x8000) 7 | PSP_EXPORT_FUNC(module_start) 8 | PSP_EXPORT_FUNC(module_stop) 9 | PSP_EXPORT_VAR(module_info) 10 | PSP_EXPORT_END 11 | 12 | PSP_EXPORT_START(display_driver, 0, 0x4001) 13 | PSP_EXPORT_FUNC(pspDisplayEnable) 14 | PSP_EXPORT_FUNC(pspDisplayDisable) 15 | PSP_EXPORT_END 16 | 17 | PSP_END_EXPORTS 18 | -------------------------------------------------------------------------------- /audio_driver/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = audio_driver 2 | OBJS = audio_driver.o exports.o 3 | 4 | PRX_EXPORTS = exports.exp 5 | 6 | # Use the kernel's small inbuilt libc 7 | USE_KERNEL_LIBC = 1 8 | # Use only kernel libraries 9 | USE_KERNEL_LIBS = 1 10 | 11 | CFLAGS = -Os -G0 -Wall -fno-builtin-printf 12 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 13 | ASFLAGS = $(CFLAGS) 14 | 15 | LDFLAGS = -nostartfiles 16 | LIBS = -lpspaudio_driver 17 | 18 | PSPSDK=$(shell psp-config --pspsdk-path) 19 | include $(PSPSDK)/lib/build_prx.mak 20 | 21 | all: 22 | psp-build-exports -s $(PRX_EXPORTS) 23 | mv audio_driver.S "../app/drivers/" 24 | -------------------------------------------------------------------------------- /display_driver/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = display_driver 2 | OBJS = display_driver.o exports.o sceDisplay_driver.o 3 | 4 | PRX_EXPORTS = exports.exp 5 | 6 | # Use the kernel's small inbuilt libc 7 | USE_KERNEL_LIBC = 1 8 | # Use only kernel libraries 9 | USE_KERNEL_LIBS = 1 10 | 11 | INCDIR = 12 | CFLAGS = -Os -G0 -Wall -fno-builtin-printf 13 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 14 | ASFLAGS = $(CFLAGS) 15 | 16 | LDFLAGS = -nostartfiles 17 | 18 | PSPSDK=$(shell psp-config --pspsdk-path) 19 | include $(PSPSDK)/lib/build_prx.mak 20 | 21 | all: 22 | psp-build-exports -s $(PRX_EXPORTS) 23 | mv display_driver.S "../app/drivers/" 24 | -------------------------------------------------------------------------------- /libs/libnsgif/utils/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2003 James Bursa 3 | * Copyright 2004 John Tytgat 4 | * 5 | * This file is part of NetSurf, http://www.netsurf-browser.org/ 6 | * Licenced under the MIT License, 7 | * http://www.opensource.org/licenses/mit-license.php 8 | */ 9 | 10 | #include 11 | 12 | #ifndef _LIBNSGIF_LOG_H_ 13 | #define _LIBNSGIF_LOG_H_ 14 | 15 | #ifdef NDEBUG 16 | # define LOG(x) ((void) 0) 17 | #else 18 | # define LOG(x) do { fprintf(stderr, x), fputc('\n', stderr); } while (0) 19 | #endif /* NDEBUG */ 20 | 21 | #endif /* _LIBNSGIF_LOG_H_ */ 22 | -------------------------------------------------------------------------------- /fs_driver/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = fs_driver 2 | OBJS = fs_driver.o exports.o 3 | 4 | PRX_EXPORTS = exports.exp 5 | 6 | # Use the kernel's small inbuilt libc 7 | USE_KERNEL_LIBC = 1 8 | # Use only kernel libraries 9 | USE_KERNEL_LIBS = 1 10 | 11 | INCDIR = ../libs/include 12 | CFLAGS = -Os -G0 -Wall -fno-builtin-printf 13 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 14 | ASFLAGS = $(CFLAGS) 15 | 16 | LIBDIR = ../libs/lib 17 | 18 | LDFLAGS = -nostartfiles 19 | LIBS = -lpspsystemctrl_kernel 20 | 21 | PSPSDK=$(shell psp-config --pspsdk-path) 22 | include $(PSPSDK)/lib/build_prx.mak 23 | 24 | all: 25 | psp-build-exports -s $(PRX_EXPORTS) 26 | mv fs_driver.S "../app/drivers/" 27 | -------------------------------------------------------------------------------- /display_driver/sceDisplay_driver.S: -------------------------------------------------------------------------------- 1 | .set noreorder 2 | 3 | #include "pspimport.s" 4 | 5 | IMPORT_START "sceDisplay_driver",0x00010000 6 | IMPORT_FUNC "sceDisplay_driver",0x1CB8CB47,sceDisplayGetBrightness371 7 | IMPORT_FUNC "sceDisplay_driver",0x776ADFDB,sceDisplaySetBrightness371 8 | IMPORT_FUNC "sceDisplay_driver",0x946155FD,sceDisplayEnable371 9 | IMPORT_FUNC "sceDisplay_driver",0x32B67781,sceDisplayDisable371 10 | 11 | IMPORT_FUNC "sceDisplay_driver",0x31C4BAA8,sceDisplayGetBrightness 12 | IMPORT_FUNC "sceDisplay_driver",0x9E3C6DC6,sceDisplaySetBrightness 13 | IMPORT_FUNC "sceDisplay_driver",0x432D133F,sceDisplayEnable 14 | IMPORT_FUNC "sceDisplay_driver",0x681EE6A7,sceDisplayDisable 15 | -------------------------------------------------------------------------------- /app/include/g2d.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern intraFont *font; 8 | extern char font_size_cache[256]; 9 | 10 | namespace G2D { 11 | void DrawRect(float x, float y, float width, float height, g2dColor colour); 12 | void DrawImage(g2dTexture *tex, float x, float y); 13 | void DrawImageScale(g2dTexture *tex, float x, float y, float w, float h); 14 | char *KeyboardGetText(const std::string &desc_msg, const std::string &initial_msg); 15 | void FontSetStyle(float size, unsigned int colour, unsigned int options); 16 | float GetTextHeight(void); 17 | float DrawText(float x, float y, const std::string &text); 18 | } 19 | -------------------------------------------------------------------------------- /app/source/colours.cpp: -------------------------------------------------------------------------------- 1 | #include "colours.h" 2 | #include "config.h" 3 | 4 | g2dColor BG_COLOUR, STATUS_BAR_COLOUR, MENU_BAR_COLOUR, SELECTOR_COLOUR, TITLE_COLOUR, TEXT_COLOUR; 5 | 6 | namespace Colours { 7 | void Get(void) { 8 | BG_COLOUR = cfg.dark_theme? BLACK_BG : WHITE; 9 | STATUS_BAR_COLOUR = cfg.dark_theme? STATUS_BAR_DARK : STATUS_BAR_LIGHT; 10 | MENU_BAR_COLOUR = cfg.dark_theme? MENU_BAR_DARK : MENU_BAR_LIGHT; 11 | SELECTOR_COLOUR = cfg.dark_theme? SELECTOR_COLOUR_DARK : SELECTOR_COLOUR_LIGHT; 12 | TITLE_COLOUR = cfg.dark_theme? TITLE_COLOUR_DARK : TITLE_COLOUR_LIGHT; 13 | TEXT_COLOUR = cfg.dark_theme? TEXT_COLOUR_DARK : TEXT_COLOUR_LIGHT; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libs/libnsbmp/utils/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2003 James Bursa 3 | * Copyright 2004 John Tytgat 4 | * 5 | * This file is part of NetSurf, http://www.netsurf-browser.org/ 6 | * Licenced under the MIT License, 7 | * http://www.opensource.org/licenses/mit-license.php 8 | */ 9 | 10 | #include 11 | 12 | #ifndef _LIBNSBMP_LOG_H_ 13 | #define _LIBNSBMP_LOG_H_ 14 | 15 | #ifdef NDEBUG 16 | # define LOG(x) ((void) 0) 17 | #else 18 | # ifdef __GNUC__ 19 | # define LOG(x) do { printf x, fputc('\n', stdout)); } while (0) 20 | # elif defined(__CC_NORCROFT) 21 | # define LOG(x) do { printf x, fputc('\n', stdout)); } while (0) 22 | # else 23 | # define LOG(x) do { printf x, fputc('\n', stdout)); } while (0) 24 | # endif 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /launcher/source/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "systemctrl.h" 7 | 8 | PSP_MODULE_INFO("CMFileManager Launcher", PSP_MODULE_USER, VERSION_MAJOR, VERSION_MINOR); 9 | PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); 10 | 11 | int main(int argc, char **argv) { 12 | int ret = 0; 13 | char path[264], cwd[256]; 14 | struct SceKernelLoadExecVSHParam param; 15 | 16 | getcwd(cwd, 256); 17 | snprintf(path, 264, "%s/APP.PBP", cwd); 18 | 19 | memset(¶m, 0, sizeof(param)); 20 | param.size = sizeof(param); 21 | param.key = "game"; 22 | param.args = strlen(path + 1); 23 | param.argp = path; 24 | 25 | ret = sctrlKernelLoadExecVSHWithApitype(PSP_INIT_APITYPE_MS2, path, ¶m); 26 | 27 | sceKernelExitGame(); 28 | return ret; 29 | } 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | .vscode/ 4 | 5 | # Object files 6 | *.o 7 | *.ko 8 | *.obj 9 | *.elf 10 | *.SFO 11 | 12 | # Linker output 13 | *.ilk 14 | *.map 15 | 16 | # Precompiled Headers 17 | *.gch 18 | *.pch 19 | 20 | # Libraries 21 | *.lib 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | *.PBP 39 | *.prx 40 | 41 | # Debug files 42 | *.dSYM/ 43 | *.su 44 | *.idb 45 | *.pdb 46 | 47 | # Kernel Module Compile Results 48 | *.mod* 49 | *.cmd 50 | .tmp_versions/ 51 | modules.order 52 | Module.symvers 53 | Mkfile.old 54 | dkms.conf 55 | 56 | # CMFileManager PSP Specific objects 57 | app/drivers/audio_driver.S 58 | app/drivers/display_driver.S 59 | app/drivers/fs_driver.S 60 | app/drivers/input_driver.S 61 | app/*.json 62 | app/*.log 63 | -------------------------------------------------------------------------------- /launcher/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = CMFileManager 2 | 3 | OBJS = source/main.o 4 | 5 | VERSION_MAJOR := 4 6 | VERSION_MINOR := 1 7 | VERSION_MICRO := 2 8 | 9 | INCDIR = ../libs/include 10 | CFLAGS = -Os -G0 -Wall -Werror -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) 11 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti 12 | ASFLAGS := $(CFLAGS) 13 | 14 | LIBDIR = ../libs/lib 15 | LDFLAGS = 16 | LIBS = -lpspsystemctrl_user 17 | 18 | EXTRA_TARGETS = EBOOT.PBP 19 | PSP_EBOOT_TITLE = CM File Manager PSP v$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_MICRO) 20 | PSP_EBOOT_ICON = ../ICON0.PNG 21 | 22 | PSPSDK=$(shell psp-config --pspsdk-path) 23 | include $(PSPSDK)/lib/build.mak 24 | 25 | %.o: %.png 26 | bin2o -i $< $@ $(addsuffix _png, $(basename $(notdir $<) )) 27 | 28 | %.o: %.pgf 29 | bin2o -i $< $@ $(addsuffix _pgf, $(basename $(notdir $<) )) 30 | -------------------------------------------------------------------------------- /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ next ] 6 | pull_request: 7 | branches: [ next ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | container: pspdev/pspdev:latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Install dependencies 17 | run: | 18 | apk add build-base git bash cmake 19 | 20 | - name: Compile project 21 | run: make 22 | 23 | - name: Prepare artifact folder 24 | run: | 25 | mkdir -p CMFileManagerPSP 26 | cp audio_driver/audio_driver.prx CMFileManagerPSP/ 27 | cp display_driver/display_driver.prx CMFileManagerPSP/ 28 | cp fs_driver/fs_driver.prx CMFileManagerPSP/ 29 | cp app/EBOOT.PBP CMFileManagerPSP/ 30 | 31 | - uses: actions/upload-artifact@v4 32 | with: 33 | name: CMFileManagerPSP 34 | path: CMFileManagerPSP/ 35 | -------------------------------------------------------------------------------- /fs_driver/exports.exp: -------------------------------------------------------------------------------- 1 | # Define the exports for the prx 2 | PSP_BEGIN_EXPORTS 3 | 4 | # These four lines are mandatory (although you can add other functions like module_stop) 5 | # syslib is a psynonym for the single mandatory export. 6 | PSP_EXPORT_START(syslib, 0, 0x8000) 7 | PSP_EXPORT_FUNC(module_start) 8 | PSP_EXPORT_FUNC(module_stop) 9 | PSP_EXPORT_VAR(module_info) 10 | PSP_EXPORT_END 11 | 12 | PSP_EXPORT_START(fs_driver, 0, 0x4001) 13 | PSP_EXPORT_FUNC(pspIoOpenDir) 14 | PSP_EXPORT_FUNC(pspIoReadDir) 15 | PSP_EXPORT_FUNC(pspIoCloseDir) 16 | PSP_EXPORT_FUNC(pspIoMakeDir) 17 | PSP_EXPORT_FUNC(pspIoRemoveDir) 18 | PSP_EXPORT_FUNC(pspIoOpenFile) 19 | PSP_EXPORT_FUNC(pspIoReadFile) 20 | PSP_EXPORT_FUNC(pspIoWriteFile) 21 | PSP_EXPORT_FUNC(pspIoCloseFile) 22 | PSP_EXPORT_FUNC(pspIoLseek) 23 | PSP_EXPORT_FUNC(pspIoLseek32) 24 | PSP_EXPORT_FUNC(pspIoGetstat) 25 | PSP_EXPORT_FUNC(pspIoRename) 26 | PSP_EXPORT_FUNC(pspIoRemoveFile) 27 | PSP_EXPORT_FUNC(pspIoDevctl) 28 | PSP_EXPORT_END 29 | 30 | PSP_END_EXPORTS 31 | -------------------------------------------------------------------------------- /app/include/colours.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | constexpr g2dColor BLACK_BG = G2D_RGBA(48, 48, 48, 255); 6 | constexpr g2dColor STATUS_BAR_LIGHT = G2D_RGBA(37, 79, 174, 255); 7 | constexpr g2dColor STATUS_BAR_DARK = G2D_RGBA(38, 50, 56, 255); 8 | constexpr g2dColor MENU_BAR_LIGHT = G2D_RGBA(51, 103, 214, 255); 9 | constexpr g2dColor MENU_BAR_DARK = G2D_RGBA(55, 71, 79, 255); 10 | constexpr g2dColor SELECTOR_COLOUR_LIGHT = G2D_RGBA(241, 241, 241, 255); 11 | constexpr g2dColor SELECTOR_COLOUR_DARK = G2D_RGBA(76, 76, 76, 255); 12 | constexpr g2dColor TITLE_COLOUR_LIGHT = G2D_RGBA(30, 136, 229, 255); 13 | constexpr g2dColor TITLE_COLOUR_DARK = G2D_RGBA(0, 150, 136, 255); 14 | constexpr g2dColor TEXT_COLOUR_LIGHT = G2D_RGBA(32, 32, 32, 255); 15 | constexpr g2dColor TEXT_COLOUR_DARK = G2D_RGBA(185, 185, 185, 255); 16 | 17 | extern g2dColor BG_COLOUR, STATUS_BAR_COLOUR, MENU_BAR_COLOUR, SELECTOR_COLOUR, TITLE_COLOUR, TEXT_COLOUR; 18 | 19 | namespace Colours { 20 | void Get(void); 21 | } 22 | -------------------------------------------------------------------------------- /app/source/log.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "config.h" 7 | #include "utils.h" 8 | 9 | namespace Log { 10 | static const char *logPath = "debug.log"; 11 | 12 | int Error(const char *format, ...) { 13 | SceUID log = 0; 14 | 15 | // Clear debug logs on start up 16 | sceIoRemove(logPath); 17 | 18 | if (R_SUCCEEDED(log = sceIoOpen(logPath, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_APPEND, 0777))) { 19 | va_list list; 20 | char string[256] = {0}; 21 | 22 | va_start(list, format); 23 | std::vsprintf(string, format, list); 24 | va_end(list); 25 | 26 | std::printf("%s", string); 27 | 28 | int ret = 0; 29 | if (R_FAILED(ret = sceIoWrite(log, string, std::strlen(string)))) 30 | return ret; 31 | 32 | sceIoClose(log); 33 | } 34 | 35 | return 0; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/source/kernel_functions.cpp: -------------------------------------------------------------------------------- 1 | #include "kernel_functions.h" 2 | 3 | // audio_driver functions 4 | int pspAudioSetFrequency(int frequency); 5 | 6 | // display driver functions 7 | int pspDisplayEnable(void); 8 | int pspDisplayDisable(void); 9 | 10 | // fs_driver functions 11 | int pspIoOpenDir(const char *dirname); 12 | int pspIoReadDir(SceUID dir, SceIoDirent *dirent); 13 | int pspIoCloseDir(SceUID dir); 14 | int pspIoMakeDir(const char *dir, SceMode mode); 15 | int pspIoRemoveDir(const char *path); 16 | int pspIoOpenFile(const char *file, int flags, SceMode mode); 17 | int pspIoReadFile(SceUID file, void *data, SceSize size); 18 | int pspIoWriteFile(SceUID file, void *data, SceSize size); 19 | int pspIoCloseFile(SceUID file); 20 | int pspIoLseek(SceUID file, SceOff offset, int whence); 21 | int pspIoLseek32(SceUID file, SceOff offset, int whence); 22 | int pspIoGetstat(const char *file, SceIoStat *stat); 23 | int pspIoRename(const char *oldname, const char *newname); 24 | int pspIoRemoveFile(const char *file); 25 | int pspIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); 26 | -------------------------------------------------------------------------------- /libs/libnsbmp/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2006 Richard Wilson 2 | Copyright (C) 2008 Sean Fox 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | * The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /libs/libnsgif/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2004 Richard Wilson 2 | Copyright (C) 2008 Sean Fox 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | * The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /libs/include/libtiff/LICENSE.md: -------------------------------------------------------------------------------- 1 | # LibTIFF license 2 | 3 | Copyright © 1988-1997 Sam Leffler\ 4 | Copyright © 1991-1997 Silicon Graphics, Inc. 5 | 6 | Permission to use, copy, modify, distribute, and sell this software and 7 | its documentation for any purpose is hereby granted without fee, provided 8 | that (i) the above copyright notices and this permission notice appear in 9 | all copies of the software and related documentation, and (ii) the names of 10 | Sam Leffler and Silicon Graphics may not be used in any advertising or 11 | publicity relating to the software without the specific, prior written 12 | permission of Sam Leffler and Silicon Graphics. 13 | 14 | THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 16 | WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 17 | 18 | IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 19 | ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 20 | OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 | WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 22 | LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23 | OF THIS SOFTWARE. 24 | -------------------------------------------------------------------------------- /app/include/textures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | constexpr int NUM_FILE_ICONS = 6; 7 | constexpr int NUM_BATT_ICONS = 6; 8 | constexpr int NUM_THEMES = 2; 9 | 10 | extern g2dTexture *file_icons[NUM_FILE_ICONS], *icon_dir[NUM_THEMES], *icon_check[NUM_THEMES], *icon_uncheck[NUM_THEMES], \ 11 | *icon_toggle_on[NUM_THEMES], *icon_toggle_off, *icon_radio_off[NUM_THEMES], *icon_radio_on[NUM_THEMES], *icon_nav_drawer, \ 12 | *icon_back, *options_dialog[NUM_THEMES], *properties_dialog[NUM_THEMES], *dialog[NUM_THEMES], \ 13 | *battery_charging[NUM_BATT_ICONS], *battery[NUM_BATT_ICONS], *usb_icon, \ 14 | *default_artwork, *default_artwork_blur, *btn_play, *btn_pause, *btn_rewind, *btn_forward, \ 15 | *btn_repeat, *btn_shuffle, *btn_repeat_overlay, *btn_shuffle_overlay, \ 16 | *bg_header, *icon_sd[NUM_THEMES], *icon_secure[NUM_THEMES], *ic_play_btn, *ftp_icon[NUM_THEMES], *sort_icon[NUM_THEMES], \ 17 | *dark_theme_icon[NUM_THEMES], *dev_options_icon[NUM_THEMES], *about_icon[NUM_THEMES]; 18 | 19 | namespace Textures { 20 | g2dTexture *LoadImageBufferJPEG(unsigned char *data, int size); 21 | g2dTexture *LoadImageBufferPNG(unsigned char *data, int size); 22 | g2dTexture *LoadImage(const std::string &path, int size); 23 | void Load(void); 24 | void Free(void); 25 | } 26 | -------------------------------------------------------------------------------- /app/include/kernel_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined (__cplusplus) 4 | extern "C" { 5 | #endif 6 | 7 | #include 8 | #include 9 | 10 | // Kernel function prototypes 11 | 12 | // audio_driver functions 13 | extern int pspAudioSetFrequency(int frequency); 14 | 15 | // display_driver functions 16 | extern int pspDisplayEnable(void); 17 | extern int pspDisplayDisable(void); 18 | 19 | // fs_driver functions 20 | extern int pspIoOpenDir(const char *dirname); 21 | extern int pspIoReadDir(SceUID dir, SceIoDirent *dirent); 22 | extern int pspIoCloseDir(SceUID dir); 23 | extern int pspIoMakeDir(const char *dir, SceMode mode); 24 | extern int pspIoRemoveDir(const char *path); 25 | extern int pspIoOpenFile(const char *file, int flags, SceMode mode); 26 | extern int pspIoReadFile(SceUID file, void *data, SceSize size); 27 | extern int pspIoWriteFile(SceUID file, void *data, SceSize size); 28 | extern int pspIoCloseFile(SceUID file); 29 | extern int pspIoLseek(SceUID file, SceOff offset, int whence); 30 | extern int pspIoLseek32(SceUID file, SceOff offset, int whence); 31 | extern int pspIoGetstat(const char *file, SceIoStat *stat); 32 | extern int pspIoRename(const char *oldname, const char *newname); 33 | extern int pspIoRemoveFile(const char *file); 34 | extern int pspIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen); 35 | 36 | #if defined (__cplusplus) 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /app/source/audio/wav.cpp: -------------------------------------------------------------------------------- 1 | #include "audio.h" 2 | #define DR_WAV_IMPLEMENTATION 3 | #include "dr_wav.h" 4 | 5 | namespace WAV { 6 | static drwav wav; 7 | static drwav_uint64 frames_read = 0; 8 | 9 | int Init(const std::string &path) { 10 | if (!drwav_init_file(&wav, path.c_str(), nullptr)) 11 | return -1; 12 | 13 | return 0; 14 | } 15 | 16 | u32 GetSampleRate(void) { 17 | return wav.sampleRate; 18 | } 19 | 20 | u8 GetChannels(void) { 21 | return wav.channels; 22 | } 23 | 24 | void Decode(void *buf, unsigned int length, void *userdata) { 25 | frames_read += drwav_read_pcm_frames_s16(&wav, static_cast(length), static_cast(buf)); 26 | if (frames_read >= wav.totalPCMFrameCount) 27 | playing = false; 28 | } 29 | 30 | u64 GetPosition(void) { 31 | return frames_read; 32 | } 33 | 34 | u64 GetLength(void) { 35 | return wav.totalPCMFrameCount; 36 | } 37 | 38 | u64 Seek(u64 index) { 39 | drwav_uint64 seek_frame = (wav.totalPCMFrameCount * (index / 225.0)); 40 | 41 | if (drwav_seek_to_pcm_frame(&wav, seek_frame) == DRWAV_TRUE) { 42 | frames_read = seek_frame; 43 | return frames_read; 44 | } 45 | 46 | return -1; 47 | } 48 | 49 | void Exit(void) { 50 | frames_read = 0; 51 | drwav_uninit(&wav); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /libs/include/libtiff/tiffvers.h: -------------------------------------------------------------------------------- 1 | /* tiffvers.h version information is updated according to version information 2 | * in configure.ac */ 3 | 4 | /* clang-format off */ 5 | 6 | /* clang-format disabled because FindTIFF.cmake is very sensitive to the 7 | * formatting of below line being a single line. 8 | * Furthermore, configure_file variables of type "" are 9 | * modified by clang-format and won't be substituted by CMake. 10 | */ 11 | #define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.7.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." 12 | /* 13 | * This define can be used in code that requires 14 | * compilation-related definitions specific to a 15 | * version or versions of the library. Runtime 16 | * version checking should be done based on the 17 | * string returned by TIFFGetVersion. 18 | */ 19 | #define TIFFLIB_VERSION 20240911 20 | 21 | /* The following defines have been added in 4.5.0 */ 22 | #define TIFFLIB_MAJOR_VERSION 4 23 | #define TIFFLIB_MINOR_VERSION 7 24 | #define TIFFLIB_MICRO_VERSION 0 25 | #define TIFFLIB_VERSION_STR_MAJ_MIN_MIC "4.7.0" 26 | 27 | /* Macro added in 4.5.0. Returns TRUE if the current libtiff version is 28 | * greater or equal to major.minor.micro 29 | */ 30 | #define TIFFLIB_AT_LEAST(major, minor, micro) \ 31 | (TIFFLIB_MAJOR_VERSION > (major) || \ 32 | (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \ 33 | (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \ 34 | TIFFLIB_MICRO_VERSION >= (micro))) 35 | 36 | /* clang-format on */ 37 | -------------------------------------------------------------------------------- /libs/include/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /libs/include/pspusbdevice.h: -------------------------------------------------------------------------------- 1 | #ifndef __PSPUSBDEVICE_H__ 2 | #define __PSPUSBDEVICE_H__ 3 | 4 | #if defined (__cplusplus) 5 | extern "C" { 6 | #endif 7 | 8 | /** 9 | * This functions require flash0:/kd/_usbdevice.prx to be loaded/started first. 10 | 11 | * Link with pspusbdevice for user mode access or with pspusbdevice_driver for kernel access 12 | */ 13 | 14 | #define PSP_USBDEVICE_FLASH0 0 15 | #define PSP_USBDEVICE_FLASH1 1 16 | #define PSP_USBDEVICE_FLASH2 2 17 | #define PSP_USBDEVICE_FLASH3 3 18 | #define PSP_USBDEVICE_UMD9660 4 19 | 20 | #define UNASSIGN_MASK_FLASH0 1 21 | #define UNASSIGN_MASK_FLASH1 2 22 | #define UNASSIGN_MASK_FLASH2 3 23 | #define UNASSIGN_MASK_FLASH3 4 24 | 25 | /** 26 | * Sets the usb device. Call this function when you are about to do the sceUsbStart and sceUsbActivate stuff 27 | * 28 | * @param device - The usb device, one of listed above. 29 | * @param ronly - If non-zero indicates read only access. This parameters is ignored for PSP_USBDEVICE_UMD9660 30 | * @param unassign_mask - It unassigns automatically the flashes indicated by the mask. 31 | * The flashes will be reassigned automatically after calling pspUsbDeviceFinishDevice 32 | * 33 | * Set this param to 0 if you don't need it (vshctrl doesn't use it). 34 | * 35 | * @returns 0 on success, < 0 on error. 36 | */ 37 | int pspUsbDeviceSetDevice(u32 device, int ronly, int unassign_mask); 38 | 39 | /** 40 | * Finishes the usb device. Call this function after stoping usbstor driver 41 | * 42 | * @returns 0 in success, < 0 on error 43 | */ 44 | int pspUsbDeviceFinishDevice(); 45 | 46 | #if defined (__cplusplus) 47 | } 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /app/include/fs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | typedef enum FileType { 8 | FileTypeNone, 9 | FileTypeApp, 10 | FileTypeArchive, 11 | FileTypeAudio, 12 | FileTypeImage, 13 | FileTypeText 14 | } FileType; 15 | 16 | typedef enum FileTimestamp { 17 | FileCreatedTime, 18 | FileAccessedTime, 19 | FileModifiedTime 20 | } FileTimestamp; 21 | 22 | namespace FS { 23 | bool FileExists(const std::string &path); 24 | bool DirExists(const std::string &path); 25 | int MakeDir(const std::string &path); 26 | int RecursiveMakeDir(const std::string &path); 27 | int CreateFile(const std::string &path); 28 | const char* GetFileExt(const char *filename); 29 | FileType GetFileType(const std::string &filename); 30 | SceOff GetFileSize(const std::string &path); 31 | char *GetFileTimestamp(SceIoStat &stat, FileTimestamp time); 32 | char *GetFilePermission(SceIoStat &stat); 33 | int ReadFile(const std::string &path, void *buf, int size); 34 | int WriteFile(const std::string &path, void *buf, int size); 35 | int GetDirList(const std::string &path, std::vector &entries); 36 | int ChangeDirNext(const std::string &path, std::vector &entries); 37 | int ChangeDirPrev(std::vector &entries); 38 | std::string GetFilename(const std::string &path); 39 | void Copy(SceIoDirent &entry, const std::string &path); 40 | int Paste(void); 41 | int Move(void); 42 | int Delete(SceIoDirent &entry); 43 | std::string BuildPath(const std::string &path, const std::string &filename); 44 | } 45 | -------------------------------------------------------------------------------- /app/include/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /// Checks whether a result code indicates success. 7 | #define R_SUCCEEDED(res) ((res) >= 0) 8 | /// Checks whether a result code indicates failure. 9 | #define R_FAILED(res) ((res) < 0) 10 | 11 | enum BROWSE_STATE { 12 | BROWSE_STATE_INTERNAL, 13 | BROWSE_STATE_EXTERNAL, 14 | BROWSE_STATE_FLASH0, 15 | BROWSE_STATE_FLASH1, 16 | BROWSE_STATE_FLASH2, 17 | BROWSE_STATE_FLASH3, 18 | BROWSE_STATE_UMD 19 | }; 20 | 21 | extern bool isMSInserted, isPSPGo; 22 | extern enum PspCtrlButtons PSP_CTRL_ENTER, PSP_CTRL_CANCEL; 23 | extern BROWSE_STATE device; 24 | extern int language; 25 | 26 | namespace Utils { 27 | void SetBounds(int &set, int min, int max); 28 | void SetMax(int &set, int value, int max); 29 | void SetMin(int &set, int value, int min); 30 | void GetSizeString(char *string, double size); 31 | void InitKernelDrivers(void); 32 | void TermKernelDrivers(void); 33 | void HandleUSB(void); 34 | bool IsModelPSPGo(void); 35 | int IsMemCardInserted(bool &isInserted); 36 | bool IsInternalStorage(void); 37 | int LaunchEboot(const char *path); 38 | u64 GetTotalStorage(void); 39 | u64 GetFreeStorage(void); 40 | u64 GetUsedStorage(void); 41 | int ReadControls(void); 42 | int IsButtonPressed(enum PspCtrlButtons buttons); 43 | int IsButtonHeld(enum PspCtrlButtons buttons); 44 | enum PspCtrlButtons GetEnterButton(void); 45 | enum PspCtrlButtons GetCancelButton(void); 46 | float GetAnalogX(void); 47 | float GetAnalogY(void); 48 | bool IsCancelButtonPressed(void); 49 | int GetLanguage(void); 50 | } 51 | -------------------------------------------------------------------------------- /app/include/pspaudiolib_cm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspaudiolib.h - Audio library build on top of sceAudio, but to provide 7 | * multiple thread usage and callbacks. 8 | * 9 | * Copyright (c) 2005 Adresd 10 | * Copyright (c) 2005 Marcus R. Brown 11 | # Copyright (c) 2019 Joel16 12 | * 13 | * $Id: pspaudiolib.h 1874 2006-04-18 13:20:58Z tyranid $ 14 | */ 15 | #pragma once 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #define PSP_NUM_AUDIO_CHANNELS 4 22 | /** This is the number of frames you can update per callback, a frame being 23 | * 1 sample for mono, 2 samples for stereo etc. */ 24 | #define PSP_NUM_AUDIO_SAMPLES 960 25 | #define PSP_VOLUME_MAX 0x8000 26 | 27 | typedef void (* pspAudioCallback_t)(void *buf, unsigned int reqn, void *pdata); 28 | 29 | typedef struct { 30 | int threadhandle; 31 | int handle; 32 | int volumeleft; 33 | int volumeright; 34 | pspAudioCallback_t callback; 35 | void *pdata; 36 | } psp_audio_channelinfo; 37 | 38 | typedef int (* pspAudioThreadfunc_t)(int args, void *argp); 39 | 40 | int pspAudioInit(int format); 41 | void pspAudioEndPre(void); 42 | void pspAudioEnd(void); 43 | 44 | void pspAudioSetVolume(int channel, int left, int right); 45 | void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn); 46 | void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata); 47 | int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /display_driver/display_driver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | PSP_MODULE_INFO("display_driver", PSP_MODULE_KERNEL, 1, 6); 6 | PSP_NO_CREATE_MAIN_THREAD(); 7 | 8 | int sceDisplayEnable(void); 9 | int sceDisplayDisable(void); 10 | int sceDisplayEnable371(void); 11 | int sceDisplayDisable371(void); 12 | void sceDisplaySetBrightness371(int level, int unk1); 13 | void sceDisplayGetBrightness371(int *level, int *unk1); 14 | 15 | static int old_brightness_level = 0; 16 | 17 | int pspDisplayEnable(void) { 18 | u32 k1 = pspSdkSetK1(0); 19 | 20 | int ret = 0; 21 | if (sceKernelDevkitVersion() < 0x03070110) { 22 | sceDisplaySetBrightness(old_brightness_level, 0); 23 | ret = sceDisplayEnable(); 24 | } 25 | else { 26 | sceDisplaySetBrightness371(old_brightness_level, 0); 27 | ret = sceDisplayEnable371(); 28 | } 29 | 30 | pspSdkSetK1(k1); 31 | return ret; 32 | } 33 | 34 | int pspDisplayDisable(void) { 35 | u32 k1 = pspSdkSetK1(0); 36 | 37 | int ret = 0; 38 | if (sceKernelDevkitVersion() < 0x03070110) { 39 | sceDisplaySetBrightness(0, 0); 40 | ret = sceDisplayDisable(); 41 | } 42 | else { 43 | sceDisplaySetBrightness371(0, 0); 44 | ret = sceDisplayDisable371(); 45 | } 46 | 47 | pspSdkSetK1(k1); 48 | return ret; 49 | } 50 | 51 | int module_start(SceSize args, void *argp) { 52 | int unk = 0; 53 | 54 | if (sceKernelDevkitVersion() < 0x03070110) 55 | sceDisplayGetBrightness(&old_brightness_level, &unk); 56 | else 57 | sceDisplayGetBrightness371(&old_brightness_level, &unk); 58 | 59 | return 0; 60 | } 61 | 62 | int module_stop(void) { 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /app/include/gui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | enum MENU_STATES { 9 | MENU_STATE_MENUBAR, 10 | MENU_STATE_FILEBROWSER, 11 | MENU_STATE_OPTIONS, 12 | MENU_STATE_DELETE, 13 | MENU_STATE_PROPERTIES, 14 | MENU_STATE_SETTINGS, 15 | MENU_STATE_IMAGEVIEWER, 16 | MENU_STATE_ARCHIVEEXTRACT, 17 | MENU_STATE_TEXTREADER 18 | }; 19 | 20 | typedef struct { 21 | MENU_STATES state = MENU_STATE_FILEBROWSER; 22 | int selected = 0; 23 | std::vector entries; 24 | std::vector checked; 25 | std::vector checked_copy; 26 | std::string checked_cwd; 27 | int checked_count = 0; 28 | u64 used_storage = 0; 29 | u64 total_storage = 0; 30 | g2dTexture *texture = nullptr; 31 | } MenuItem; 32 | 33 | extern bool running; 34 | 35 | namespace GUI { 36 | void ResetCheckbox(MenuItem &item); 37 | void GetStorageSize(MenuItem &item); 38 | void DisplayStatusBar(void); 39 | void ProgressBar(const std::string &title, std::string message, u64 offset, u64 size); 40 | int RenderLoop(void); 41 | 42 | void HandleMenubarAnim(float &delta); 43 | void DisplayMenubar(void); 44 | void ControlMenubar(MenuItem &item, int &ctrl); 45 | 46 | void DisplayFileBrowser(MenuItem &item); 47 | void ControlFileBrowser(MenuItem &item, int &ctrl); 48 | 49 | void DisplayFileOptions(MenuItem &item); 50 | void ControlFileOptions(MenuItem &item, int &ctrl); 51 | 52 | void DisplayFileProperties(MenuItem &item); 53 | void ControlFileProperties(MenuItem &item); 54 | 55 | void DisplayDeleteOptions(void); 56 | void ControlDeleteOptions(MenuItem &item, int &ctrl); 57 | 58 | void DisplaySettings(MenuItem &item); 59 | void ControlSettings(MenuItem &item, int &ctrl); 60 | 61 | void DisplayImageViewer(MenuItem &item); 62 | void ControlImageViewer(MenuItem &item, float &delta); 63 | } 64 | -------------------------------------------------------------------------------- /app/Makefile: -------------------------------------------------------------------------------- 1 | TARGET = CMFileManager 2 | 3 | SOURCES := data drivers source source/audio source/gui ../libs/libnsbmp ../libs/libnsgif 4 | CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) 5 | SFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.S)) 6 | CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) 7 | GFXFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.png)) 8 | FONTFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.pgf)) 9 | 10 | OBJS := $(addsuffix .o,$(BINFILES)) \ 11 | $(CFILES:.c=.o) $(SFILES:.S=.o) $(CPPFILES:.cpp=.o) $(GFXFILES:.png=.o) $(FONTFILES:.pgf=.o) 12 | 13 | VERSION_MAJOR := 4 14 | VERSION_MINOR := 1 15 | VERSION_MICRO := 2 16 | 17 | INCDIR = ../libs/ ../libs/include ../libs/include/libtiff ../libs/libnsbmp ../libs/libnsgif \ 18 | ../libs/include/opus include 19 | CFLAGS = -Os -mno-gpopt -Wall -ffast-math -Wno-narrowing -Wno-unused-variable \ 20 | -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_MICRO=$(VERSION_MICRO) 21 | CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti -std=gnu++17 22 | ASFLAGS := $(CFLAGS) 23 | 24 | BUILD_PRX = 1 25 | 26 | LIBDIR = ../libs/lib 27 | LDFLAGS = 28 | LIBS = -lintrafont -lglib2d -lxmp -lmpg123 -lvorbisfile -lvorbis -lopusfile -lopus -lFLAC -logg \ 29 | -larchive -ltiff -lbz2 -llzma -lturbojpeg -ljpeg -lpng16 -lstdc++ -lz \ 30 | -lpspkubridge -lpspsystemctrl_user -lpspusbdevice \ 31 | -lpspgu -lpspvram -lpspaudio -lpsppower -lpspreg -lpspusb -lpspusbstor -lpspumd 32 | 33 | EXTRA_TARGETS = EBOOT.PBP 34 | PSP_EBOOT_TITLE = CM File Manager PSP v$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_MICRO) 35 | PSP_EBOOT_ICON = ../ICON0.PNG 36 | 37 | PSPSDK=$(shell psp-config --pspsdk-path) 38 | include $(PSPSDK)/lib/build.mak 39 | 40 | %.o: %.png 41 | bin2o -i $< $@ $(addsuffix _png, $(basename $(notdir $<) )) 42 | 43 | %.o: %.pgf 44 | bin2o -i $< $@ $(addsuffix _pgf, $(basename $(notdir $<) )) 45 | -------------------------------------------------------------------------------- /app/source/audio/xm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "audio.h" 4 | 5 | namespace XM { 6 | static xmp_context xmp; 7 | static struct xmp_frame_info frame_info; 8 | static struct xmp_module_info module_info; 9 | static SceUInt64 samples_read = 0, total_samples = 0; 10 | 11 | int Init(const std::string &path) { 12 | xmp = xmp_create_context(); 13 | if (xmp_load_module(xmp, const_cast(path.c_str())) < 0) 14 | return -1; 15 | 16 | xmp_start_player(xmp, 44100, 0); 17 | xmp_get_frame_info(xmp, &frame_info); 18 | total_samples = (frame_info.total_time * 44.1); 19 | 20 | xmp_get_module_info(xmp, &module_info); 21 | if (module_info.mod->name[0] != '\0') { 22 | metadata.has_meta = true; 23 | metadata.title = module_info.mod->name; 24 | } 25 | 26 | return 0; 27 | } 28 | 29 | u32 GetSampleRate(void) { 30 | return 44100; 31 | } 32 | 33 | u8 GetChannels(void) { 34 | return 2; 35 | } 36 | 37 | void Decode(void *buf, unsigned int length, void *userdata) { 38 | xmp_play_buffer(xmp, buf, static_cast(length) * (sizeof(s16) * 2), 0); 39 | samples_read += length; 40 | 41 | if (samples_read >= total_samples) 42 | playing = false; 43 | } 44 | 45 | u64 GetPosition(void) { 46 | return samples_read; 47 | } 48 | 49 | u64 GetLength(void) { 50 | return total_samples; 51 | } 52 | 53 | u64 Seek(u64 index) { 54 | int seek_sample = (total_samples * (index / 225.0)); 55 | 56 | if (xmp_seek_time(xmp, (seek_sample / 44.1)) >= 0) { 57 | samples_read = seek_sample; 58 | return samples_read; 59 | } 60 | 61 | return -1; 62 | } 63 | 64 | void Exit(void) { 65 | samples_read = 0; 66 | xmp_end_player(xmp); 67 | xmp_release_module(xmp); 68 | xmp_free_context(xmp); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /libs/include/rapidjson/internal/clzll.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_CLZLL_H_ 16 | #define RAPIDJSON_CLZLL_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(_MSC_VER) && !defined(UNDER_CE) 21 | #include 22 | #if defined(_WIN64) 23 | #pragma intrinsic(_BitScanReverse64) 24 | #else 25 | #pragma intrinsic(_BitScanReverse) 26 | #endif 27 | #endif 28 | 29 | RAPIDJSON_NAMESPACE_BEGIN 30 | namespace internal { 31 | 32 | inline uint32_t clzll(uint64_t x) { 33 | // Passing 0 to __builtin_clzll is UB in GCC and results in an 34 | // infinite loop in the software implementation. 35 | RAPIDJSON_ASSERT(x != 0); 36 | 37 | #if defined(_MSC_VER) && !defined(UNDER_CE) 38 | unsigned long r = 0; 39 | #if defined(_WIN64) 40 | _BitScanReverse64(&r, x); 41 | #else 42 | // Scan the high 32 bits. 43 | if (_BitScanReverse(&r, static_cast(x >> 32))) 44 | return 63 - (r + 32); 45 | 46 | // Scan the low 32 bits. 47 | _BitScanReverse(&r, static_cast(x & 0xFFFFFFFF)); 48 | #endif // _WIN64 49 | 50 | return 63 - r; 51 | #elif (defined(__GNUC__) && __GNUC__ >= 4) || RAPIDJSON_HAS_BUILTIN(__builtin_clzll) 52 | // __builtin_clzll wrapper 53 | return static_cast(__builtin_clzll(x)); 54 | #else 55 | // naive version 56 | uint32_t r = 0; 57 | while (!(x & (static_cast(1) << 63))) { 58 | x <<= 1; 59 | ++r; 60 | } 61 | 62 | return r; 63 | #endif // _MSC_VER 64 | } 65 | 66 | #define RAPIDJSON_CLZLL RAPIDJSON_NAMESPACE::internal::clzll 67 | 68 | } // namespace internal 69 | RAPIDJSON_NAMESPACE_END 70 | 71 | #endif // RAPIDJSON_CLZLL_H_ 72 | -------------------------------------------------------------------------------- /app/include/ftppsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Sergi Granell (xerpi), Joel16 3 | */ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | typedef void (*ftppsp_log_cb_t)(const char *); 10 | 11 | /* Returns PSVita's IP and FTP port. 0 on success */ 12 | int ftppsp_init(char *psp_ip, unsigned short int *psp_port); 13 | void ftppsp_fini(void); 14 | int ftppsp_is_initialized(void); 15 | int ftppsp_add_device(const char *devname); 16 | int ftppsp_del_device(const char *devname); 17 | void ftppsp_set_info_log_cb(ftppsp_log_cb_t cb); 18 | void ftppsp_set_debug_log_cb(ftppsp_log_cb_t cb); 19 | void ftppsp_set_file_buf_size(unsigned int size); 20 | 21 | /* Extended functionality */ 22 | 23 | typedef enum { 24 | FTP_DATA_CONNECTION_NONE, 25 | FTP_DATA_CONNECTION_ACTIVE, 26 | FTP_DATA_CONNECTION_PASSIVE 27 | } DataConnectionType; 28 | 29 | 30 | typedef struct ftppsp_client_info { 31 | /* Client number */ 32 | int num = 0; 33 | /* Thread UID */ 34 | SceUID thid = 0; 35 | /* Control connection socket FD */ 36 | int ctrl_sockfd = 0; 37 | /* Data connection attributes */ 38 | int data_sockfd = 0; 39 | DataConnectionType data_con_type = FTP_DATA_CONNECTION_NONE; 40 | struct sockaddr_in data_sockaddr; 41 | /* PASV mode client socket */ 42 | struct sockaddr_in pasv_sockaddr; 43 | int pasv_sockfd = 0; 44 | /* Remote client net info */ 45 | struct sockaddr_in addr; 46 | /* Receive buffer attributes */ 47 | int n_recv = 0; 48 | char recv_buffer[1024] = {0}; 49 | /* Points to the character after the first space */ 50 | const char *recv_cmd_args = nullptr; 51 | /* Current working directory */ 52 | char cur_path[1024] = {0}; 53 | /* Rename path */ 54 | char rename_path[1024] = {0}; 55 | /* Client list */ 56 | struct ftppsp_client_info *next; 57 | struct ftppsp_client_info *prev; 58 | /* Offset for transfer resume */ 59 | unsigned int restore_point = 0; 60 | } ftppsp_client_info_t; 61 | 62 | typedef void (*cmd_dispatch_func)(ftppsp_client_info_t *client); // Command handler 63 | 64 | int ftppsp_ext_add_custom_command(const char *cmd, cmd_dispatch_func func); 65 | int ftppsp_ext_del_custom_command(const char *cmd); 66 | void ftppsp_ext_client_send_ctrl_msg(ftppsp_client_info_t *client, const char *msg); 67 | void ftppsp_ext_client_send_data_msg(ftppsp_client_info_t *client, const char *str); 68 | -------------------------------------------------------------------------------- /libs/include/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Returns number of code points in a encoded string. 49 | template 50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 51 | RAPIDJSON_ASSERT(s != 0); 52 | RAPIDJSON_ASSERT(outCount != 0); 53 | GenericStringStream is(s); 54 | const typename Encoding::Ch* end = s + length; 55 | SizeType count = 0; 56 | while (is.src_ < end) { 57 | unsigned codepoint; 58 | if (!Encoding::Decode(is, &codepoint)) 59 | return false; 60 | count++; 61 | } 62 | *outCount = count; 63 | return true; 64 | } 65 | 66 | } // namespace internal 67 | RAPIDJSON_NAMESPACE_END 68 | 69 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 70 | -------------------------------------------------------------------------------- /libs/include/rapidjson/cursorstreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_CURSORSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_CURSORSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | 20 | #if defined(__GNUC__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && _MSC_VER <= 1800 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(4702) // unreachable code 28 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 29 | #endif 30 | 31 | RAPIDJSON_NAMESPACE_BEGIN 32 | 33 | 34 | //! Cursor stream wrapper for counting line and column number if error exists. 35 | /*! 36 | \tparam InputStream Any stream that implements Stream Concept 37 | */ 38 | template > 39 | class CursorStreamWrapper : public GenericStreamWrapper { 40 | public: 41 | typedef typename Encoding::Ch Ch; 42 | 43 | CursorStreamWrapper(InputStream& is): 44 | GenericStreamWrapper(is), line_(1), col_(0) {} 45 | 46 | // counting line and column number 47 | Ch Take() { 48 | Ch ch = this->is_.Take(); 49 | if(ch == '\n') { 50 | line_ ++; 51 | col_ = 0; 52 | } else { 53 | col_ ++; 54 | } 55 | return ch; 56 | } 57 | 58 | //! Get the error line number, if error exists. 59 | size_t GetLine() const { return line_; } 60 | //! Get the error column number, if error exists. 61 | size_t GetColumn() const { return col_; } 62 | 63 | private: 64 | size_t line_; //!< Current Line 65 | size_t col_; //!< Current Column 66 | }; 67 | 68 | #if defined(_MSC_VER) && _MSC_VER <= 1800 69 | RAPIDJSON_DIAG_POP 70 | #endif 71 | 72 | #if defined(__GNUC__) 73 | RAPIDJSON_DIAG_POP 74 | #endif 75 | 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_CURSORSTREAMWRAPPER_H_ 79 | -------------------------------------------------------------------------------- /libs/include/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /libs/include/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 | #define RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /app/include/audio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern bool playing, paused; 8 | 9 | typedef struct { 10 | bool has_meta = false; 11 | std::string title; 12 | std::string album; 13 | std::string artist; 14 | std::string year; 15 | std::string comment; 16 | std::string genre; 17 | g2dTexture *cover_image; 18 | } AudioMetadata; 19 | 20 | extern AudioMetadata metadata; 21 | 22 | namespace FLAC { 23 | int Init(const std::string &path); 24 | u32 GetSampleRate(void); 25 | u8 GetChannels(void); 26 | void Decode(void *buf, unsigned int length, void *userdata); 27 | u64 GetPosition(void); 28 | u64 GetLength(void); 29 | u64 Seek(u64 index); 30 | void Exit(void); 31 | } 32 | 33 | namespace MP3 { 34 | int Init(const std::string &path); 35 | u32 GetSampleRate(void); 36 | u8 GetChannels(void); 37 | void Decode(void *buf, unsigned int length, void *userdata); 38 | u64 GetPosition(void); 39 | u64 GetLength(void); 40 | u64 Seek(u64 index); 41 | void Exit(void); 42 | } 43 | 44 | namespace OGG { 45 | int Init(const std::string &path); 46 | u32 GetSampleRate(void); 47 | u8 GetChannels(void); 48 | void Decode(void *buf, unsigned int length, void *userdata); 49 | u64 GetPosition(void); 50 | u64 GetLength(void); 51 | u64 Seek(u64 index); 52 | void Exit(void); 53 | } 54 | 55 | namespace OPUS { 56 | int Init(const std::string &path); 57 | u32 GetSampleRate(void); 58 | u8 GetChannels(void); 59 | void Decode(void *buf, unsigned int length, void *userdata); 60 | u64 GetPosition(void); 61 | u64 GetLength(void); 62 | u64 Seek(u64 index); 63 | void Exit(void); 64 | } 65 | 66 | namespace WAV { 67 | int Init(const std::string &path); 68 | u32 GetSampleRate(void); 69 | u8 GetChannels(void); 70 | void Decode(void *buf, unsigned int length, void *userdata); 71 | u64 GetPosition(void); 72 | u64 GetLength(void); 73 | u64 Seek(u64 index); 74 | void Exit(void); 75 | } 76 | 77 | namespace XM { 78 | int Init(const std::string &path); 79 | u32 GetSampleRate(void); 80 | u8 GetChannels(void); 81 | void Decode(void *buf, unsigned int length, void *userdata); 82 | u64 GetPosition(void); 83 | u64 GetLength(void); 84 | u64 Seek(u64 index); 85 | void Exit(void); 86 | } 87 | 88 | namespace Audio { 89 | void Init(const std::string &path); 90 | bool IsPaused(void); 91 | void Pause(void); 92 | void Stop(void); 93 | u64 GetPosition(void); 94 | u64 GetLength(void); 95 | u64 GetPositionSeconds(void); 96 | u64 GetLengthSeconds(void); 97 | u64 Seek(u64 index); 98 | void Exit(void); 99 | } 100 | -------------------------------------------------------------------------------- /app/source/gui/properties.cpp: -------------------------------------------------------------------------------- 1 | #include "colours.h" 2 | #include "config.h" 3 | #include "fs.h" 4 | #include "g2d.h" 5 | #include "gui.h" 6 | #include "log.h" 7 | #include "textures.h" 8 | #include "utils.h" 9 | 10 | namespace GUI { 11 | void DisplayFileProperties(MenuItem &item) { 12 | G2D::DrawRect(0, 18, 480, 254, G2D_RGBA(0, 0, 0, cfg.dark_theme? 50 : 80)); 13 | G2D::DrawImage(properties_dialog[cfg.dark_theme], ((480 - (properties_dialog[0]->w)) / 2), ((272 - (properties_dialog[0]->h)) / 2)); 14 | G2D::FontSetStyle(1.f, TITLE_COLOUR, INTRAFONT_ALIGN_LEFT); 15 | 16 | G2D::DrawText(((480 - (properties_dialog[0]->w)) / 2) + 10, ((272 - (properties_dialog[0]->h)) / 2) + 20, "Properties"); 17 | 18 | int ok_width = intraFontMeasureText(font, "OK"); 19 | G2D::DrawRect((340 - (ok_width)) - 5, (220 - (font->texYSize - 15)) - 5, ok_width + 10, (font->texYSize - 5) + 10, SELECTOR_COLOUR); 20 | G2D::DrawText(340 - (ok_width), (232 - (font->texYSize - 15)) - 3, "OK"); 21 | 22 | G2D::FontSetStyle(1.f, TEXT_COLOUR, INTRAFONT_ALIGN_LEFT); 23 | intraFontPrintf(font, 140, 74, std::string(item.entries[item.selected].d_name).length() > 14? "Name: %.14s..." : "%s", 24 | item.entries[item.selected].d_name); 25 | 26 | if (!(FIO_S_ISDIR(item.entries[item.selected].d_stat.st_mode))) { 27 | char size[16] = {0}; 28 | Utils::GetSizeString(size, item.entries[item.selected].d_stat.st_size); 29 | intraFontPrintf(font, 140, 92, "Size: %s", size); 30 | intraFontPrintf(font, 140, 110, "Created: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileCreatedTime)); 31 | intraFontPrintf(font, 140, 128, "Accessed: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileAccessedTime)); 32 | intraFontPrintf(font, 140, 146, "Modified: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileModifiedTime)); 33 | intraFontPrintf(font, 140, 164, "Perms: %s", FS::GetFilePermission(item.entries[item.selected].d_stat)); 34 | } 35 | else { 36 | intraFontPrintf(font, 140, 92, "Created: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileCreatedTime)); 37 | intraFontPrintf(font, 140, 110, "Accessed: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileAccessedTime)); 38 | intraFontPrintf(font, 140, 128, "Modified: %s", FS::GetFileTimestamp(item.entries[item.selected].d_stat, FileModifiedTime)); 39 | intraFontPrintf(font, 140, 146, "Perms: %s", FS::GetFilePermission(item.entries[item.selected].d_stat)); 40 | } 41 | } 42 | 43 | void ControlFileProperties(MenuItem &item) { 44 | if ((Utils::IsButtonPressed(PSP_CTRL_ENTER)) || (Utils::IsButtonPressed(PSP_CTRL_CANCEL))) 45 | item.state = MENU_STATE_OPTIONS; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/source/config.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "fs.h" 3 | #include "log.h" 4 | #include "rapidjson/document.h" 5 | #include "utils.h" 6 | 7 | constexpr int config_version = 4; 8 | constexpr char config_file[] = "{\n\t\"config_ver\": %d,\n\t\"sort\": %d,\n\t\"dark_theme\": %d,\n\t\"dev_options\": %d\n}\n"; 9 | static int config_version_holder = 0; 10 | config_t cfg; 11 | 12 | namespace Config { 13 | int Save(config_t config) { 14 | int ret = 0; 15 | char buf[128]; 16 | int len = std::snprintf(buf, 128, config_file, config_version, cfg.sort, cfg.dark_theme, cfg.dev_options); 17 | 18 | if (R_FAILED(ret = FS::WriteFile("config.json", buf, len))) { 19 | Log::Error("%s failed: 0x%08x\n", __func__, ret); 20 | return ret; 21 | } 22 | 23 | return 0; 24 | } 25 | 26 | int Load(void) { 27 | int ret = 0; 28 | 29 | // Set root path and current working directory based on model. 30 | cfg.cwd = isPSPGo? "ef0:" : "ms0:"; 31 | device = isPSPGo ? BROWSE_STATE_INTERNAL : BROWSE_STATE_EXTERNAL; 32 | 33 | if (!FS::FileExists("config.json")) { 34 | cfg = config_t(); 35 | cfg.cwd = isPSPGo? "ef0:" : "ms0:"; 36 | return Config::Save(cfg); 37 | } 38 | 39 | u64 size = FS::GetFileSize("config.json"); 40 | char *buf = new char[size]; 41 | 42 | if (R_FAILED(ret = FS::ReadFile("config.json", buf, size))) { 43 | Log::Error("%s(FS::ReadFile) failed: 0x%08x\n", __func__, ret); 44 | delete[] buf; 45 | return ret; 46 | } 47 | 48 | buf[size] = '\0'; 49 | rapidjson::Document document; 50 | document.Parse(buf); 51 | 52 | if ((!document.IsObject()) || (!document.HasMember("config_ver")) || (!document.HasMember("sort")) || 53 | (!document.HasMember("dark_theme")) || (!document.HasMember("dev_options"))) { 54 | Log::Error("%s failed: Malformed config file, resetting\n", __func__); 55 | cfg = config_t(); 56 | cfg.cwd = isPSPGo? "ef0:" : "ms0:"; 57 | return Config::Save(cfg); 58 | } 59 | 60 | config_version_holder = document["config_ver"].GetInt(); 61 | cfg.sort = document["sort"].GetInt(); 62 | cfg.dark_theme = document["dark_theme"].GetInt(); 63 | cfg.dev_options = document["dev_options"].GetInt(); 64 | 65 | delete[] buf; 66 | 67 | // delete[] config file if config file is updated. This will rarely happen. 68 | if (config_version_holder < config_version) { 69 | sceIoRemove("config.json"); 70 | cfg = config_t(); 71 | cfg.cwd = isPSPGo? "ef0:" : "ms0:"; 72 | return Config::Save(cfg); 73 | } 74 | 75 | return 0; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libs/include/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_ 16 | #define RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(unreachable-code) 23 | RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 51 | void Flush() { RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /libs/include/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_IEEE754_ 16 | #define RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d_(d) {} 27 | Double(uint64_t u) : u_(u) {} 28 | 29 | double Value() const { return d_; } 30 | uint64_t Uint64Value() const { return u_; } 31 | 32 | double NextPositiveDouble() const { 33 | RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u_ + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u_ & kSignMask) != 0; } 38 | uint64_t Significand() const { return u_ & kSignificandMask; } 39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } 40 | 41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } 44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } 45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } 46 | 47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } 50 | 51 | static int EffectiveSignificandSize(int order) { 52 | if (order >= -1021) 53 | return 53; 54 | else if (order <= -1074) 55 | return 0; 56 | else 57 | return order + 1074; 58 | } 59 | 60 | private: 61 | static const int kSignificandSize = 52; 62 | static const int kExponentBias = 0x3FF; 63 | static const int kDenormalExponent = 1 - kExponentBias; 64 | static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 65 | static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 66 | static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 67 | static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 68 | 69 | union { 70 | double d_; 71 | uint64_t u_; 72 | }; 73 | }; 74 | 75 | } // namespace internal 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_IEEE754_ 79 | -------------------------------------------------------------------------------- /app/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "config.h" 6 | #include "g2d.h" 7 | #include "gui.h" 8 | #include "log.h" 9 | #include "textures.h" 10 | #include "utils.h" 11 | 12 | PSP_MODULE_INFO("CMFileManager", 0x800, VERSION_MAJOR, VERSION_MINOR); 13 | PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU); 14 | PSP_HEAP_THRESHOLD_SIZE_KB(1024); 15 | PSP_HEAP_SIZE_KB(-2048); 16 | 17 | bool running = true; 18 | 19 | namespace Services { 20 | int Init(void) { 21 | int ret = 0; 22 | 23 | sceCtrlSetSamplingCycle(0); 24 | sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); 25 | Utils::InitKernelDrivers(); 26 | Textures::Load(); 27 | 28 | Utils::IsMemCardInserted(isMSInserted); 29 | isPSPGo = Utils::IsModelPSPGo(); 30 | 31 | if (R_FAILED(ret = Config::Load())) { 32 | Log::Error("Config::Load failed: 0x%08x\n", ret); 33 | return ret; 34 | } 35 | 36 | if (R_FAILED(ret = intraFontInit())) { 37 | Log::Error("intraFontInit failed: 0x%08x\n", ret); 38 | return ret; 39 | } 40 | 41 | font = intraFontLoad("flash0:/font/ltn8.pgf", INTRAFONT_CACHE_ALL); 42 | G2D::FontSetStyle(1.f, WHITE, INTRAFONT_ALIGN_LEFT); 43 | 44 | // Font size cache 45 | for (int i = 0; i < 256; i++) { 46 | char character[2] = {0}; 47 | character[0] = i; 48 | character[1] = '\0'; 49 | font_size_cache[i] = intraFontMeasureText(font, character); 50 | } 51 | 52 | PSP_CTRL_ENTER = Utils::GetEnterButton(); 53 | PSP_CTRL_CANCEL = Utils::GetCancelButton(); 54 | language = Utils::GetLanguage(); 55 | return 0; 56 | } 57 | 58 | void Exit(void) { 59 | if (sceUmdCheckMedium() != 0) { 60 | int ret = 0; 61 | 62 | if (R_FAILED(ret = sceUmdDeactivate(1, "disc0:"))) 63 | Log::Error("sceUmdDeactivate(disc0) failed: 0x%x\n", ret); 64 | } 65 | 66 | intraFontUnload(font); 67 | Textures::Free(); 68 | Utils::TermKernelDrivers(); 69 | sceKernelExitGame(); 70 | } 71 | 72 | static int ExitCallback(int arg1, int arg2, void *common) { 73 | running = false; 74 | return 0; 75 | } 76 | 77 | static int CallbackThread(SceSize args, void *argp) { 78 | int callback = 0; 79 | callback = sceKernelCreateCallback("ExitCallback", Services::ExitCallback, nullptr); 80 | sceKernelRegisterExitCallback(callback); 81 | sceKernelSleepThreadCB(); 82 | return 0; 83 | } 84 | 85 | int SetupCallbacks(void) { 86 | int thread = 0; 87 | 88 | if (R_SUCCEEDED(thread = sceKernelCreateThread("CallbackThread", Services::CallbackThread, 0x11, 0xFA0, 0, nullptr))) 89 | sceKernelStartThread(thread, 0, 0); 90 | 91 | return thread; 92 | } 93 | } 94 | 95 | int main(int argc, char* argv[]) { 96 | Services::SetupCallbacks(); 97 | Services::Init(); 98 | GUI::RenderLoop(); 99 | Services::Exit(); 100 | } 101 | -------------------------------------------------------------------------------- /app/source/gui/delete.cpp: -------------------------------------------------------------------------------- 1 | #include "colours.h" 2 | #include "config.h" 3 | #include "fs.h" 4 | #include "g2d.h" 5 | #include "gui.h" 6 | #include "textures.h" 7 | #include "utils.h" 8 | 9 | namespace Options { 10 | void Delete(MenuItem &item, int *selection) { 11 | int ret = 0; 12 | 13 | if ((item.checked_count > 1) && (!item.checked_cwd.compare(cfg.cwd))) { 14 | for (u32 i = 0; i < item.checked.size(); i++) { 15 | if (item.checked.at(i)) { 16 | if (R_FAILED(ret = FS::Delete(item.entries[i]))) { 17 | FS::GetDirList(cfg.cwd, item.entries); 18 | GUI::ResetCheckbox(item); 19 | break; 20 | } 21 | } 22 | } 23 | } 24 | else 25 | ret = FS::Delete(item.entries[item.selected]); 26 | 27 | if (R_SUCCEEDED(ret)) { 28 | FS::GetDirList(cfg.cwd, item.entries); 29 | GUI::ResetCheckbox(item); 30 | } 31 | 32 | GUI::GetStorageSize(item); 33 | *selection = 0; 34 | item.selected = 0; 35 | item.state = MENU_STATE_FILEBROWSER; 36 | } 37 | } 38 | 39 | namespace GUI { 40 | static int selection = 0; 41 | static const std::string prompt = "Do you wish to continue?"; 42 | 43 | void DisplayDeleteOptions(void) { 44 | G2D::DrawRect(0, 18, 480, 254, G2D_RGBA(0, 0, 0, cfg.dark_theme? 50: 80)); 45 | G2D::DrawImage(dialog[cfg.dark_theme], ((480 - (dialog[0]->w)) / 2), ((272 - (dialog[0]->h)) / 2)); 46 | G2D::FontSetStyle(1.f, TITLE_COLOUR, INTRAFONT_ALIGN_LEFT); 47 | G2D::DrawText(((480 - (dialog[0]->w)) / 2) + 10, ((272 - (dialog[0]->h)) / 2) + 20, "Delete"); 48 | 49 | int confirm_width = intraFontMeasureText(font, "YES"); 50 | int cancel_width = intraFontMeasureText(font, "NO"); 51 | 52 | if (selection == 0) 53 | G2D::DrawRect((364 - cancel_width) - 5, (180 - (font->texYSize - 15)) - 5, cancel_width + 10, (font->texYSize - 5) + 10, SELECTOR_COLOUR); 54 | else 55 | G2D::DrawRect((409 - (confirm_width)) - 5, (180 - (font->texYSize - 15)) - 5, confirm_width + 10, (font->texYSize - 5) + 10, SELECTOR_COLOUR); 56 | 57 | G2D::DrawText(409 - (confirm_width), (192 - (font->texYSize - 15)) - 3, "YES"); 58 | G2D::DrawText(364 - cancel_width, (192 - (font->texYSize - 15)) - 3, "NO"); 59 | 60 | int prompt_width = intraFontMeasureText(font, prompt.c_str()); 61 | G2D::FontSetStyle(1.f, TEXT_COLOUR, INTRAFONT_ALIGN_LEFT); 62 | G2D::DrawText(((480 - (prompt_width)) / 2), ((272 - (dialog[0]->h)) / 2) + 60, prompt.c_str()); 63 | } 64 | 65 | void ControlDeleteOptions(MenuItem &item, int &ctrl) { 66 | if (ctrl & PSP_CTRL_RIGHT) 67 | selection++; 68 | else if (ctrl & PSP_CTRL_LEFT) 69 | selection--; 70 | 71 | if (Utils::IsButtonPressed(PSP_CTRL_ENTER)) { 72 | if (selection == 1) 73 | Options::Delete(item, &selection); 74 | else 75 | item.state = MENU_STATE_OPTIONS; 76 | 77 | } 78 | else if (Utils::IsButtonPressed(PSP_CTRL_CANCEL)) 79 | item.state = MENU_STATE_OPTIONS; 80 | 81 | Utils::SetBounds(selection, 0, 1); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /libs/include/libccc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libccc.h 3 | * Character Code Conversion Library 4 | * Version 0.31 by BenHur - http://www.psp-programming.com/benhur 5 | * 6 | * This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License. 7 | * See LICENSE for more details. 8 | * 9 | */ 10 | 11 | #ifndef __LIBCCC_H__ 12 | #define __LIBCCC_H__ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /** @defgroup character code conversion library 21 | * @{ 22 | */ 23 | 24 | typedef unsigned short cccUCS2; 25 | typedef unsigned char cccCode; 26 | 27 | /* supported codepages */ 28 | #define CCC_CP000 0x00 //ASCII 29 | #define CCC_CP437 0x01 //US 30 | #define CCC_CP850 0x05 //Multilingual Latin I 31 | #define CCC_CP866 0x0b //Russian 32 | #define CCC_CP932 0x0d //S-JIS 33 | #define CCC_CP936 0x0e //GBK 34 | #define CCC_CP949 0x0f //Korean 35 | #define CCC_CP950 0x10 //Big5 36 | #define CCC_CP1251 0x12 //Cyrillic 37 | #define CCC_CP1252 0x13 //Latin II 38 | #define CCC_CPUTF8 0xff //UTF-8 39 | #define CCC_N_CP 0x14 //number of codepages (for array definition) 40 | 41 | /* error codes */ 42 | #define CCC_SUCCESS 0x00000000 43 | #define CCC_ERROR_BUFFER_SIZE 0x80000104 44 | #define CCC_ERROR_INPUT_STREAM 0x80000108 45 | #define CCC_ERROR_MEM_ALLOC 0x800200D9 46 | #define CCC_ERROR_FILE_READ 0x80020130 47 | #define CCC_ERROR_UNSUPPORTED 0x80020325 48 | 49 | 50 | /** 51 | * Character counting 52 | * 53 | * @param str - zero terminated string 54 | * 55 | * @param cp - codepage 56 | * 57 | * @returns number of characters in the string 58 | */ 59 | int cccStrlen(cccCode const * str); //for single byte character sets 60 | int cccStrlenSJIS(cccCode const * str); 61 | int cccStrlenGBK(cccCode const * str); 62 | int cccStrlenKOR(cccCode const * str); 63 | int cccStrlenBIG5(cccCode const * str); 64 | int cccStrlenUTF8(cccCode const * str); 65 | int cccStrlenCode(cccCode const * str, unsigned char cp); 66 | int cccStrlenUCS2(cccUCS2 const * str); 67 | 68 | /** 69 | * Character code conversion 70 | * 71 | * @param dst - output string 72 | * 73 | * @param count - size of output buffer 74 | * 75 | * @param str - input string 76 | * 77 | * @param cp - codepage 78 | * 79 | * @returns number of converted character codes 80 | */ 81 | int cccSJIStoUCS2(cccUCS2 * dst, size_t count, cccCode const * str); 82 | int cccGBKtoUCS2 (cccUCS2 * dst, size_t count, cccCode const * str); 83 | int cccKORtoUCS2 (cccUCS2 * dst, size_t count, cccCode const * str); 84 | int cccBIG5toUCS2(cccUCS2 * dst, size_t count, cccCode const * str); 85 | int cccUTF8toUCS2(cccUCS2 * dst, size_t count, cccCode const * str); 86 | int cccCodetoUCS2(cccUCS2 * dst, size_t count, cccCode const * str, unsigned char cp); 87 | 88 | /** 89 | * Set error character (character that's used for code points where conversion failed) 90 | * 91 | * @param code - new error character (default: 0) 92 | * 93 | * @returns previous error character 94 | */ 95 | cccUCS2 cccSetErrorCharUCS2(cccUCS2 code); 96 | 97 | /** 98 | * Shutdown the Character Code Conversion Library 99 | */ 100 | void cccShutDown(void); 101 | 102 | /** @} */ 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif // __cplusplus 107 | 108 | #endif // __LIBCCC_H__ 109 | -------------------------------------------------------------------------------- /libs/include/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_ 16 | #define RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | RAPIDJSON_DIAG_OFF(unreachable-code) 25 | RAPIDJSON_DIAG_OFF(missing-noreturn) 26 | #endif 27 | 28 | RAPIDJSON_NAMESPACE_BEGIN 29 | 30 | //! File byte stream for input using fread(). 31 | /*! 32 | \note implements Stream concept 33 | */ 34 | class FileReadStream { 35 | public: 36 | typedef char Ch; //!< Character type (byte). 37 | 38 | //! Constructor. 39 | /*! 40 | \param fp File pointer opened for read. 41 | \param buffer user-supplied buffer. 42 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 43 | */ 44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 45 | RAPIDJSON_ASSERT(fp_ != 0); 46 | RAPIDJSON_ASSERT(bufferSize >= 4); 47 | Read(); 48 | } 49 | 50 | Ch Peek() const { return *current_; } 51 | Ch Take() { Ch c = *current_; Read(); return c; } 52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 53 | 54 | // Not implemented 55 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 56 | void Flush() { RAPIDJSON_ASSERT(false); } 57 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 58 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 59 | 60 | // For encoding detection only. 61 | const Ch* Peek4() const { 62 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 63 | } 64 | 65 | private: 66 | void Read() { 67 | if (current_ < bufferLast_) 68 | ++current_; 69 | else if (!eof_) { 70 | count_ += readCount_; 71 | readCount_ = std::fread(buffer_, 1, bufferSize_, fp_); 72 | bufferLast_ = buffer_ + readCount_ - 1; 73 | current_ = buffer_; 74 | 75 | if (readCount_ < bufferSize_) { 76 | buffer_[readCount_] = '\0'; 77 | ++bufferLast_; 78 | eof_ = true; 79 | } 80 | } 81 | } 82 | 83 | std::FILE* fp_; 84 | Ch *buffer_; 85 | size_t bufferSize_; 86 | Ch *bufferLast_; 87 | Ch *current_; 88 | size_t readCount_; 89 | size_t count_; //!< Number of characters read 90 | bool eof_; 91 | }; 92 | 93 | RAPIDJSON_NAMESPACE_END 94 | 95 | #ifdef __clang__ 96 | RAPIDJSON_DIAG_POP 97 | #endif 98 | 99 | #endif // RAPIDJSON_FILESTREAM_H_ 100 | -------------------------------------------------------------------------------- /libs/include/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(unreachable-code) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of C file stream for output using fwrite(). 29 | /*! 30 | \note implements Stream concept 31 | */ 32 | class FileWriteStream { 33 | public: 34 | typedef char Ch; //!< Character type. Only support char. 35 | 36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 37 | RAPIDJSON_ASSERT(fp_ != 0); 38 | } 39 | 40 | void Put(char c) { 41 | if (current_ >= bufferEnd_) 42 | Flush(); 43 | 44 | *current_++ = c; 45 | } 46 | 47 | void PutN(char c, size_t n) { 48 | size_t avail = static_cast(bufferEnd_ - current_); 49 | while (n > avail) { 50 | std::memset(current_, c, avail); 51 | current_ += avail; 52 | Flush(); 53 | n -= avail; 54 | avail = static_cast(bufferEnd_ - current_); 55 | } 56 | 57 | if (n > 0) { 58 | std::memset(current_, c, n); 59 | current_ += n; 60 | } 61 | } 62 | 63 | void Flush() { 64 | if (current_ != buffer_) { 65 | size_t result = std::fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 66 | if (result < static_cast(current_ - buffer_)) { 67 | // failure deliberately ignored at this time 68 | // added to avoid warn_unused_result build errors 69 | } 70 | current_ = buffer_; 71 | } 72 | } 73 | 74 | // Not implemented 75 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 76 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 77 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 78 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 79 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 80 | 81 | private: 82 | // Prohibit copy constructor & assignment operator. 83 | FileWriteStream(const FileWriteStream&); 84 | FileWriteStream& operator=(const FileWriteStream&); 85 | 86 | std::FILE* fp_; 87 | char *buffer_; 88 | char *bufferEnd_; 89 | char *current_; 90 | }; 91 | 92 | //! Implement specialized version of PutN() with memset() for better performance. 93 | template<> 94 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 95 | stream.PutN(c, n); 96 | } 97 | 98 | RAPIDJSON_NAMESPACE_END 99 | 100 | #ifdef __clang__ 101 | RAPIDJSON_DIAG_POP 102 | #endif 103 | 104 | #endif // RAPIDJSON_FILESTREAM_H_ 105 | -------------------------------------------------------------------------------- /libs/include/rapidjson/internal/pow10.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_POW10_ 16 | #define RAPIDJSON_POW10_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Computes integer powers of 10 in double (10.0^n). 24 | /*! This function uses lookup table for fast and accurate results. 25 | \param n non-negative exponent. Must <= 308. 26 | \return 10.0^n 27 | */ 28 | inline double Pow10(int n) { 29 | static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes 30 | 1e+0, 31 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 32 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 33 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 34 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 35 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 36 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 37 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 38 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 39 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 40 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 41 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 42 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 43 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 44 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 45 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 46 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 47 | }; 48 | RAPIDJSON_ASSERT(n >= 0 && n <= 308); 49 | return e[n]; 50 | } 51 | 52 | } // namespace internal 53 | RAPIDJSON_NAMESPACE_END 54 | 55 | #endif // RAPIDJSON_POW10_ 56 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # CMFileManager PSP [![C/C++ CI](https://github.com/joel16/CMFileManager-PSP/actions/workflows/c-cpp.yml/badge.svg?branch=next)](https://github.com/joel16/CMFileManager-PSP/actions/workflows/c-cpp.yml) ![Github latest downloads](https://img.shields.io/github/downloads/joel16/CMFileManager-PSP/total.svg) 2 | 3 | CMFileManager PSP is a PSP application built using the unofficial PSPSDK and [glib2d (modded)](https://github.com/joel16/gLib2D). The user interface in this homebrew is heavily inspired and based on the LineageOS/CM file manager. The aim of this project is to provide a stable and up to date file manager that makes use of updated tools, whilst offering a modernized and user friendly interace. CMFileManager PSP is the **only** homebrew that properly uses the 'move' function correctly for moving files/folder from one place to another. Unlike other file managers for PSP which copies a file from one place to another and then deletes it, which can take a while depending on the file size. 4 | 5 |

6 | CMFileManager-PSP 7 |

8 | 9 | **Features:** 10 | 11 | - Copy files/folders. 12 | - Move files/folders. 13 | - Delete files/folders. 14 | - Multi file handling functions for copy/move/delete. 15 | - Edit text files. (Supported extensiosn include .JSON, .INI, .CFG, .LOG, .TXT and .MD) 16 | - File properties. (File size, creation time, modification time, access times, permissions) 17 | - Creating directories. 18 | - Renaming files/folders. 19 | - Image viewer (BMP, GIF - non animated, JPG/JPEG, PGM, PPM, PNG, PSG, TGA and TIFF). 20 | - Dark theme mode. 21 | - Extract metadata from homebrew (Eboots) or ISOs. (ICON0.PNG, ICON1.PMF, PIC0.PNG, PIC1.PNG, SND0.AT3) 22 | - Browse other drives like flah0, flash1 and UMD (if not using PSP Go). 23 | - Support for both ef0:/ (internal) and ms0:/ (external) drives on PSP Go. 24 | - Screenshots in .PNG format. Use L + R to capture a screenshot. 25 | - Audio Player 16-Bit short 41K - 48K Hz. (FLAC, IT, MOD, MP3, OGG, OPUS, S3M, WAV and XM) 26 | - FTP connection 27 | - Extract archives (7Z, LZMA, RAR, TAR and ZIP) 28 | 29 | 30 | **FTP Mode Instructions:** 31 | 1. Press *START* to open settings menu and select `FTP connection`. 32 | 3. Select a network connection when the Network dialog pops up. 33 | 4. After it is connected successfully, a message will appear saying `FTP Connection established IP:Port`. Use an FTP client like WinSCP and enter the IP and port (1337) and make sure to use anonymous login. 34 | 6. Once an FTP connection is established from your server, you *may* not see any folders or files. If this is the case, you can manually enter the path of the device like `ip:port/ms0:` (A real example would look something like: `127.0.0.1:1337/ms0:`) 35 | 36 | 37 | **Buttons:** 38 | 39 | - Press *DPAD Up* to move the cursor up. 40 | - Press *DPAD Right* to move the cursor down. 41 | - Press *DPAD Left* to position the cursor to the start of the directory. 42 | - Press *DPAD Right* to position the cursor to the end of the directory. 43 | - Press *Start* to open settings. 44 | - Press *Select* to open menubar. 45 | - Press *Triangle* to bring up file options. 46 | - Press *enter button (depending on your region)* to enter directory/open file. 47 | - Press *cancel button (depending on your region)* to go back to previous directory/menu. 48 | - Press *L + R* to caputre screenshot. 49 | - Press *Home* to display exit dialog. 50 | - Press *Start* on FTP mode or Audio player to disable/enable screen to save battery. 51 | 52 | 53 | **Image Viewer controls:** 54 | - L/R - Rotate anti-clockwise/clockwise 55 | - Up/Down - Zoom in/out 56 | - Select - Help menu 57 | - Left/Right - Previous/Next image 58 | - Analog stick - Position image after zoom 59 | - Triangle - Flip vertically 60 | - Square - Flip horizantally 61 | -------------------------------------------------------------------------------- /libs/include/libtiff/tif_hash_set.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * $Id$ 3 | * 4 | * Name: tif_hash_set.h 5 | * Project: TIFF - Common Portability Library 6 | * Purpose: Hash set functions. 7 | * Author: Even Rouault, 8 | * 9 | ********************************************************************** 10 | * Copyright (c) 2008-2009, Even Rouault 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a 13 | * copy of this software and associated documentation files (the "Software"), 14 | * to deal in the Software without restriction, including without limitation 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 16 | * and/or sell copies of the Software, and to permit persons to whom the 17 | * Software is furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included 20 | * in all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 25 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 | * DEALINGS IN THE SOFTWARE. 29 | ****************************************************************************/ 30 | 31 | #ifndef TIFF_HASH_SET_H_INCLUDED 32 | #define TIFF_HASH_SET_H_INCLUDED 33 | 34 | #include 35 | 36 | /** 37 | * \file tif_hash_set.h 38 | * 39 | * Hash set implementation. 40 | * 41 | * An hash set is a data structure that holds elements that are unique 42 | * according to a comparison function. Operations on the hash set, such as 43 | * insertion, removal or lookup, are supposed to be fast if an efficient 44 | * "hash" function is provided. 45 | */ 46 | 47 | #ifdef __cplusplus 48 | extern "C" 49 | { 50 | #endif 51 | 52 | /* Types */ 53 | 54 | /** Opaque type for a hash set */ 55 | typedef struct _TIFFHashSet TIFFHashSet; 56 | 57 | /** TIFFHashSetHashFunc */ 58 | typedef unsigned long (*TIFFHashSetHashFunc)(const void *elt); 59 | 60 | /** TIFFHashSetEqualFunc */ 61 | typedef bool (*TIFFHashSetEqualFunc)(const void *elt1, const void *elt2); 62 | 63 | /** TIFFHashSetFreeEltFunc */ 64 | typedef void (*TIFFHashSetFreeEltFunc)(void *elt); 65 | 66 | /* Functions */ 67 | 68 | TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc, 69 | TIFFHashSetEqualFunc fnEqualFunc, 70 | TIFFHashSetFreeEltFunc fnFreeEltFunc); 71 | 72 | void TIFFHashSetDestroy(TIFFHashSet *set); 73 | 74 | int TIFFHashSetSize(const TIFFHashSet *set); 75 | 76 | #ifdef notused 77 | void TIFFHashSetClear(TIFFHashSet *set); 78 | 79 | /** TIFFHashSetIterEltFunc */ 80 | typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data); 81 | 82 | void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc, 83 | void *user_data); 84 | #endif 85 | 86 | bool TIFFHashSetInsert(TIFFHashSet *set, void *elt); 87 | 88 | void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt); 89 | 90 | bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt); 91 | 92 | #ifdef notused 93 | bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt); 94 | #endif 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* TIFF_HASH_SET_H_INCLUDED */ 101 | -------------------------------------------------------------------------------- /app/source/audio/opus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "audio.h" 4 | #include "textures.h" 5 | 6 | namespace OPUS { 7 | static OggOpusFile *opus; 8 | static ogg_int64_t samples_read = 0, max_samples = 0; 9 | 10 | int Init(const std::string &path) { 11 | int error = 0; 12 | if ((opus = op_open_file(path.c_str(), &error)) == nullptr) 13 | return -1; 14 | 15 | if ((error = op_current_link(opus)) < 0) 16 | return -1; 17 | 18 | max_samples = op_pcm_total(opus, -1); 19 | const OpusTags *tags = op_tags(opus, 0); 20 | if (opus_tags_query_count(tags, "title") > 0) { 21 | metadata.has_meta = true; 22 | metadata.title = opus_tags_query(tags, "title", 0); 23 | } 24 | 25 | if (opus_tags_query_count(tags, "album") > 0) { 26 | metadata.has_meta = true; 27 | metadata.album = opus_tags_query(tags, "album", 0); 28 | } 29 | 30 | if (opus_tags_query_count(tags, "artist") > 0) { 31 | metadata.has_meta = true; 32 | metadata.artist = opus_tags_query(tags, "artist", 0); 33 | } 34 | 35 | if (opus_tags_query_count(tags, "date") > 0) { 36 | metadata.has_meta = true; 37 | metadata.year = opus_tags_query(tags, "date", 0); 38 | } 39 | 40 | if (opus_tags_query_count(tags, "comment") > 0) { 41 | metadata.has_meta = true; 42 | metadata.comment = opus_tags_query(tags, "comment", 0); 43 | } 44 | 45 | if (opus_tags_query_count(tags, "genre") > 0) { 46 | metadata.has_meta = true; 47 | metadata.genre = opus_tags_query(tags, "genre", 0); 48 | } 49 | 50 | if (opus_tags_query_count(tags, "METADATA_BLOCK_PICTURE") > 0) { 51 | metadata.has_meta = true; 52 | OpusPictureTag picture_tag = { 0 }; 53 | opus_picture_tag_init(&picture_tag); 54 | const char *metadata_block = opus_tags_query(tags, "METADATA_BLOCK_PICTURE", 0); 55 | 56 | int error = opus_picture_tag_parse(&picture_tag, metadata_block); 57 | if (error == 0) { 58 | if (picture_tag.type == 3) { 59 | if (picture_tag.format == OP_PIC_FORMAT_JPEG) 60 | metadata.cover_image = Textures::LoadImageBufferJPEG(picture_tag.data, picture_tag.data_length); 61 | else if (picture_tag.format == OP_PIC_FORMAT_PNG) 62 | metadata.cover_image = Textures::LoadImageBufferPNG(picture_tag.data, picture_tag.data_length); 63 | } 64 | } 65 | 66 | opus_picture_tag_clear(&picture_tag); 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | u32 GetSampleRate(void) { 73 | return 48000; 74 | } 75 | 76 | u8 GetChannels(void) { 77 | return 2; 78 | } 79 | 80 | void Decode(void *buf, unsigned int length, void *userdata) { 81 | int read = op_read_stereo(opus, static_cast(buf), static_cast(length * (sizeof(s16) * 2))); 82 | if (read) 83 | samples_read = op_pcm_tell(opus); 84 | 85 | if (samples_read >= max_samples) 86 | playing = false; 87 | } 88 | 89 | u64 GetPosition(void) { 90 | return samples_read; 91 | } 92 | 93 | u64 GetLength(void) { 94 | return max_samples; 95 | } 96 | 97 | u64 Seek(u64 index) { 98 | if (op_seekable(opus) >= 0) { 99 | ogg_int64_t seek_sample = (max_samples * (index / 225.0)); 100 | 101 | if (op_pcm_seek(opus, seek_sample) >= 0) { 102 | samples_read = seek_sample; 103 | return samples_read; 104 | } 105 | } 106 | 107 | return -1; 108 | } 109 | 110 | void Exit(void) { 111 | samples_read = 0; 112 | op_free(opus); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /libs/include/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 16 | #define RAPIDJSON_STRINGBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 22 | #include // std::move 23 | #endif 24 | 25 | #include "internal/stack.h" 26 | 27 | #if defined(__clang__) 28 | RAPIDJSON_DIAG_PUSH 29 | RAPIDJSON_DIAG_OFF(c++98-compat) 30 | #endif 31 | 32 | RAPIDJSON_NAMESPACE_BEGIN 33 | 34 | //! Represents an in-memory output stream. 35 | /*! 36 | \tparam Encoding Encoding of the stream. 37 | \tparam Allocator type for allocating memory buffer. 38 | \note implements Stream concept 39 | */ 40 | template 41 | class GenericStringBuffer { 42 | public: 43 | typedef typename Encoding::Ch Ch; 44 | 45 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 46 | 47 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 48 | GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {} 49 | GenericStringBuffer& operator=(GenericStringBuffer&& rhs) { 50 | if (&rhs != this) 51 | stack_ = std::move(rhs.stack_); 52 | return *this; 53 | } 54 | #endif 55 | 56 | void Put(Ch c) { *stack_.template Push() = c; } 57 | void PutUnsafe(Ch c) { *stack_.template PushUnsafe() = c; } 58 | void Flush() {} 59 | 60 | void Clear() { stack_.Clear(); } 61 | void ShrinkToFit() { 62 | // Push and pop a null terminator. This is safe. 63 | *stack_.template Push() = '\0'; 64 | stack_.ShrinkToFit(); 65 | stack_.template Pop(1); 66 | } 67 | 68 | void Reserve(size_t count) { stack_.template Reserve(count); } 69 | Ch* Push(size_t count) { return stack_.template Push(count); } 70 | Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe(count); } 71 | void Pop(size_t count) { stack_.template Pop(count); } 72 | 73 | const Ch* GetString() const { 74 | // Push and pop a null terminator. This is safe. 75 | *stack_.template Push() = '\0'; 76 | stack_.template Pop(1); 77 | 78 | return stack_.template Bottom(); 79 | } 80 | 81 | //! Get the size of string in bytes in the string buffer. 82 | size_t GetSize() const { return stack_.GetSize(); } 83 | 84 | //! Get the length of string in Ch in the string buffer. 85 | size_t GetLength() const { return stack_.GetSize() / sizeof(Ch); } 86 | 87 | static const size_t kDefaultCapacity = 256; 88 | mutable internal::Stack stack_; 89 | 90 | private: 91 | // Prohibit copy constructor & assignment operator. 92 | GenericStringBuffer(const GenericStringBuffer&); 93 | GenericStringBuffer& operator=(const GenericStringBuffer&); 94 | }; 95 | 96 | //! String buffer with UTF8 encoding 97 | typedef GenericStringBuffer > StringBuffer; 98 | 99 | template 100 | inline void PutReserve(GenericStringBuffer& stream, size_t count) { 101 | stream.Reserve(count); 102 | } 103 | 104 | template 105 | inline void PutUnsafe(GenericStringBuffer& stream, typename Encoding::Ch c) { 106 | stream.PutUnsafe(c); 107 | } 108 | 109 | //! Implement specialized version of PutN() with memset() for better performance. 110 | template<> 111 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 112 | std::memset(stream.stack_.Push(n), c, n * sizeof(c)); 113 | } 114 | 115 | RAPIDJSON_NAMESPACE_END 116 | 117 | #if defined(__clang__) 118 | RAPIDJSON_DIAG_POP 119 | #endif 120 | 121 | #endif // RAPIDJSON_STRINGBUFFER_H_ 122 | -------------------------------------------------------------------------------- /fs_driver/fs_driver.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "systemctrl.h" 5 | 6 | PSP_MODULE_INFO("fs_driver", PSP_MODULE_KERNEL, 1, 2); 7 | PSP_NO_CREATE_MAIN_THREAD(); 8 | 9 | int pspIoOpenDir(const char *dirname) { 10 | u32 k1 = pspSdkSetK1(0); 11 | int level = sctrlKernelSetUserLevel(8); 12 | 13 | int ret = sceIoDopen(dirname); 14 | 15 | pspSdkSetK1(k1); 16 | sctrlKernelSetUserLevel(level); 17 | return ret; 18 | } 19 | 20 | int pspIoReadDir(SceUID dir, SceIoDirent *dirent) { 21 | u32 k1 = pspSdkSetK1(0); 22 | int level = sctrlKernelSetUserLevel(8); 23 | 24 | int ret = sceIoDread(dir, dirent); 25 | 26 | pspSdkSetK1(k1); 27 | sctrlKernelSetUserLevel(level); 28 | return ret; 29 | } 30 | 31 | int pspIoCloseDir(SceUID dir) { 32 | u32 k1 = pspSdkSetK1(0); 33 | int level = sctrlKernelSetUserLevel(8); 34 | 35 | int ret = sceIoDclose(dir); 36 | 37 | pspSdkSetK1(k1); 38 | sctrlKernelSetUserLevel(level); 39 | return ret; 40 | } 41 | 42 | int pspIoMakeDir(const char *dir, SceMode mode) { 43 | u32 k1 = pspSdkSetK1(0); 44 | int level = sctrlKernelSetUserLevel(8); 45 | 46 | int ret = sceIoMkdir(dir, mode); 47 | 48 | pspSdkSetK1(k1); 49 | sctrlKernelSetUserLevel(level); 50 | return ret; 51 | } 52 | 53 | int pspIoRemoveDir(const char *path) { 54 | u32 k1 = pspSdkSetK1(0); 55 | int level = sctrlKernelSetUserLevel(8); 56 | 57 | int ret = sceIoRmdir(path); 58 | 59 | pspSdkSetK1(k1); 60 | sctrlKernelSetUserLevel(level); 61 | return ret; 62 | } 63 | 64 | int pspIoOpenFile(const char *file, int flags, SceMode mode) { 65 | u32 k1 = pspSdkSetK1(0); 66 | int level = sctrlKernelSetUserLevel(8); 67 | 68 | int ret = sceIoOpen(file, flags, mode); 69 | 70 | pspSdkSetK1(k1); 71 | sctrlKernelSetUserLevel(level); 72 | return ret; 73 | } 74 | 75 | int pspIoReadFile(SceUID file, void *data, SceSize size) { 76 | u32 k1 = pspSdkSetK1(0); 77 | int level = sctrlKernelSetUserLevel(8); 78 | 79 | int ret = sceIoRead(file, data, size); 80 | 81 | pspSdkSetK1(k1); 82 | sctrlKernelSetUserLevel(level); 83 | return ret; 84 | } 85 | 86 | int pspIoWriteFile(SceUID file, const void *data, SceSize size) { 87 | u32 k1 = pspSdkSetK1(0); 88 | int level = sctrlKernelSetUserLevel(8); 89 | 90 | int ret = sceIoWrite(file, data, size); 91 | 92 | pspSdkSetK1(k1); 93 | sctrlKernelSetUserLevel(level); 94 | return ret; 95 | } 96 | 97 | int pspIoCloseFile(SceUID file) { 98 | u32 k1 = pspSdkSetK1(0); 99 | int level = sctrlKernelSetUserLevel(8); 100 | 101 | int ret = sceIoClose(file); 102 | 103 | pspSdkSetK1(k1); 104 | sctrlKernelSetUserLevel(level); 105 | return ret; 106 | } 107 | 108 | int pspIoLseek(SceUID file, SceOff offset, int whence) { 109 | u32 k1 = pspSdkSetK1(0); 110 | int level = sctrlKernelSetUserLevel(8); 111 | 112 | int ret = sceIoLseek(file, offset, whence); 113 | 114 | pspSdkSetK1(k1); 115 | sctrlKernelSetUserLevel(level); 116 | return ret; 117 | } 118 | 119 | int pspIoLseek32(SceUID file, SceOff offset, int whence) { 120 | u32 k1 = pspSdkSetK1(0); 121 | int level = sctrlKernelSetUserLevel(8); 122 | 123 | int ret = sceIoLseek32(file, offset, whence); 124 | 125 | pspSdkSetK1(k1); 126 | sctrlKernelSetUserLevel(level); 127 | return ret; 128 | } 129 | 130 | int pspIoGetstat(const char *file, SceIoStat *stat) { 131 | u32 k1 = pspSdkSetK1(0); 132 | int level = sctrlKernelSetUserLevel(8); 133 | 134 | int ret = sceIoGetstat(file, stat); 135 | 136 | pspSdkSetK1(k1); 137 | sctrlKernelSetUserLevel(level); 138 | return ret; 139 | } 140 | 141 | int pspIoRename(const char *oldname, const char *newname) { 142 | u32 k1 = pspSdkSetK1(0); 143 | int level = sctrlKernelSetUserLevel(8); 144 | 145 | int ret = sceIoRename(oldname, newname); 146 | 147 | pspSdkSetK1(k1); 148 | sctrlKernelSetUserLevel(level); 149 | return ret; 150 | } 151 | 152 | int pspIoRemoveFile(const char *file) { 153 | u32 k1 = pspSdkSetK1(0); 154 | int level = sctrlKernelSetUserLevel(8); 155 | 156 | int ret = sceIoRemove(file); 157 | 158 | pspSdkSetK1(k1); 159 | sctrlKernelSetUserLevel(level); 160 | return ret; 161 | } 162 | 163 | int pspIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen) { 164 | u32 k1 = pspSdkSetK1(0); 165 | int level = sctrlKernelSetUserLevel(8); 166 | 167 | int ret = sceIoDevctl(dev, cmd, indata, inlen, outdata, outlen); 168 | 169 | pspSdkSetK1(k1); 170 | sctrlKernelSetUserLevel(level); 171 | return ret; 172 | } 173 | 174 | int module_start(SceSize args, void *argp) { 175 | return 0; 176 | } 177 | 178 | int module_stop(void) { 179 | return 0; 180 | } 181 | -------------------------------------------------------------------------------- /libs/include/libtiff/tiffconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Configuration defines for installed libtiff. 3 | This file maintained for backward compatibility. Do not use definitions 4 | from this file in your programs. 5 | */ 6 | 7 | /* clang-format off */ 8 | /* clang-format disabled because CMake scripts are very sensitive to the 9 | * formatting of this file. configure_file variables of type "" are 10 | * modified by clang-format and won't be substituted. 11 | */ 12 | 13 | #ifndef _TIFFCONF_ 14 | #define _TIFFCONF_ 15 | 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | /* Signed 16-bit type */ 23 | #define TIFF_INT16_T int16_t 24 | 25 | /* Signed 32-bit type */ 26 | #define TIFF_INT32_T int32_t 27 | 28 | /* Signed 64-bit type */ 29 | #define TIFF_INT64_T int64_t 30 | 31 | /* Signed 8-bit type */ 32 | #define TIFF_INT8_T int8_t 33 | 34 | /* Unsigned 16-bit type */ 35 | #define TIFF_UINT16_T uint16_t 36 | 37 | /* Unsigned 32-bit type */ 38 | #define TIFF_UINT32_T uint32_t 39 | 40 | /* Unsigned 64-bit type */ 41 | #define TIFF_UINT64_T uint64_t 42 | 43 | /* Unsigned 8-bit type */ 44 | #define TIFF_UINT8_T uint8_t 45 | 46 | /* Signed size type */ 47 | #define TIFF_SSIZE_T int32_t 48 | 49 | /* Compatibility stuff. */ 50 | 51 | /* Define as 0 or 1 according to the floating point format supported by the 52 | machine */ 53 | #define HAVE_IEEEFP 1 54 | 55 | /* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1 56 | * this macro will always be hardcoded to FILLORDER_LSB2MSB on all 57 | * architectures, to reflect past long behavior of doing so on x86 architecture. 58 | * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB, 59 | * as mandated per the TIFF specification. 60 | * The influence of HOST_FILLORDER is only when passing the 'H' mode in 61 | * TIFFOpen(). 62 | * You should NOT rely on this macro to decide the CPU endianness! 63 | * This macro will be removed in libtiff 4.6 64 | */ 65 | #define HOST_FILLORDER FILLORDER_LSB2MSB 66 | 67 | /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian 68 | (Intel) */ 69 | #define HOST_BIGENDIAN 0 70 | 71 | /* Support CCITT Group 3 & 4 algorithms */ 72 | #define CCITT_SUPPORT 1 73 | 74 | /* Support JPEG compression (requires IJG JPEG library) */ 75 | #define JPEG_SUPPORT 1 76 | 77 | /* Support JBIG compression (requires JBIG-KIT library) */ 78 | /* #undef JBIG_SUPPORT */ 79 | 80 | /* Support LERC compression */ 81 | /* #undef LERC_SUPPORT */ 82 | 83 | /* Support LogLuv high dynamic range encoding */ 84 | #define LOGLUV_SUPPORT 1 85 | 86 | /* Support LZW algorithm */ 87 | #define LZW_SUPPORT 1 88 | 89 | /* Support NeXT 2-bit RLE algorithm */ 90 | #define NEXT_SUPPORT 1 91 | 92 | /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation 93 | fails with unpatched IJG JPEG library) */ 94 | #define OJPEG_SUPPORT 1 95 | 96 | /* Support Macintosh PackBits algorithm */ 97 | #define PACKBITS_SUPPORT 1 98 | 99 | /* Support Pixar log-format algorithm (requires Zlib) */ 100 | #define PIXARLOG_SUPPORT 1 101 | 102 | /* Support ThunderScan 4-bit RLE algorithm */ 103 | #define THUNDER_SUPPORT 1 104 | 105 | /* Support Deflate compression */ 106 | #define ZIP_SUPPORT 1 107 | 108 | /* Support libdeflate enhanced compression */ 109 | /* #undef LIBDEFLATE_SUPPORT */ 110 | 111 | /* Support strip chopping (whether or not to convert single-strip uncompressed 112 | images to multiple strips of ~8Kb to reduce memory usage) */ 113 | #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP 114 | 115 | /* Enable SubIFD tag (330) support */ 116 | #define SUBIFD_SUPPORT 1 117 | 118 | /* Treat extra sample as alpha (default enabled). The RGBA interface will 119 | treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many 120 | packages produce RGBA files but don't mark the alpha properly. */ 121 | #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 122 | 123 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 124 | lacking the tag (default enabled). */ 125 | #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 126 | 127 | /* Support MS MDI magic number files as TIFF */ 128 | #define MDI_SUPPORT 1 129 | 130 | /* 131 | * Feature support definitions. 132 | * XXX: These macros are obsoleted. Don't use them in your apps! 133 | * Macros stays here for backward compatibility and should be always defined. 134 | */ 135 | #define COLORIMETRY_SUPPORT 136 | #define YCBCR_SUPPORT 137 | #define CMYK_SUPPORT 138 | #define ICC_SUPPORT 139 | #define PHOTOSHOP_SUPPORT 140 | #define IPTC_SUPPORT 141 | 142 | #endif /* _TIFFCONF_ */ 143 | 144 | /* clang-format on */ 145 | -------------------------------------------------------------------------------- /libs/include/rapidjson/istreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_ISTREAMWRAPPER_H_ 16 | #define RAPIDJSON_ISTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | #include 21 | 22 | #ifdef __clang__ 23 | RAPIDJSON_DIAG_PUSH 24 | RAPIDJSON_DIAG_OFF(padded) 25 | #elif defined(_MSC_VER) 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized 28 | #endif 29 | 30 | RAPIDJSON_NAMESPACE_BEGIN 31 | 32 | //! Wrapper of \c std::basic_istream into RapidJSON's Stream concept. 33 | /*! 34 | The classes can be wrapped including but not limited to: 35 | 36 | - \c std::istringstream 37 | - \c std::stringstream 38 | - \c std::wistringstream 39 | - \c std::wstringstream 40 | - \c std::ifstream 41 | - \c std::fstream 42 | - \c std::wifstream 43 | - \c std::wfstream 44 | 45 | \tparam StreamType Class derived from \c std::basic_istream. 46 | */ 47 | 48 | template 49 | class BasicIStreamWrapper { 50 | public: 51 | typedef typename StreamType::char_type Ch; 52 | 53 | //! Constructor. 54 | /*! 55 | \param stream stream opened for read. 56 | */ 57 | BasicIStreamWrapper(StreamType &stream) : stream_(stream), buffer_(peekBuffer_), bufferSize_(4), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 58 | Read(); 59 | } 60 | 61 | //! Constructor. 62 | /*! 63 | \param stream stream opened for read. 64 | \param buffer user-supplied buffer. 65 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 66 | */ 67 | BasicIStreamWrapper(StreamType &stream, char* buffer, size_t bufferSize) : stream_(stream), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 68 | RAPIDJSON_ASSERT(bufferSize >= 4); 69 | Read(); 70 | } 71 | 72 | Ch Peek() const { return *current_; } 73 | Ch Take() { Ch c = *current_; Read(); return c; } 74 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 75 | 76 | // Not implemented 77 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 78 | void Flush() { RAPIDJSON_ASSERT(false); } 79 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 80 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 81 | 82 | // For encoding detection only. 83 | const Ch* Peek4() const { 84 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 85 | } 86 | 87 | private: 88 | BasicIStreamWrapper(); 89 | BasicIStreamWrapper(const BasicIStreamWrapper&); 90 | BasicIStreamWrapper& operator=(const BasicIStreamWrapper&); 91 | 92 | void Read() { 93 | if (current_ < bufferLast_) 94 | ++current_; 95 | else if (!eof_) { 96 | count_ += readCount_; 97 | readCount_ = bufferSize_; 98 | bufferLast_ = buffer_ + readCount_ - 1; 99 | current_ = buffer_; 100 | 101 | if (!stream_.read(buffer_, static_cast(bufferSize_))) { 102 | readCount_ = static_cast(stream_.gcount()); 103 | *(bufferLast_ = buffer_ + readCount_) = '\0'; 104 | eof_ = true; 105 | } 106 | } 107 | } 108 | 109 | StreamType &stream_; 110 | Ch peekBuffer_[4], *buffer_; 111 | size_t bufferSize_; 112 | Ch *bufferLast_; 113 | Ch *current_; 114 | size_t readCount_; 115 | size_t count_; //!< Number of characters read 116 | bool eof_; 117 | }; 118 | 119 | typedef BasicIStreamWrapper IStreamWrapper; 120 | typedef BasicIStreamWrapper WIStreamWrapper; 121 | 122 | #if defined(__clang__) || defined(_MSC_VER) 123 | RAPIDJSON_DIAG_POP 124 | #endif 125 | 126 | RAPIDJSON_NAMESPACE_END 127 | 128 | #endif // RAPIDJSON_ISTREAMWRAPPER_H_ 129 | -------------------------------------------------------------------------------- /libs/include/rapidjson/fwd.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FWD_H_ 16 | #define RAPIDJSON_FWD_H_ 17 | 18 | #include "rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | 22 | // encodings.h 23 | 24 | template struct UTF8; 25 | template struct UTF16; 26 | template struct UTF16BE; 27 | template struct UTF16LE; 28 | template struct UTF32; 29 | template struct UTF32BE; 30 | template struct UTF32LE; 31 | template struct ASCII; 32 | template struct AutoUTF; 33 | 34 | template 35 | struct Transcoder; 36 | 37 | // allocators.h 38 | 39 | class CrtAllocator; 40 | 41 | template 42 | class MemoryPoolAllocator; 43 | 44 | // stream.h 45 | 46 | template 47 | struct GenericStringStream; 48 | 49 | typedef GenericStringStream > StringStream; 50 | 51 | template 52 | struct GenericInsituStringStream; 53 | 54 | typedef GenericInsituStringStream > InsituStringStream; 55 | 56 | // stringbuffer.h 57 | 58 | template 59 | class GenericStringBuffer; 60 | 61 | typedef GenericStringBuffer, CrtAllocator> StringBuffer; 62 | 63 | // filereadstream.h 64 | 65 | class FileReadStream; 66 | 67 | // filewritestream.h 68 | 69 | class FileWriteStream; 70 | 71 | // memorybuffer.h 72 | 73 | template 74 | struct GenericMemoryBuffer; 75 | 76 | typedef GenericMemoryBuffer MemoryBuffer; 77 | 78 | // memorystream.h 79 | 80 | struct MemoryStream; 81 | 82 | // reader.h 83 | 84 | template 85 | struct BaseReaderHandler; 86 | 87 | template 88 | class GenericReader; 89 | 90 | typedef GenericReader, UTF8, CrtAllocator> Reader; 91 | 92 | // writer.h 93 | 94 | template 95 | class Writer; 96 | 97 | // prettywriter.h 98 | 99 | template 100 | class PrettyWriter; 101 | 102 | // document.h 103 | 104 | template 105 | class GenericMember; 106 | 107 | template 108 | class GenericMemberIterator; 109 | 110 | template 111 | struct GenericStringRef; 112 | 113 | template 114 | class GenericValue; 115 | 116 | typedef GenericValue, MemoryPoolAllocator > Value; 117 | 118 | template 119 | class GenericDocument; 120 | 121 | typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document; 122 | 123 | // pointer.h 124 | 125 | template 126 | class GenericPointer; 127 | 128 | typedef GenericPointer Pointer; 129 | 130 | // schema.h 131 | 132 | template 133 | class IGenericRemoteSchemaDocumentProvider; 134 | 135 | template 136 | class GenericSchemaDocument; 137 | 138 | typedef GenericSchemaDocument SchemaDocument; 139 | typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; 140 | 141 | template < 142 | typename SchemaDocumentType, 143 | typename OutputHandler, 144 | typename StateAllocator> 145 | class GenericSchemaValidator; 146 | 147 | typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator; 148 | 149 | RAPIDJSON_NAMESPACE_END 150 | 151 | #endif // RAPIDJSON_RAPIDJSONFWD_H_ 152 | -------------------------------------------------------------------------------- /app/source/screenshot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "fs.h" 9 | #include "utils.h" 10 | 11 | namespace Screenshot { 12 | void WriteFunc(png_structp ptr, png_bytep data, png_size_t length) { 13 | png_voidp p = png_get_io_ptr(ptr); 14 | sceIoWrite(*static_cast(p), data, length); 15 | } 16 | 17 | void Save(const std::string &path) { 18 | u32 *vram32 = nullptr; 19 | u16 *vram16 = nullptr; 20 | int buf_width = 0, pixel_format = 0; 21 | const int SCREEN_WIDTH = 480; 22 | const int SCREEN_HEIGHT = 272; 23 | 24 | SceUID file = 0; 25 | if (R_FAILED(file = sceIoOpen(path.c_str(), PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777))) 26 | return; 27 | 28 | png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); 29 | if (!png_ptr) 30 | return; 31 | 32 | png_infop info_ptr = png_create_info_struct(png_ptr); 33 | if (!info_ptr) { 34 | png_destroy_write_struct(&png_ptr, nullptr); 35 | sceIoClose(file); 36 | return; 37 | } 38 | 39 | png_set_write_fn(png_ptr, static_cast(&file), Screenshot::WriteFunc, nullptr); 40 | png_set_IHDR(png_ptr, info_ptr, SCREEN_WIDTH, SCREEN_HEIGHT, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 41 | png_write_info(png_ptr, info_ptr); 42 | 43 | u8 *line = new u8 [SCREEN_WIDTH * 3]; 44 | sceDisplayWaitVblankStart(); 45 | sceDisplayGetFrameBuf(reinterpret_cast(&vram32), &buf_width, &pixel_format, 0); 46 | vram16 = reinterpret_cast(vram32); 47 | 48 | for (int y = 0; y < SCREEN_HEIGHT; y++) { 49 | for (int i = 0, x = 0; x < SCREEN_WIDTH; x++) { 50 | u32 color = 0; 51 | u8 r = 0, g = 0, b = 0; 52 | switch (pixel_format) { 53 | case PSP_DISPLAY_PIXEL_FORMAT_565: 54 | color = vram16[x + y * buf_width]; 55 | r = (color & 0x1f) << 3; 56 | g = ((color >> 5) & 0x3f) << 2 ; 57 | b = ((color >> 11) & 0x1f) << 3 ; 58 | break; 59 | 60 | case PSP_DISPLAY_PIXEL_FORMAT_5551: 61 | color = vram16[x + y * buf_width]; 62 | r = (color & 0x1f) << 3; 63 | g = ((color >> 5) & 0x1f) << 3 ; 64 | b = ((color >> 10) & 0x1f) << 3 ; 65 | break; 66 | 67 | case PSP_DISPLAY_PIXEL_FORMAT_4444: 68 | color = vram16[x + y * buf_width]; 69 | r = (color & 0xf) << 4; 70 | g = ((color >> 4) & 0xf) << 4 ; 71 | b = ((color >> 8) & 0xf) << 4 ; 72 | break; 73 | 74 | case PSP_DISPLAY_PIXEL_FORMAT_8888: 75 | color = vram32[x + y * buf_width]; 76 | r = color & 0xff; 77 | g = (color >> 8) & 0xff; 78 | b = (color >> 16) & 0xff; 79 | break; 80 | } 81 | 82 | line[i++] = r; 83 | line[i++] = g; 84 | line[i++] = b; 85 | } 86 | 87 | png_write_row(png_ptr, line); 88 | } 89 | 90 | delete[] line; 91 | png_write_end(png_ptr, info_ptr); 92 | png_destroy_write_struct(&png_ptr, nullptr); 93 | sceIoClose(file); 94 | } 95 | 96 | int Capture(void) { 97 | int ret = 0; 98 | ScePspDateTime time; 99 | 100 | if (R_FAILED(ret = sceRtcGetCurrentClockLocalTime(&time))) 101 | return ret; 102 | 103 | if (!(FS::DirExists(Utils::IsInternalStorage()? "ef0:/PSP/PHOTO/CMFileManager/" : "ms0:/PSP/PHOTO/CMFileManager/"))) 104 | FS::RecursiveMakeDir(Utils::IsInternalStorage()? "ef0:/PSP/PHOTO/CMFileManager" : "ms0:/PSP/PHOTO/CMFileManager"); 105 | 106 | static char path[128]; 107 | std::snprintf(path, 128, Utils::IsInternalStorage()? "ef0:/PSP/PHOTO/CMFileManager/screenshot_%02d%02d%02d-%i.bmp" : 108 | "ms0:/PSP/PHOTO/CMFileManager/screenshot_%02d%02d%02d-%02d%02d%02d.png", time.year, time.month, time.day, time.hour, time.minute, time.second); 109 | 110 | Screenshot::Save(path); 111 | return 0; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /app/source/audio/ogg.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "audio.h" 6 | #include "utils.h" 7 | 8 | namespace OGG { 9 | static OggVorbis_File ogg; 10 | static SceUID ogg_file = 0; 11 | static vorbis_info *ogg_info = nullptr; 12 | static ogg_int64_t samples_read = 0, max_lenth = 0; 13 | 14 | size_t ogg_callback_read(void *ptr, size_t size, size_t count, void *stream) { 15 | return sceIoRead(*reinterpret_cast(stream), ptr, size * count); 16 | } 17 | 18 | int ogg_callback_seek(void *stream, ogg_int64_t offset, int whence) { 19 | return sceIoLseek32(*reinterpret_cast(stream), static_cast(offset), whence); 20 | } 21 | 22 | int ogg_callback_close(void *stream) { 23 | return sceIoClose(*reinterpret_cast(stream)); 24 | } 25 | 26 | long ogg_callback_tell(void *stream) { 27 | return sceIoLseek32(*reinterpret_cast(stream), 0, PSP_SEEK_CUR); 28 | } 29 | 30 | int Init(const std::string &path) { 31 | if (R_FAILED(ogg_file = sceIoOpen(path.c_str(), PSP_O_RDONLY, 0777))) 32 | return -1; 33 | 34 | ov_callbacks ogg_callbacks; 35 | ogg_callbacks.read_func = ogg_callback_read; 36 | ogg_callbacks.seek_func = ogg_callback_seek; 37 | ogg_callbacks.close_func = ogg_callback_close; 38 | ogg_callbacks.tell_func = ogg_callback_tell; 39 | 40 | if (R_FAILED(ov_open_callbacks(&ogg_file, &ogg, nullptr, 0, ogg_callbacks))) { 41 | sceIoClose(ogg_file); 42 | return -1; 43 | } 44 | 45 | if ((ogg_info = ov_info(&ogg, -1)) == nullptr) 46 | return -1; 47 | 48 | max_lenth = ov_pcm_total(&ogg, -1); 49 | vorbis_comment *comment = ov_comment(&ogg, -1); 50 | 51 | if (comment != nullptr) { 52 | metadata.has_meta = true; 53 | char *value = nullptr; 54 | 55 | if ((value = vorbis_comment_query(comment, "title", 0)) != nullptr) 56 | metadata.title = value; 57 | 58 | if ((value = vorbis_comment_query(comment, "album", 0)) != nullptr) 59 | metadata.album = value; 60 | 61 | if ((value = vorbis_comment_query(comment, "artist", 0)) != nullptr) 62 | metadata.artist = value; 63 | 64 | if ((value = vorbis_comment_query(comment, "year", 0)) != nullptr) 65 | metadata.year = value; 66 | 67 | if ((value = vorbis_comment_query(comment, "comment", 0)) != nullptr) 68 | metadata.comment = value; 69 | 70 | if ((value = vorbis_comment_query(comment, "genre", 0)) != nullptr) 71 | metadata.genre = value; 72 | } 73 | 74 | return 0; 75 | } 76 | 77 | u32 GetSampleRate(void) { 78 | return ogg_info->rate; 79 | } 80 | 81 | u8 GetChannels(void) { 82 | return ogg_info->channels; 83 | } 84 | 85 | static u64 FillBuffer(char *out) { 86 | u64 samples_read = 0; 87 | int samples_to_read = (sizeof(s16) * ogg_info->channels) * 960; 88 | 89 | while(samples_to_read > 0) { 90 | static int current_section; 91 | int samples_just_read = ov_read(&ogg, out, samples_to_read > 960 ? 960 : samples_to_read, 0, 2, 1, ¤t_section); 92 | 93 | if (samples_just_read < 0) 94 | return samples_just_read; 95 | else if (samples_just_read == 0) 96 | break; 97 | 98 | samples_read += samples_just_read; 99 | samples_to_read -= samples_just_read; 100 | out += samples_just_read; 101 | } 102 | 103 | return samples_read / sizeof(s16); 104 | } 105 | 106 | void Decode(void *buf, unsigned int length, void *userdata) { 107 | OGG::FillBuffer(static_cast(buf)); 108 | samples_read = ov_pcm_tell(&ogg); 109 | 110 | if (samples_read >= max_lenth) 111 | playing = false; 112 | } 113 | 114 | u64 GetPosition(void) { 115 | return samples_read; 116 | } 117 | 118 | u64 GetLength(void) { 119 | return max_lenth; 120 | } 121 | 122 | u64 Seek(u64 index) { 123 | ogg_int64_t seek_sample = (max_lenth * (index / 225.0)); 124 | 125 | if (ov_pcm_seek(&ogg, seek_sample) >= 0) { 126 | samples_read = seek_sample; 127 | return samples_read; 128 | } 129 | 130 | return -1; 131 | } 132 | 133 | void Exit(void) { 134 | samples_read = 0; 135 | ov_clear(&ogg); 136 | sceIoClose(ogg_file); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /libs/include/kubridge.h: -------------------------------------------------------------------------------- 1 | #ifndef __KULIBRARY__ 2 | #define __KULIBRARY__ 3 | 4 | #if defined (__cplusplus) 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * Functions to let user mode access certain functions only available in 15 | * kernel mode 16 | */ 17 | 18 | /** 19 | * Load a module using ModuleMgrForKernel. 20 | * 21 | * @param path - The path to the module to load. 22 | * @param flags - Unused, always 0 . 23 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 24 | * 25 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 26 | */ 27 | SceUID kuKernelLoadModule(const char *path, int flags, SceKernelLMOption *option); 28 | 29 | 30 | /** 31 | * Load a module with a specific apitype 32 | * 33 | * @param ap�type - The apitype 34 | * @param path - The path to the module to load. 35 | * @param flags - Unused, always 0 . 36 | * @param option - Pointer to a mod_param_t structure. Can be NULL. 37 | * 38 | * @returns The UID of the loaded module on success, otherwise one of ::PspKernelErrorCodes. 39 | */ 40 | SceUID kuKernelLoadModuleWithApitype2(int apitype, const char *path, int flags, SceKernelLMOption *option); 41 | 42 | /** 43 | * Gets the api type 44 | * 45 | * @returns the api type in which the system has booted 46 | */ 47 | int kuKernelInitApitype(); 48 | 49 | /** 50 | * Gets the filename of the executable to be launched after all modules of the api. 51 | * 52 | * @param initfilename - String where copy the initfilename 53 | * @returns 0 on success 54 | */ 55 | int kuKernelInitFileName(char *initfilename); 56 | 57 | /** 58 | * 59 | * Gets the device in which the application was launched. 60 | * 61 | * @returns the device code, one of PSPBootFrom values. 62 | */ 63 | int kuKernelBootFrom(); 64 | 65 | /** 66 | * Get the key configuration in which the system has booted. 67 | * 68 | * @returns the key configuration code, one of PSPKeyConfig values 69 | */ 70 | int kuKernelInitKeyConfig(); 71 | 72 | /** 73 | * Get the user level of the current thread 74 | * 75 | * @return The user level, < 0 on error 76 | */ 77 | int kuKernelGetUserLevel(void); 78 | 79 | /** 80 | * Set the protection of a block of ddr memory 81 | * 82 | * @param addr - Address to set protection on 83 | * @param size - Size of block 84 | * @param prot - Protection bitmask 85 | * 86 | * @return < 0 on error 87 | */ 88 | int kuKernelSetDdrMemoryProtection(void *addr, int size, int prot); 89 | 90 | /** 91 | * Gets the model of the PSP from user mode. 92 | * This function is available since 3.60 M33. 93 | * In previous version, use the kernel function sceKernelGetModel 94 | * 95 | * @return one of PspModel values 96 | */ 97 | int kuKernelGetModel(void); 98 | 99 | /** 100 | * Find module by name 101 | * 102 | * @param modname - Name of Module 103 | * @param mod - module structure for output (actually treated as SceModule2) 104 | * 105 | * @return < 0 on error 106 | */ 107 | int kuKernelFindModuleByName(char *modname, SceModule *mod); 108 | 109 | /** 110 | * Invalidate the entire instruction cache 111 | */ 112 | void kuKernelIcacheInvalidateAll(void); 113 | 114 | /** 115 | * Read 4 bytes from memory (with kernel memory access) 116 | * 117 | * @param addr - Address to read, must have 4 bytes alignment 118 | */ 119 | u32 kuKernelPeekw(void *addr); 120 | 121 | /** 122 | * Write 4 bytes to memory (with kernel memory access) 123 | * 124 | * @param addr - Address to write, must have 4 bytes alignment 125 | */ 126 | void kuKernelPokew(void *addr, u32 value); 127 | 128 | /** 129 | * memcpy (with kernel memory access) 130 | * 131 | * @param dest - Destination address 132 | * @param src - Source address 133 | * @param num - copy bytes count 134 | * 135 | * @return Destination address 136 | */ 137 | void *kuKernelMemcpy(void *dest, const void *src, size_t num); 138 | 139 | struct KernelCallArg { 140 | u32 arg1; 141 | u32 arg2; 142 | u32 arg3; 143 | u32 arg4; 144 | u32 arg5; 145 | u32 arg6; 146 | u32 arg7; 147 | u32 arg8; 148 | u32 arg9; 149 | u32 arg10; 150 | u32 arg11; 151 | u32 arg12; 152 | u32 ret1; 153 | u32 ret2; 154 | }; 155 | 156 | /** 157 | * Call a kernel function with kernel privilege 158 | * 159 | * @param func_addr - kernel function address 160 | * @param args - kernel arguments and return values 161 | * 162 | * return < 0 on error 163 | */ 164 | int kuKernelCall(void *func_addr, struct KernelCallArg *args); 165 | 166 | /** 167 | * Call a kernel function with kernel privilege and extended stack 168 | * 169 | * @param func_addr - kernel function address 170 | * @param args - kernel arguments and return values 171 | * 172 | * return < 0 on error 173 | */ 174 | int kuKernelCallExtendStack(void *func_addr, struct KernelCallArg *args, int stack_size); 175 | 176 | void kuKernelGetUmdFile(char *umdfile, int size); 177 | 178 | #if defined (__cplusplus) 179 | } 180 | #endif 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /libs/include/libtiff/tif_config.h: -------------------------------------------------------------------------------- 1 | /* clang-format off */ 2 | /* clang-format disabled because CMake scripts are very sensitive to the 3 | * formatting of this file. configure_file variables of type "" are 4 | * modified by clang-format and won't be substituted. 5 | */ 6 | 7 | /* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ 8 | /* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ 9 | 10 | #include "tiffconf.h" 11 | 12 | /* Support CCITT Group 3 & 4 algorithms */ 13 | #define CCITT_SUPPORT 1 14 | 15 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 16 | lacking the tag (default enabled). */ 17 | #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 18 | 19 | /* enable partial strip reading for large strips (experimental) */ 20 | /* #undef CHUNKY_STRIP_READ_SUPPORT */ 21 | 22 | /* Support C++ stream API (requires C++ compiler) */ 23 | #define CXX_SUPPORT 1 24 | 25 | /* enable deferred strip/tile offset/size loading (experimental) */ 26 | /* #undef DEFER_STRILE_LOAD */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_ASSERT_H 1 30 | 31 | /* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ 32 | #define HAVE_DECL_OPTARG 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_FCNTL_H 1 36 | 37 | /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ 38 | /* #undef HAVE_FSEEKO */ 39 | 40 | /* Define to 1 if you have the `getopt' function. */ 41 | #define HAVE_GETOPT 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | /* #undef HAVE_GLUT_GLUT_H */ 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_GL_GLUT_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_GL_GLU_H 1 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_GL_GL_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | /* #undef HAVE_IO_H */ 57 | 58 | /* Define to 1 if you have the `jbg_newlen' function. */ 59 | /* #undef HAVE_JBG_NEWLEN */ 60 | 61 | /* Define to 1 if you have the `mmap' function. */ 62 | /* #undef HAVE_MMAP */ 63 | 64 | /* Define to 1 if you have the header file. */ 65 | /* #undef HAVE_OPENGL_GLU_H */ 66 | 67 | /* Define to 1 if you have the header file. */ 68 | /* #undef HAVE_OPENGL_GL_H */ 69 | 70 | /* Define to 1 if you have the `setmode' function. */ 71 | /* #undef HAVE_SETMODE */ 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_STRINGS_H 1 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #define HAVE_SYS_TYPES_H 1 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_UNISTD_H 1 81 | 82 | /* 8/12 bit libjpeg dual mode enabled */ 83 | /* #undef JPEG_DUAL_MODE_8_12 */ 84 | 85 | /* Support LERC compression */ 86 | /* #undef LERC_SUPPORT */ 87 | 88 | /* 12bit libjpeg primary include file with path */ 89 | #define LIBJPEG_12_PATH "" 90 | 91 | /* Support LZMA2 compression */ 92 | #define LZMA_SUPPORT 1 93 | 94 | /* Name of package */ 95 | #define PACKAGE "LibTIFF Software" 96 | 97 | /* Define to the address where bug reports for this package should be sent. */ 98 | #define PACKAGE_BUGREPORT "tiff@lists.osgeo.org" 99 | 100 | /* Define to the full name of this package. */ 101 | #define PACKAGE_NAME "LibTIFF Software" 102 | 103 | /* Define to the one symbol short name of this package. */ 104 | #define PACKAGE_TARNAME "tiff" 105 | 106 | /* Define to the home page for this package. */ 107 | #define PACKAGE_URL "" 108 | 109 | /* Size of size_t */ 110 | #define SIZEOF_SIZE_T 4 111 | 112 | /* Default size of the strip in bytes (when strip chopping enabled) */ 113 | #define STRIP_SIZE_DEFAULT 8192 114 | 115 | /** Maximum number of TIFF IFDs that libtiff can iterate through in a file. */ 116 | #define TIFF_MAX_DIR_COUNT 1048576 117 | 118 | /* define to use win32 IO system */ 119 | /* #undef USE_WIN32_FILEIO */ 120 | 121 | /* Support WEBP compression */ 122 | /* #undef WEBP_SUPPORT */ 123 | 124 | /* Support ZSTD compression */ 125 | /* #undef ZSTD_SUPPORT */ 126 | 127 | 128 | /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 129 | significant byte first (like Motorola and SPARC, unlike Intel). */ 130 | #if defined AC_APPLE_UNIVERSAL_BUILD 131 | # if defined __BIG_ENDIAN__ 132 | # define WORDS_BIGENDIAN 1 133 | # endif 134 | #else 135 | # ifndef WORDS_BIGENDIAN 136 | # undef WORDS_BIGENDIAN 137 | # endif 138 | #endif 139 | 140 | #if !defined(__MINGW32__) 141 | # define TIFF_SIZE_FORMAT "zu" 142 | #endif 143 | #if SIZEOF_SIZE_T == 8 144 | # define TIFF_SSIZE_FORMAT PRId64 145 | # if defined(__MINGW32__) 146 | # define TIFF_SIZE_FORMAT PRIu64 147 | # endif 148 | #elif SIZEOF_SIZE_T == 4 149 | # define TIFF_SSIZE_FORMAT PRId32 150 | # if defined(__MINGW32__) 151 | # define TIFF_SIZE_FORMAT PRIu32 152 | # endif 153 | #else 154 | # error "Unsupported size_t size; please submit a bug report" 155 | #endif 156 | 157 | /* clang-format on */ 158 | -------------------------------------------------------------------------------- /app/source/gui/archive_helper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "colours.h" 8 | #include "config.h" 9 | #include "fs.h" 10 | #include "g2d.h" 11 | #include "gui.h" 12 | #include "log.h" 13 | #include "textures.h" 14 | #include "utils.h" 15 | 16 | namespace ArchiveHelper { 17 | u64 CountFiles(const std::string &path) { 18 | int ret = 0; 19 | u64 count = 0; 20 | 21 | struct archive *arch = archive_read_new(); 22 | archive_read_support_format_all(arch); 23 | 24 | if ((ret = archive_read_open_filename(arch, path.c_str(), 0x3000)) != ARCHIVE_OK) { 25 | archive_read_close(arch); 26 | archive_read_free(arch); 27 | return ret; 28 | } 29 | 30 | struct archive_entry *entry; 31 | while((ret = archive_read_next_header(arch, &entry)) == ARCHIVE_OK) { 32 | count++; 33 | } 34 | 35 | archive_read_close(arch); 36 | archive_read_free(arch); 37 | return count; 38 | } 39 | 40 | static int CopyData(struct archive *src, struct archive *dest) { 41 | int ret = 0; 42 | const void *buff = nullptr; 43 | size_t size = 0; 44 | int64_t offset = 0; 45 | 46 | for (;;) { 47 | ret = archive_read_data_block(src, &buff, &size, &offset); 48 | if (ret == ARCHIVE_EOF) { 49 | return ARCHIVE_OK; 50 | } 51 | 52 | if (ret != ARCHIVE_OK) { 53 | return ret; 54 | } 55 | 56 | ret = archive_write_data_block(dest, buff, size, offset); 57 | if (ret != ARCHIVE_OK) { 58 | return ret; 59 | } 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | static void FreeHandles(struct archive *read, struct archive *write) { 66 | archive_read_close(read); 67 | archive_read_free(read); 68 | archive_write_close(write); 69 | archive_write_free(write); 70 | scePowerUnlock(0); 71 | } 72 | 73 | int Extract(const std::string &path) { 74 | int ret = 0; 75 | scePowerLock(0); 76 | 77 | int flags = ARCHIVE_EXTRACT_TIME; 78 | flags |= ARCHIVE_EXTRACT_PERM; 79 | flags |= ARCHIVE_EXTRACT_ACL; 80 | flags |= ARCHIVE_EXTRACT_FFLAGS; 81 | 82 | struct archive *arch = archive_read_new(); 83 | archive_read_support_format_all(arch); 84 | 85 | struct archive *ext = archive_write_disk_new(); 86 | archive_write_disk_set_options(ext, flags); 87 | 88 | struct archive_entry *entry = nullptr; 89 | 90 | if ((ret = archive_read_open_filename(arch, path.c_str(), 0x3000)) != ARCHIVE_OK) { 91 | Log::Error("archive_read_open_filename(%s) failed: %s\n", path.c_str(), archive_error_string(arch)); 92 | ArchiveHelper::FreeHandles(arch, ext); 93 | return ret; 94 | } 95 | 96 | u64 index = 0, count = ArchiveHelper::CountFiles(path); 97 | std::string filename = std::filesystem::path(path).filename(); 98 | std::string dest = cfg.cwd; 99 | dest.append("/"); 100 | dest.append(std::filesystem::path(path).stem()); 101 | FS::MakeDir(dest); 102 | 103 | for (;;) { 104 | if (Utils::IsCancelButtonPressed()) { 105 | ArchiveHelper::FreeHandles(arch, ext); 106 | return 0; 107 | } 108 | 109 | ret = archive_read_next_header(arch, &entry); 110 | if (ret == ARCHIVE_EOF) { 111 | break; 112 | } 113 | 114 | if (ret != ARCHIVE_OK) { 115 | Log::Error("archive_read_next_header(%s) failed: %s\n", path.c_str(), archive_error_string(arch)); 116 | ArchiveHelper::FreeHandles(arch, ext); 117 | return ret; 118 | } 119 | 120 | const char *entry_name = archive_entry_pathname(entry); 121 | std::string dest_path = dest + "/"; 122 | dest_path.append(entry_name); 123 | 124 | archive_entry_update_pathname_utf8(entry, dest_path.c_str()); 125 | ret = archive_write_header(ext, entry); 126 | 127 | if (ret < ARCHIVE_OK) { 128 | Log::Error("archive_write_header(%s) failed: %s\n", dest_path.c_str(), archive_error_string(arch)); 129 | ArchiveHelper::FreeHandles(arch, ext); 130 | return ret; 131 | } 132 | else if (archive_entry_size(entry) > 0) { 133 | ret = ArchiveHelper::CopyData(arch, ext); 134 | if (ret != ARCHIVE_OK) { 135 | Log::Error("ArchiveHelper::CopyData(%s) failed: %s\n", dest_path.c_str(), archive_error_string(arch)); 136 | ArchiveHelper::FreeHandles(arch, ext); 137 | return ret; 138 | } 139 | } 140 | 141 | archive_write_finish_entry(ext); 142 | GUI::ProgressBar("Extracting", filename, index, count); 143 | index++; 144 | } 145 | 146 | ArchiveHelper::FreeHandles(arch, ext); 147 | return 0; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /libs/libnsgif/lzw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of NetSurf's LibNSGIF, http://www.netsurf-browser.org/ 3 | * Licensed under the MIT License, 4 | * http://www.opensource.org/licenses/mit-license.php 5 | * 6 | * Copyright 2017 Michael Drake 7 | * Copyright 2021 Michael Drake 8 | */ 9 | 10 | #ifndef LZW_H_ 11 | #define LZW_H_ 12 | 13 | /** 14 | * \file 15 | * \brief LZW decompression (interface) 16 | * 17 | * Decoder for GIF LZW data. 18 | */ 19 | 20 | /** Maximum LZW code size in bits */ 21 | #define LZW_CODE_MAX 12 22 | 23 | /* Declare lzw internal context structure */ 24 | struct lzw_ctx; 25 | 26 | /** LZW decoding response codes */ 27 | typedef enum lzw_result { 28 | LZW_OK, /**< Success */ 29 | LZW_OK_EOD, /**< Success; reached zero-length sub-block */ 30 | LZW_NO_MEM, /**< Error: Out of memory */ 31 | LZW_NO_DATA, /**< Error: Out of data */ 32 | LZW_EOI_CODE, /**< Error: End of Information code */ 33 | LZW_NO_COLOUR, /**< Error: No colour map provided. */ 34 | LZW_BAD_ICODE, /**< Error: Bad initial LZW code */ 35 | LZW_BAD_PARAM, /**< Error: Bad function parameter. */ 36 | LZW_BAD_CODE, /**< Error: Bad LZW code */ 37 | } lzw_result; 38 | 39 | /** 40 | * Create an LZW decompression context. 41 | * 42 | * \param[out] ctx Returns an LZW decompression context. Caller owned, 43 | * free with lzw_context_destroy(). 44 | * \return LZW_OK on success, or appropriate error code otherwise. 45 | */ 46 | lzw_result lzw_context_create( 47 | struct lzw_ctx **ctx); 48 | 49 | /** 50 | * Destroy an LZW decompression context. 51 | * 52 | * \param[in] ctx The LZW decompression context to destroy. 53 | */ 54 | void lzw_context_destroy( 55 | struct lzw_ctx *ctx); 56 | 57 | /** 58 | * Initialise an LZW decompression context for decoding. 59 | * 60 | * \param[in] ctx The LZW decompression context to initialise. 61 | * \param[in] minimum_code_size The LZW Minimum Code Size. 62 | * \param[in] input_data The compressed data. 63 | * \param[in] input_length Byte length of compressed data. 64 | * \param[in] input_pos Start position in data. Must be position 65 | * of a size byte at sub-block start. 66 | * \return LZW_OK on success, or appropriate error code otherwise. 67 | */ 68 | lzw_result lzw_decode_init( 69 | struct lzw_ctx *ctx, 70 | uint8_t minimum_code_size, 71 | const uint8_t *input_data, 72 | size_t input_length, 73 | size_t input_pos); 74 | 75 | /** 76 | * Read input codes until end of LZW context owned output buffer. 77 | * 78 | * Ensure anything in output is used before calling this, as anything 79 | * there before this call will be trampled. 80 | * 81 | * \param[in] ctx LZW reading context, updated. 82 | * \param[out] output_data Returns pointer to array of output values. 83 | * \param[out] output_written Returns the number of values written to data. 84 | * \return LZW_OK on success, or appropriate error code otherwise. 85 | */ 86 | lzw_result lzw_decode(struct lzw_ctx *ctx, 87 | const uint8_t *restrict *const restrict output_data, 88 | uint32_t *restrict output_written); 89 | 90 | /** 91 | * Initialise an LZW decompression context for decoding to colour map values. 92 | * 93 | * For transparency to work correctly, the given client buffer must have 94 | * the values from the previous frame. The transparency_idx should be a value 95 | * of 256 or above, if the frame does not have transparency. 96 | * 97 | * \param[in] ctx The LZW decompression context to initialise. 98 | * \param[in] minimum_code_size The LZW Minimum Code Size. 99 | * \param[in] transparency_idx Index representing transparency. 100 | * \param[in] colour_table Index to pixel colour mapping. 101 | * \param[in] input_data The compressed data. 102 | * \param[in] input_length Byte length of compressed data. 103 | * \param[in] input_pos Start position in data. Must be position 104 | * of a size byte at sub-block start. 105 | * \return LZW_OK on success, or appropriate error code otherwise. 106 | */ 107 | lzw_result lzw_decode_init_map( 108 | struct lzw_ctx *ctx, 109 | uint8_t minimum_code_size, 110 | uint32_t transparency_idx, 111 | const uint32_t *colour_table, 112 | const uint8_t *input_data, 113 | size_t input_length, 114 | size_t input_pos); 115 | 116 | /** 117 | * Read LZW codes into client buffer, mapping output to colours. 118 | * 119 | * The context must have been initialised using \ref lzw_decode_init_map 120 | * before calling this function, in order to provide the colour mapping table 121 | * and any transparency index. 122 | * 123 | * Ensure anything in output is used before calling this, as anything 124 | * there before this call will be trampled. 125 | * 126 | * \param[in] ctx LZW reading context, updated. 127 | * \param[in] output_data Client buffer to fill with colour mapped values. 128 | * \param[in] output_length Size of output array. 129 | * \param[out] output_written Returns the number of values written to data. 130 | * \return LZW_OK on success, or appropriate error code otherwise. 131 | */ 132 | lzw_result lzw_decode_map(struct lzw_ctx *ctx, 133 | uint32_t *restrict output_data, 134 | uint32_t output_length, 135 | uint32_t *restrict output_written); 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /app/source/g2d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "g2d.h" 8 | #include "log.h" 9 | #include "utils.h" 10 | 11 | intraFont *font; 12 | 13 | namespace G2D { 14 | void DrawRect(float x, float y, float width, float height, g2dColor colour) { 15 | g2dBeginRects(nullptr); { 16 | g2dSetColor(colour); 17 | g2dSetScaleWH(width, height); 18 | g2dSetCoordXY(x, y); 19 | g2dAdd(); 20 | } 21 | g2dEnd(); 22 | } 23 | 24 | void DrawImage(g2dTexture *tex, float x, float y) { 25 | g2dBeginRects(tex); { 26 | g2dSetCoordXY(x, y); 27 | g2dAdd(); 28 | } 29 | g2dEnd(); 30 | } 31 | 32 | void DrawImageScale(g2dTexture *tex, float x, float y, float w, float h) { 33 | g2dBeginRects(tex); { 34 | g2dSetScaleWH(w, h); 35 | g2dSetCoordXY(x, y); 36 | g2dAdd(); 37 | } 38 | g2dEnd(); 39 | } 40 | 41 | static int GetText(char *input, unsigned short *intext, unsigned short *desc) { 42 | int ret = 0; 43 | bool done = false; 44 | unsigned short outtext[128] = { 0 }; 45 | 46 | SceUtilityOskData data; 47 | std::memset(&data, 0, sizeof(SceUtilityOskData)); 48 | 49 | data.language = PSP_UTILITY_OSK_LANGUAGE_DEFAULT; // Use system default for text input 50 | data.lines = 1; 51 | data.unk_24 = 1; 52 | data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; // Allow all input types 53 | data.desc = desc; 54 | data.intext = intext; 55 | data.outtextlength = 128; 56 | data.outtextlimit = 128; // Limit input to 128 characters 57 | data.outtext = outtext; 58 | 59 | SceUtilityOskParams params; 60 | std::memset(¶ms, 0, sizeof(SceUtilityOskParams)); 61 | 62 | params.base.size = sizeof(SceUtilityOskParams); 63 | params.base.language = language; 64 | params.base.buttonSwap = (PSP_CTRL_ENTER == PSP_CTRL_CROSS)? PSP_UTILITY_ACCEPT_CROSS : PSP_UTILITY_ACCEPT_CIRCLE; 65 | params.base.graphicsThread = 17; 66 | params.base.accessThread = 19; 67 | params.base.fontThread = 18; 68 | params.base.soundThread = 16; 69 | params.datacount = 1; 70 | params.data = &data; 71 | 72 | if (R_FAILED(ret = sceUtilityOskInitStart(¶ms))) { 73 | Log::Error("sceUtilityOskInitStart() failed: 0x%08x\n", ret); 74 | return ret; 75 | } 76 | 77 | while(!done) { 78 | int i = 0, j = 0; 79 | 80 | g2dClear(G2D_RGBA(39, 50, 56, 255)); 81 | sceGuFinish(); 82 | sceGuSync(0, 0); 83 | 84 | switch(sceUtilityOskGetStatus()) { 85 | case PSP_UTILITY_DIALOG_VISIBLE: 86 | if (R_FAILED(ret = sceUtilityOskUpdate(1))) { 87 | Log::Error("sceUtilityOskUpdate(1) failed: 0x%08x\n", ret); 88 | done = true; 89 | } 90 | break; 91 | 92 | case PSP_UTILITY_DIALOG_QUIT: 93 | if (R_FAILED(ret = sceUtilityOskShutdownStart())) { 94 | Log::Error("sceUtilityOskShutdownStart() failed: 0x%08x\n", ret); 95 | done = true; 96 | } 97 | break; 98 | 99 | case PSP_UTILITY_DIALOG_NONE: 100 | done = true; 101 | 102 | default: 103 | break; 104 | } 105 | 106 | for(i = 0; data.outtext[i]; i++) { 107 | if (data.outtext[i] != '\0' && data.outtext[i] != '\n' && data.outtext[i] != '\r') { 108 | input[j] = data.outtext[i]; 109 | j++; 110 | } 111 | } 112 | 113 | input[j] = 0; 114 | g2dFlip(G2D_VSYNC); 115 | } 116 | 117 | return 0; 118 | } 119 | 120 | char *KeyboardGetText(const std::string &desc_msg, const std::string &initial_msg) { 121 | int ret = 0; 122 | size_t i = 0; 123 | static char str[128]; 124 | unsigned short initial[128] = { 0 }; 125 | unsigned short desc[128] = { 0 }; 126 | 127 | if (initial_msg.c_str()[0] != 0) { 128 | for (i = 0; i <= initial_msg.length(); i++) 129 | initial[i] = static_cast(initial_msg.c_str()[i]); 130 | } 131 | 132 | if (desc_msg.c_str()[0] != 0) { 133 | for (i = 0; i <= desc_msg.length(); i++) 134 | desc[i] = static_cast(desc_msg.c_str()[i]); 135 | } 136 | 137 | if (R_SUCCEEDED(ret = G2D::GetText(str, initial, desc))) 138 | return str; 139 | 140 | return 0; 141 | } 142 | 143 | void FontSetStyle(float size, unsigned int colour, unsigned int options) { 144 | intraFontSetStyle(font, size, colour, G2D_RGBA(0, 0, 0, 0), 0.f, options); 145 | } 146 | 147 | float GetTextHeight(void) { 148 | return font->advancey * font->size / 4.f + 2.f; 149 | } 150 | 151 | float DrawText(float x, float y, const std::string &text) { 152 | return intraFontPrintf(font, x, y, text.c_str()); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /app/source/gui/imageviewer.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "fs.h" 3 | #include "colours.h" 4 | #include "g2d.h" 5 | #include "gui.h" 6 | #include "textures.h" 7 | #include "utils.h" 8 | 9 | namespace ImageViewer { 10 | static void Draw(g2dTexture *tex, float w, float h, float zoom_factor, int angle, int pos_x, int pos_y) { 11 | g2dBeginRects(tex); { 12 | g2dSetCoordMode(G2D_CENTER); 13 | g2dSetScaleWH(w * zoom_factor, h * zoom_factor); 14 | g2dSetCoordXY((G2D_SCR_W / 2) - (pos_x * zoom_factor - pos_x) / 2, (G2D_SCR_H / 2) - (pos_y * zoom_factor - pos_y) / 2); 15 | g2dSetRotation(angle); 16 | g2dAdd(); 17 | } 18 | g2dEnd(); 19 | } 20 | } 21 | 22 | namespace GUI { 23 | static bool properties = false; 24 | static float scale_factor = 1.f, width = 0.f, height = 0.f, zoom_factor = 1.f; 25 | static int degrees = 0, pos_x = 0, pos_y = 0; 26 | 27 | void DisplayImageViewer(MenuItem &item) { 28 | g2dClear(BLACK_BG); 29 | 30 | if (static_cast(item.texture->h) > 272.f) { 31 | scale_factor = (272.f / static_cast(item.texture->h)); 32 | width = static_cast(item.texture->w) * scale_factor; 33 | height = static_cast(item.texture->h) * scale_factor; 34 | } 35 | else { 36 | width = static_cast(item.texture->w) * scale_factor; 37 | height = static_cast(item.texture->h) * scale_factor; 38 | } 39 | 40 | ImageViewer::Draw(item.texture, width, height, zoom_factor, degrees, pos_x, pos_y); 41 | 42 | if (properties) { 43 | G2D::DrawRect(0, 0, 480, 272, G2D_RGBA(0, 0, 0, cfg.dark_theme? 50 : 80)); 44 | G2D::DrawImage(properties_dialog[cfg.dark_theme], ((480 - (properties_dialog[0]->w)) / 2), ((272 - (properties_dialog[0]->h)) / 2)); 45 | G2D::FontSetStyle(1.f, TITLE_COLOUR, INTRAFONT_ALIGN_LEFT); 46 | 47 | G2D::DrawText(((480 - (properties_dialog[0]->w)) / 2) + 10, ((272 - (properties_dialog[0]->h)) / 2) + 20, "Properties"); 48 | 49 | int ok_width = intraFontMeasureText(font, "OK"); 50 | G2D::DrawRect((340 - (ok_width)) - 5, (220 - (font->texYSize - 15)) - 5, ok_width + 10, (font->texYSize - 5) + 10, SELECTOR_COLOUR); 51 | G2D::DrawText(340 - (ok_width), (232 - (font->texYSize - 15)) - 3, "OK"); 52 | 53 | G2D::FontSetStyle(1.f, TEXT_COLOUR, INTRAFONT_ALIGN_LEFT); 54 | intraFontPrintf(font, 140, 74, std::string(item.entries[item.selected].d_name).length() > 14? "Name: %.14s..." : "%s", 55 | item.entries[item.selected].d_name); 56 | intraFontPrintf(font, 140, 92, "Width: %dpx", item.texture->w); 57 | intraFontPrintf(font, 140, 110, "Height: %dpx", item.texture->h); 58 | } 59 | } 60 | 61 | void ControlImageViewer(MenuItem &item, float &delta) { 62 | if (Utils::IsButtonPressed(PSP_CTRL_LTRIGGER)) { 63 | degrees -= 90; 64 | 65 | if (degrees < 0) 66 | degrees = 270; 67 | } 68 | else if (Utils::IsButtonPressed(PSP_CTRL_RTRIGGER)) { 69 | degrees += 90; 70 | 71 | if (degrees > 270) 72 | degrees = 0; 73 | } 74 | 75 | if (Utils::IsButtonPressed(PSP_CTRL_TRIANGLE)) 76 | properties = !properties; 77 | 78 | if (Utils::IsButtonHeld(PSP_CTRL_UP)) { 79 | zoom_factor += (delta / 1000.f); 80 | 81 | if (zoom_factor > 2.f) 82 | zoom_factor = 2.f; 83 | } 84 | else if (Utils::IsButtonHeld(PSP_CTRL_DOWN)) { 85 | zoom_factor -= (delta / 1000.f); 86 | 87 | if (zoom_factor < 0.5f) 88 | zoom_factor = 0.5f; 89 | 90 | if (zoom_factor <= 1.f) { 91 | pos_x = 0; 92 | pos_y = 0; 93 | } 94 | } 95 | 96 | if ((height * zoom_factor > 272.f) || (width * zoom_factor > 480.f)) { 97 | float velocity = 2.f / zoom_factor; 98 | if (Utils::GetAnalogY() < -0.4f) 99 | pos_y -= ((velocity * zoom_factor) * delta); 100 | if (Utils::GetAnalogY() > 0.4f) 101 | pos_y += ((velocity * zoom_factor) * delta); 102 | if (Utils::GetAnalogX() < -0.4f) 103 | pos_x -= ((velocity * zoom_factor) * delta); 104 | if (Utils::GetAnalogX() > 0.4f) 105 | pos_x += ((velocity * zoom_factor) * delta); 106 | } 107 | 108 | if ((degrees == 0) || (degrees == 180)) { 109 | Utils::SetMax(pos_x, width, width); 110 | Utils::SetMin(pos_x, -width, -width); 111 | Utils::SetMax(pos_y, height, height); 112 | Utils::SetMin(pos_y, -height, -height); 113 | } 114 | else { 115 | Utils::SetMax(pos_x, height, height); 116 | Utils::SetMin(pos_x, -height, -height); 117 | Utils::SetMax(pos_y, width, width); 118 | Utils::SetMin(pos_y, -width, -width); 119 | } 120 | 121 | if (Utils::IsButtonPressed(PSP_CTRL_CANCEL)) { 122 | if (!properties) { 123 | if (item.texture) 124 | g2dTexFree(&item.texture); 125 | 126 | zoom_factor = 1.f; 127 | pos_x = 0; 128 | pos_y = 0; 129 | item.state = MENU_STATE_FILEBROWSER; 130 | } 131 | else 132 | properties = false; 133 | } 134 | 135 | if (Utils::IsButtonPressed(PSP_CTRL_ENTER)) { 136 | if (properties) 137 | properties = false; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /libs/include/opus/opus_types.h: -------------------------------------------------------------------------------- 1 | /* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ 2 | /* Modified by Jean-Marc Valin */ 3 | /* 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | - Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | - Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | /* opus_types.h based on ogg_types.h from libogg */ 28 | 29 | /** 30 | @file opus_types.h 31 | @brief Opus reference implementation types 32 | */ 33 | #ifndef OPUS_TYPES_H 34 | #define OPUS_TYPES_H 35 | 36 | #define opus_int int /* used for counters etc; at least 16 bits */ 37 | #define opus_int64 long long 38 | #define opus_int8 signed char 39 | 40 | #define opus_uint unsigned int /* used for counters etc; at least 16 bits */ 41 | #define opus_uint64 unsigned long long 42 | #define opus_uint8 unsigned char 43 | 44 | /* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ 45 | #if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) 46 | #include 47 | # undef opus_int64 48 | # undef opus_int8 49 | # undef opus_uint64 50 | # undef opus_uint8 51 | typedef int8_t opus_int8; 52 | typedef uint8_t opus_uint8; 53 | typedef int16_t opus_int16; 54 | typedef uint16_t opus_uint16; 55 | typedef int32_t opus_int32; 56 | typedef uint32_t opus_uint32; 57 | typedef int64_t opus_int64; 58 | typedef uint64_t opus_uint64; 59 | #elif defined(_WIN32) 60 | 61 | # if defined(__CYGWIN__) 62 | # include <_G_config.h> 63 | typedef _G_int32_t opus_int32; 64 | typedef _G_uint32_t opus_uint32; 65 | typedef _G_int16 opus_int16; 66 | typedef _G_uint16 opus_uint16; 67 | # elif defined(__MINGW32__) 68 | typedef short opus_int16; 69 | typedef unsigned short opus_uint16; 70 | typedef int opus_int32; 71 | typedef unsigned int opus_uint32; 72 | # elif defined(__MWERKS__) 73 | typedef int opus_int32; 74 | typedef unsigned int opus_uint32; 75 | typedef short opus_int16; 76 | typedef unsigned short opus_uint16; 77 | # else 78 | /* MSVC/Borland */ 79 | typedef __int32 opus_int32; 80 | typedef unsigned __int32 opus_uint32; 81 | typedef __int16 opus_int16; 82 | typedef unsigned __int16 opus_uint16; 83 | # endif 84 | 85 | #elif defined(__MACOS__) 86 | 87 | # include 88 | typedef SInt16 opus_int16; 89 | typedef UInt16 opus_uint16; 90 | typedef SInt32 opus_int32; 91 | typedef UInt32 opus_uint32; 92 | 93 | #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ 94 | 95 | # include 96 | typedef int16_t opus_int16; 97 | typedef u_int16_t opus_uint16; 98 | typedef int32_t opus_int32; 99 | typedef u_int32_t opus_uint32; 100 | 101 | #elif defined(__BEOS__) 102 | 103 | /* Be */ 104 | # include 105 | typedef int16 opus_int16; 106 | typedef u_int16 opus_uint16; 107 | typedef int32_t opus_int32; 108 | typedef u_int32_t opus_uint32; 109 | 110 | #elif defined (__EMX__) 111 | 112 | /* OS/2 GCC */ 113 | typedef short opus_int16; 114 | typedef unsigned short opus_uint16; 115 | typedef int opus_int32; 116 | typedef unsigned int opus_uint32; 117 | 118 | #elif defined (DJGPP) 119 | 120 | /* DJGPP */ 121 | typedef short opus_int16; 122 | typedef unsigned short opus_uint16; 123 | typedef int opus_int32; 124 | typedef unsigned int opus_uint32; 125 | 126 | #elif defined(R5900) 127 | 128 | /* PS2 EE */ 129 | typedef int opus_int32; 130 | typedef unsigned opus_uint32; 131 | typedef short opus_int16; 132 | typedef unsigned short opus_uint16; 133 | 134 | #elif defined(__SYMBIAN32__) 135 | 136 | /* Symbian GCC */ 137 | typedef signed short opus_int16; 138 | typedef unsigned short opus_uint16; 139 | typedef signed int opus_int32; 140 | typedef unsigned int opus_uint32; 141 | 142 | #elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) 143 | 144 | typedef short opus_int16; 145 | typedef unsigned short opus_uint16; 146 | typedef long opus_int32; 147 | typedef unsigned long opus_uint32; 148 | 149 | #elif defined(CONFIG_TI_C6X) 150 | 151 | typedef short opus_int16; 152 | typedef unsigned short opus_uint16; 153 | typedef int opus_int32; 154 | typedef unsigned int opus_uint32; 155 | 156 | #else 157 | 158 | /* Give up, take a reasonable guess */ 159 | typedef short opus_int16; 160 | typedef unsigned short opus_uint16; 161 | typedef int opus_int32; 162 | typedef unsigned int opus_uint32; 163 | 164 | #endif 165 | 166 | #endif /* OPUS_TYPES_H */ 167 | -------------------------------------------------------------------------------- /libs/include/systemctrl_se.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCTRLLIBRARY_SE_H__ 2 | #define __SCTRLLIBRARY_SE_H__ 3 | 4 | /** 5 | * These functions are only available in SE-C and later, 6 | * and they are not in HEN 7 | */ 8 | 9 | enum 10 | { 11 | FAKE_REGION_DISABLED = 0, 12 | FAKE_REGION_JAPAN = 1, 13 | FAKE_REGION_AMERICA = 2, 14 | FAKE_REGION_EUROPE = 3, 15 | FAKE_REGION_KOREA = 4, 16 | FAKE_REGION_UNK = 5, 17 | FAKE_REGION_UNK2 = 6, 18 | FAKE_REGION_AUSTRALIA = 7, 19 | FAKE_REGION_HONGKONG = 8, 20 | FAKE_REGION_TAIWAN = 9, 21 | FAKE_REGION_RUSSIA = 10, 22 | FAKE_REGION_CHINA = 11, 23 | FAKE_REGION_DEBUG_TYPE_I = 12, 24 | FAKE_REGION_DEBUG_TYPE_II = 13, 25 | }; 26 | 27 | // No MODE_OE_LEGACY any more 28 | enum SEUmdModes 29 | { 30 | MODE_UMD = 0, 31 | MODE_MARCH33 = 1, 32 | MODE_NP9660 = 2, 33 | MODE_INFERNO = 3, 34 | MODE_VSHUMD = 4, 35 | MODE_UPDATERUMD = 5, 36 | }; 37 | 38 | enum MsSpeedFlag 39 | { 40 | MSSPEED_NONE = 0, 41 | MSSPEED_POP = 1, 42 | MSSPEED_GAME = 2, 43 | MSSPEED_VSH = 3, 44 | MSSPEED_POP_GAME = 4, 45 | MSSPEED_GAME_VSH = 5, 46 | MSSPEED_VSH_POP = 6, 47 | MSSPEED_ALWAYS = 7, 48 | }; 49 | 50 | enum InfernoCachePolicy 51 | { 52 | CACHE_POLICY_LRU = 0, 53 | CACHE_POLICY_RR = 1, 54 | }; 55 | 56 | typedef struct _SEConfig 57 | { 58 | int magic; 59 | s16 umdmode; 60 | s16 vshcpuspeed; 61 | s16 vshbusspeed; 62 | s16 umdisocpuspeed; 63 | s16 umdisobusspeed; 64 | s16 fakeregion; 65 | s16 usbdevice; 66 | s16 usbcharge; 67 | s16 machidden; 68 | s16 skipgameboot; 69 | s16 hidepic; 70 | s16 plugvsh; 71 | s16 pluggame; 72 | s16 plugpop; 73 | s16 flashprot; 74 | s16 skiplogo; 75 | s16 useversion; 76 | s16 useownupdate; 77 | s16 usenodrm; 78 | s16 hibblock; 79 | s16 noanalog; 80 | s16 oldplugin; 81 | s16 htmlviewer_custom_save_location; 82 | s16 hide_cfw_dirs; 83 | s16 chn_iso; 84 | s16 msspeed; 85 | s16 slimcolor; 86 | s16 iso_cache; 87 | s16 iso_cache_total_size; // in MB 88 | s16 iso_cache_num; 89 | s16 iso_cache_policy; 90 | s16 usbversion; 91 | s16 language; /* -1 as autodetect */ 92 | s16 retail_high_memory; 93 | s16 macspoofer; 94 | } SEConfig; 95 | 96 | /** 97 | * Gets the SE/OE version 98 | * 99 | * @returns the SE version 100 | * 101 | * 3.03 OE-A: 0x00000500 102 | */ 103 | int sctrlSEGetVersion(); 104 | 105 | /** 106 | * Gets the SE configuration. 107 | * Avoid using this function, it may corrupt your program. 108 | * Use sctrlSEGetCongiEx function instead. 109 | * 110 | * @param config - pointer to a SEConfig structure that receives the SE configuration 111 | * @returns 0 on success 112 | */ 113 | int sctrlSEGetConfig(SEConfig *config); 114 | 115 | /** 116 | * Gets the SE configuration 117 | * 118 | * @param config - pointer to a SEConfig structure that receives the SE configuration 119 | * @param size - The size of the structure 120 | * @returns 0 on success 121 | */ 122 | int sctrlSEGetConfigEx(SEConfig *config, int size); 123 | 124 | /** 125 | * Sets the SE configuration 126 | * This function can corrupt the configuration in flash, use 127 | * sctrlSESetConfigEx instead. 128 | * 129 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 130 | * @returns 0 on success 131 | */ 132 | int sctrlSESetConfig(SEConfig *config); 133 | 134 | /** 135 | * Sets the SE configuration 136 | * 137 | * @param config - pointer to a SEConfig structure that has the SE configuration to set 138 | * @param size - the size of the structure 139 | * @returns 0 on success 140 | */ 141 | int sctrlSESetConfigEx(SEConfig *config, int size); 142 | 143 | /** 144 | * Initiates the emulation of a disc from an ISO9660/CSO file. 145 | * 146 | * @param file - The path of the 147 | * @param noumd - Wether use noumd or not 148 | * @param isofs - Wether use the custom SE isofs driver or not 149 | * 150 | * @returns 0 on success 151 | * 152 | * @Note - When setting noumd to 1, isofs should also be set to 1, 153 | * otherwise the umd would be still required. 154 | * 155 | * @Note 2 - The function doesn't check if the file is valid or even if it exists 156 | * and it may return success on those cases 157 | * 158 | * @Note 3 - This function is not available in SE for devhook 159 | * @Example: 160 | * 161 | * SEConfig config; 162 | * 163 | * sctrlSEGetConfig(&config); 164 | * 165 | * if (config.usenoumd) 166 | * { 167 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 1, 1); 168 | * } 169 | * else 170 | * { 171 | * sctrlSEMountUmdFromFile("ms0:/ISO/mydisc.iso", 0, config.useisofsonumdinserted); 172 | * } 173 | */ 174 | int sctrlSEMountUmdFromFile(char *file, int noumd, int isofs); 175 | 176 | /** 177 | * Umounts an iso. 178 | * 179 | * @returns 0 on success 180 | */ 181 | int sctrlSEUmountUmd(void); 182 | 183 | /** 184 | * Forces the umd disc out state 185 | * 186 | * @param out - non-zero for disc out, 0 otherwise 187 | * 188 | */ 189 | void sctrlSESetDiscOut(int out); 190 | 191 | /** 192 | * Sets the disctype. 193 | * 194 | * @param type - the disctype (0x10=game, 0x20=video, 0x40=audio) 195 | * @note: Currently only inferno available, needs reset to take effect 196 | */ 197 | void sctrlSESetDiscType(int type); 198 | 199 | /** 200 | * Get the disctype. 201 | */ 202 | int sctrlSEGetDiscType(void); 203 | 204 | /** 205 | * Sets the current umd file (kernel only) 206 | */ 207 | char *sctrlSEGetUmdFile(); 208 | 209 | /** 210 | * Gets the current umd file (kernel only) 211 | */ 212 | char *sctrlSEGetUmdFile(); 213 | 214 | /** 215 | * Sets the current umd file (kernel only) 216 | * 217 | * @param file - The umd file 218 | */ 219 | void sctrlSESetUmdFile(char *file); 220 | 221 | /** 222 | * Sets the boot config file for next reboot 223 | * 224 | * @param index - The index identifying the file (0 -> normal bootconf, 1 -> march33 driver bootconf, 2 -> np9660 bootcnf, 3 -> inferno bootconf), 4 -> inferno vsh mount 225 | */ 226 | void sctrlSESetBootConfFileIndex(int index); 227 | 228 | /** 229 | * Get the boot config index 230 | */ 231 | u32 sctrlSEGetBootConfFileIndex(void); 232 | 233 | #endif 234 | -------------------------------------------------------------------------------- /app/source/pspaudiolib_cm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * PSP Software Development Kit - http://www.pspdev.org 3 | * ----------------------------------------------------------------------- 4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details. 5 | * 6 | * pspaudiolib.c - Audio library build on top of sceAudio, but to provide 7 | * multiple thread usage and callbacks. 8 | * 9 | * Copyright (c) 2005 Adresd 10 | * Copyright (c) 2005 Marcus R. Brown 11 | * Copyright (c) 2019 Joel16 12 | * 13 | * $Id: pspaudiolib.c 1145 2005-10-12 15:32:44Z mrbrown $ 14 | */ 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "pspaudiolib_cm.h" 21 | 22 | static bool audio_ready = false; 23 | static short audio_sndbuf[PSP_NUM_AUDIO_CHANNELS][2][PSP_NUM_AUDIO_SAMPLES][2]; 24 | 25 | static psp_audio_channelinfo AudioStatus[PSP_NUM_AUDIO_CHANNELS]; 26 | 27 | static volatile bool audio_terminate = false; 28 | 29 | void pspAudioSetVolume(int channel, int left, int right) { 30 | AudioStatus[channel].volumeright = right; 31 | AudioStatus[channel].volumeleft = left; 32 | } 33 | 34 | void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn) { 35 | //pspAudioCallback_t callback; 36 | //callback = AudioStatus[channel].callback; 37 | } 38 | 39 | void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata) { 40 | volatile psp_audio_channelinfo *pci = &AudioStatus[channel]; 41 | pci->callback = 0; 42 | pci->pdata = pdata; 43 | pci->callback = callback; 44 | } 45 | 46 | int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf) { 47 | if (!audio_ready) 48 | return -1; 49 | 50 | if (channel >= PSP_NUM_AUDIO_CHANNELS) 51 | return -1; 52 | 53 | if (vol1 > PSP_VOLUME_MAX) 54 | vol1 = PSP_VOLUME_MAX; 55 | 56 | if (vol2 > PSP_VOLUME_MAX) 57 | vol2 = PSP_VOLUME_MAX; 58 | 59 | return sceAudioOutputPannedBlocking(AudioStatus[channel].handle, vol1, vol2, buf); 60 | } 61 | 62 | static int AudioChannelThread(int args, void *argp) { 63 | volatile int bufidx = 0; 64 | int channel = *static_cast(argp); 65 | 66 | while (!audio_terminate) { 67 | void *bufptr = &audio_sndbuf[channel][bufidx]; 68 | pspAudioCallback_t callback; 69 | callback = AudioStatus[channel].callback; 70 | 71 | if (callback) 72 | callback(bufptr, PSP_NUM_AUDIO_SAMPLES, AudioStatus[channel].pdata); 73 | else { 74 | unsigned int *ptr = static_cast(bufptr); 75 | for (int i = 0; i < PSP_NUM_AUDIO_SAMPLES; ++i) 76 | *(ptr++) = 0; 77 | } 78 | 79 | pspAudioOutBlocking(channel, AudioStatus[channel].volumeleft,AudioStatus[channel].volumeright, bufptr); 80 | bufidx = (bufidx? 0 : 1); 81 | } 82 | 83 | sceKernelExitThread(0); 84 | return 0; 85 | } 86 | 87 | int pspAudioInit(int format) { 88 | int ret = 0; 89 | bool failed = false; 90 | char str[32] = {0}; 91 | 92 | audio_terminate = false; 93 | audio_ready = false; 94 | 95 | for (int i = 0; i < PSP_NUM_AUDIO_CHANNELS; i++) { 96 | AudioStatus[i].handle = -1; 97 | AudioStatus[i].threadhandle = -1; 98 | AudioStatus[i].volumeright = PSP_VOLUME_MAX; 99 | AudioStatus[i].volumeleft = PSP_VOLUME_MAX; 100 | AudioStatus[i].callback = 0; 101 | AudioStatus[i].pdata = 0; 102 | } 103 | for (int i = 0; i < PSP_NUM_AUDIO_CHANNELS; i++) { 104 | if ((AudioStatus[i].handle = sceAudioChReserve(-1, PSP_NUM_AUDIO_SAMPLES, format)) < 0) 105 | failed = true; 106 | } 107 | if (failed) { 108 | for (int i = 0; i < PSP_NUM_AUDIO_CHANNELS; i++) { 109 | if (AudioStatus[i].handle != -1) 110 | sceAudioChRelease(AudioStatus[i].handle); 111 | 112 | AudioStatus[i].handle = -1; 113 | } 114 | return -1; 115 | } 116 | 117 | audio_ready = true; 118 | strcpy(str, "audiot0"); 119 | 120 | for (int i = 0; i < PSP_NUM_AUDIO_CHANNELS; i++) { 121 | str[6]= '0' + i; 122 | AudioStatus[i].threadhandle = sceKernelCreateThread(str, reinterpret_cast(&AudioChannelThread), 0x12, 0x10000, 0, nullptr); 123 | 124 | if (AudioStatus[i].threadhandle < 0) { 125 | AudioStatus[i].threadhandle = -1; 126 | failed = 1; 127 | break; 128 | } 129 | 130 | ret = sceKernelStartThread(AudioStatus[i].threadhandle, sizeof(i), &i); 131 | if (ret != 0) { 132 | failed = true; 133 | break; 134 | } 135 | } 136 | if (failed) { 137 | audio_terminate = true; 138 | for (int i = 0; i 2 | #include 3 | 4 | #include "colours.h" 5 | #include "config.h" 6 | #include "fs.h" 7 | #include "g2d.h" 8 | #include "gui.h" 9 | #include "screenshot.h" 10 | #include "textures.h" 11 | #include "utils.h" 12 | 13 | namespace GUI { 14 | static MenuItem item; 15 | 16 | void ResetCheckbox(MenuItem &item) { 17 | item.checked.clear(); 18 | item.checked_copy.clear(); 19 | item.checked.resize(item.entries.size()); 20 | item.checked.assign(item.checked.size(), false); 21 | item.checked_cwd.clear(); 22 | item.checked_count = 0; 23 | }; 24 | 25 | void GetStorageSize(MenuItem &item) { 26 | item.total_storage = Utils::GetTotalStorage(); 27 | item.used_storage = Utils::GetUsedStorage(); 28 | } 29 | 30 | void DisplayStatusBar(void) { 31 | ScePspDateTime time; 32 | static char time_string[30]; 33 | 34 | if (R_SUCCEEDED(sceRtcGetCurrentClockLocalTime(&time))) 35 | std::snprintf(time_string, 30, "%2i:%02i %s", ((time.hour % 12) == 0)? 12 : time.hour % 12, time.minute, (time.hour / 12)? "PM" : "AM"); 36 | 37 | G2D::FontSetStyle(1.f, WHITE, INTRAFONT_ALIGN_LEFT); 38 | G2D::DrawText(5, 14, time_string); 39 | 40 | int state = 0, percent = 0, battery_val = 0; 41 | if (scePowerIsBatteryExist()) { 42 | state = scePowerIsBatteryCharging(); 43 | percent = scePowerGetBatteryLifePercent(); 44 | battery_val = (percent / 20); 45 | } 46 | 47 | static char percent_string[10]; 48 | std::snprintf(percent_string, 10, "%d", percent); 49 | int percent_width = intraFontMeasureText(font, percent_string); 50 | intraFontPrintf(font, 475 - percent_width - 15, 14, "%s%%", percent_string); 51 | 52 | G2D::DrawImage(state != 0? battery_charging[battery_val] : battery[battery_val], 475 - percent_width - battery[battery_val]->w - 15, 2); 53 | } 54 | 55 | void ProgressBar(const std::string &title, std::string message, u64 offset, u64 size) { 56 | if (message.length() > 35) { 57 | message.resize(35); 58 | message.append("..."); 59 | } 60 | 61 | g2dClear(BG_COLOUR); 62 | G2D::DrawRect(0, 0, 480, 18, STATUS_BAR_COLOUR); 63 | G2D::DrawRect(0, 18, 480, 34, MENU_BAR_COLOUR); 64 | G2D::DrawImageScale(icon_nav_drawer, 5, 24, 26.f, 26.f); 65 | GUI::DisplayStatusBar(); 66 | GUI::DisplayFileBrowser(item); 67 | 68 | G2D::DrawRect(0, 18, 480, 254, G2D_RGBA(0, 0, 0, cfg.dark_theme? 50 : 80)); 69 | G2D::DrawImage(dialog[cfg.dark_theme], ((480 - (dialog[0]->w)) / 2), ((272 - (dialog[0]->h)) / 2)); 70 | G2D::FontSetStyle(1.f, TITLE_COLOUR, INTRAFONT_ALIGN_LEFT); 71 | G2D::DrawText(((480 - (dialog[0]->w)) / 2) + 10, ((272 - (dialog[0]->h)) / 2) + 20, title.c_str()); 72 | 73 | int text_width = intraFontMeasureText(font, message.c_str()); 74 | G2D::FontSetStyle(1.f, TEXT_COLOUR, INTRAFONT_ALIGN_LEFT); 75 | G2D::DrawText(((480 - (text_width)) / 2), ((272 - (dialog[0]->h)) / 2) + 60, message.c_str()); 76 | 77 | G2D::DrawRect(((480 - dialog[0]->w) / 2) + 20, ((272 - dialog[0]->h) / 2) + 70, 318, 4, SELECTOR_COLOUR); 78 | G2D::DrawRect(((480 - dialog[0]->w) / 2) + 20, ((272 - dialog[0]->h) / 2) + 70, 79 | static_cast((static_cast(offset) / static_cast(size)) * 318.f), 4, TITLE_COLOUR); 80 | 81 | g2dFlip(G2D_VSYNC); 82 | } 83 | 84 | int RenderLoop(void) { 85 | int ret = 0; 86 | if (R_FAILED(ret = FS::GetDirList(cfg.cwd, item.entries))) 87 | return ret; 88 | 89 | GUI::ResetCheckbox(item); 90 | GUI::GetStorageSize(item); 91 | 92 | Colours::Get(); 93 | 94 | // Delta time 95 | u64 last_tick = 0; 96 | float resolution = sceRtcGetTickResolution() / 1000.f; 97 | sceRtcGetCurrentTick(&last_tick); 98 | 99 | while(running) { 100 | u64 current_tick = 0; 101 | sceRtcGetCurrentTick(¤t_tick); 102 | float delta = (current_tick - last_tick) / resolution; 103 | last_tick = current_tick; 104 | 105 | if (delta < 0.001f) 106 | delta = 0.001f; 107 | 108 | int ctrl = Utils::ReadControls(); 109 | 110 | g2dClear(BG_COLOUR); 111 | G2D::DrawRect(0, 0, 480, 18, STATUS_BAR_COLOUR); 112 | G2D::DrawRect(0, 18, 480, 34, MENU_BAR_COLOUR); 113 | GUI::DisplayStatusBar(); 114 | G2D::DrawImageScale(icon_nav_drawer, 5, 24, 26.f, 26.f); 115 | GUI::DisplayFileBrowser(item); 116 | 117 | switch(item.state) { 118 | case MENU_STATE_MENUBAR: 119 | GUI::HandleMenubarAnim(delta); 120 | GUI::DisplayMenubar(); 121 | GUI::ControlMenubar(item, ctrl); 122 | break; 123 | 124 | case MENU_STATE_FILEBROWSER: 125 | GUI::ControlFileBrowser(item, ctrl); 126 | break; 127 | 128 | case MENU_STATE_OPTIONS: 129 | GUI::DisplayFileOptions(item); 130 | GUI::ControlFileOptions(item, ctrl); 131 | break; 132 | 133 | case MENU_STATE_PROPERTIES: 134 | GUI::DisplayFileProperties(item); 135 | GUI::ControlFileProperties(item); 136 | break; 137 | 138 | case MENU_STATE_DELETE: 139 | GUI::DisplayDeleteOptions(); 140 | GUI::ControlDeleteOptions(item, ctrl); 141 | break; 142 | 143 | case MENU_STATE_SETTINGS: 144 | GUI::DisplaySettings(item); 145 | GUI::ControlSettings(item, ctrl); 146 | break; 147 | 148 | case MENU_STATE_IMAGEVIEWER: 149 | GUI::DisplayImageViewer(item); 150 | GUI::ControlImageViewer(item, delta); 151 | break; 152 | 153 | default: 154 | break; 155 | } 156 | 157 | g2dFlip(G2D_VSYNC); 158 | 159 | if (Utils::IsButtonPressed(static_cast(PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER))) 160 | Screenshot::Capture(); 161 | 162 | if (Utils::IsButtonPressed(PSP_CTRL_START)) 163 | item.state = MENU_STATE_SETTINGS; 164 | } 165 | 166 | return 0; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /app/source/audio.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "fs.h" 6 | #include "kernel_functions.h" 7 | #include "audio.h" 8 | #include "pspaudiolib_cm.h" 9 | 10 | AudioMetadata metadata = { 0 }; 11 | bool playing = true, paused = false; 12 | 13 | namespace Audio { 14 | enum AudioFileType { 15 | FILE_TYPE_NONE, 16 | FILE_TYPE_FLAC, 17 | FILE_TYPE_MP3, 18 | FILE_TYPE_OGG, 19 | FILE_TYPE_OPUS, 20 | FILE_TYPE_WAV, 21 | FILE_TYPE_XM 22 | }; 23 | 24 | typedef struct { 25 | int (* init)(const std::string &path); 26 | u32 (* rate)(void); 27 | u8 (* channels)(void); 28 | void (* decode)(void *buf, unsigned int length, void *userdata); 29 | u64 (* position)(void); 30 | u64 (* length)(void); 31 | u64 (* seek)(u64 index); 32 | void (* term)(void); 33 | } Decoder; 34 | 35 | static enum AudioFileType file_type = FILE_TYPE_NONE; 36 | static Decoder decoder = { 0 }; 37 | 38 | static void Decode(void *buf, unsigned int length, void *userdata) { 39 | if ((!playing) || (paused)) { 40 | std::memset(buf, 0, length * 4); 41 | } 42 | else { 43 | (*decoder.decode)(buf, length, userdata); 44 | } 45 | } 46 | 47 | void Init(const std::string &path) { 48 | playing = true; 49 | paused = false; 50 | const char *ext = FS::GetFileExt(path.c_str()); 51 | 52 | if (strncasecmp(ext, "flac", 4) == 0) { 53 | file_type = FILE_TYPE_FLAC; 54 | } 55 | else if (strncasecmp(ext, "mp3", 3) == 0) { 56 | file_type = FILE_TYPE_MP3; 57 | } 58 | else if (strncasecmp(ext, "ogg", 3) == 0) { 59 | file_type = FILE_TYPE_OGG; 60 | } 61 | else if (strncasecmp(ext, "opus", 4) == 0) { 62 | file_type = FILE_TYPE_OPUS; 63 | } 64 | else if (strncasecmp(ext, "wav", 3) == 0) { 65 | file_type = FILE_TYPE_WAV; 66 | } 67 | else if ((strncasecmp(ext, "it", 2) == 0) || (strncasecmp(ext, "mod", 3) == 0) || (strncasecmp(ext, "s3m", 3) == 0) 68 | || (strncasecmp(ext, "xm", 2) == 0)) { 69 | file_type = FILE_TYPE_XM; 70 | } 71 | 72 | switch(file_type) { 73 | case FILE_TYPE_FLAC: 74 | decoder.init = FLAC::Init; 75 | decoder.rate = FLAC::GetSampleRate; 76 | decoder.channels = FLAC::GetChannels; 77 | decoder.decode = FLAC::Decode; 78 | decoder.position = FLAC::GetPosition; 79 | decoder.length = FLAC::GetLength; 80 | decoder.seek = FLAC::Seek; 81 | decoder.term = FLAC::Exit; 82 | break; 83 | 84 | case FILE_TYPE_MP3: 85 | decoder.init = MP3::Init; 86 | decoder.rate = MP3::GetSampleRate; 87 | decoder.channels = MP3::GetChannels; 88 | decoder.decode = MP3::Decode; 89 | decoder.position = MP3::GetPosition; 90 | decoder.length = MP3::GetLength; 91 | decoder.seek = MP3::Seek; 92 | decoder.term = MP3::Exit; 93 | break; 94 | 95 | case FILE_TYPE_OGG: 96 | decoder.init = OGG::Init; 97 | decoder.rate = OGG::GetSampleRate; 98 | decoder.channels = OGG::GetChannels; 99 | decoder.decode = OGG::Decode; 100 | decoder.position = OGG::GetPosition; 101 | decoder.length = OGG::GetLength; 102 | decoder.seek = OGG::Seek; 103 | decoder.term = OGG::Exit; 104 | break; 105 | 106 | case FILE_TYPE_OPUS: 107 | decoder.init = OPUS::Init; 108 | decoder.rate = OPUS::GetSampleRate; 109 | decoder.channels = OPUS::GetChannels; 110 | decoder.decode = OPUS::Decode; 111 | decoder.position = OPUS::GetPosition; 112 | decoder.length = OPUS::GetLength; 113 | decoder.seek = OPUS::Seek; 114 | decoder.term = OPUS::Exit; 115 | break; 116 | 117 | case FILE_TYPE_WAV: 118 | decoder.init = WAV::Init; 119 | decoder.rate = WAV::GetSampleRate; 120 | decoder.channels = WAV::GetChannels; 121 | decoder.decode = WAV::Decode; 122 | decoder.position = WAV::GetPosition; 123 | decoder.length = WAV::GetLength; 124 | decoder.seek = WAV::Seek; 125 | decoder.term = WAV::Exit; 126 | break; 127 | 128 | case FILE_TYPE_XM: 129 | decoder.init = XM::Init; 130 | decoder.rate = XM::GetSampleRate; 131 | decoder.channels = XM::GetChannels; 132 | decoder.decode = XM::Decode; 133 | decoder.position = XM::GetPosition; 134 | decoder.length = XM::GetLength; 135 | decoder.seek = XM::Seek; 136 | decoder.term = XM::Exit; 137 | break; 138 | 139 | default: 140 | break; 141 | } 142 | 143 | (* decoder.init)(path); 144 | pspAudioInit((* decoder.channels)() == 2? PSP_AUDIO_FORMAT_STEREO : PSP_AUDIO_FORMAT_MONO); 145 | pspAudioSetFrequency((* decoder.rate)() == 48000? 48000 : 44100); 146 | pspAudioSetChannelCallback(0, Audio::Decode, nullptr); 147 | } 148 | 149 | bool IsPaused(void) { 150 | return paused; 151 | } 152 | 153 | void Pause(void) { 154 | paused = !paused; 155 | } 156 | 157 | void Stop(void) { 158 | playing = !playing; 159 | } 160 | 161 | u64 GetPosition(void) { 162 | return (* decoder.position)(); 163 | } 164 | 165 | u64 GetLength(void) { 166 | return (* decoder.length)(); 167 | } 168 | 169 | u64 GetPositionSeconds(void) { 170 | return (Audio::GetPosition() / (* decoder.rate)()); 171 | } 172 | 173 | u64 GetLengthSeconds(void) { 174 | return (Audio::GetLength() / (* decoder.rate)()); 175 | } 176 | 177 | u64 Seek(u64 index) { 178 | return (* decoder.seek)(index); 179 | } 180 | 181 | void Exit(void) { 182 | playing = true; 183 | paused = false; 184 | 185 | pspAudioSetChannelCallback(0, nullptr, nullptr); // Clear channel callback 186 | pspAudioEndPre(); 187 | sceKernelDelayThread(50 * 1000); 188 | pspAudioEnd(); 189 | (* decoder.term)(); 190 | 191 | // Clear metadata struct 192 | if (metadata.has_meta && metadata.cover_image) { 193 | g2dTexFree(&metadata.cover_image); 194 | } 195 | 196 | metadata = { 0 }; 197 | decoder = { 0 }; 198 | } 199 | } 200 | --------------------------------------------------------------------------------