├── ICON0.PNG ├── libsfm_ps3.a ├── lib ├── libfatfs.a ├── libntfs_ext.a └── include │ ├── fflib.h │ ├── types.h │ ├── ffconf.h │ └── ff.h ├── include ├── font.h ├── font_b.h ├── ttf_render.h ├── ver.h ├── console.h ├── osk_input.h ├── fsutil.h ├── rsxutil.h ├── statvfs.h ├── pad.h ├── util.h ├── mem_allocate.h ├── compat.h ├── iosupport.h ├── fm.h ├── types.h ├── libfont2.h ├── storage.h ├── ntfs.h └── config.h ├── source ├── ttf_render.c ├── main.c ├── pad.c ├── console.c ├── osk_input.c ├── msxfont.c ├── util.c ├── libfont.c └── fsutil.c ├── how2.netdebug ├── udpd.py ├── sfo.xml ├── README.md ├── Makefile.pkg ├── Makefile.lib └── Makefile /ICON0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/ICON0.PNG -------------------------------------------------------------------------------- /libsfm_ps3.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/libsfm_ps3.a -------------------------------------------------------------------------------- /lib/libfatfs.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/lib/libfatfs.a -------------------------------------------------------------------------------- /lib/libntfs_ext.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/lib/libntfs_ext.a -------------------------------------------------------------------------------- /include/font.h: -------------------------------------------------------------------------------- 1 | #define size_font 28672 2 | 3 | extern unsigned char font[28672]; 4 | -------------------------------------------------------------------------------- /source/ttf_render.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/source/ttf_render.c -------------------------------------------------------------------------------- /include/font_b.h: -------------------------------------------------------------------------------- 1 | #define size_font_b 28672 2 | 3 | extern unsigned char font_b[28672]; 4 | -------------------------------------------------------------------------------- /include/ttf_render.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmirel/fm_psx/HEAD/include/ttf_render.h -------------------------------------------------------------------------------- /how2.netdebug: -------------------------------------------------------------------------------- 1 | make 'DFLAGS=-DDEBUG_IP=\"192.168.2.191\"' 2 | 3 | #use python udpd.py in a separate session to follow the debug stream 4 | -------------------------------------------------------------------------------- /source/main.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "types.h" 4 | 5 | extern s32 fmapp_run(); 6 | // 7 | s32 main(s32 argc, const char* argv[]) 8 | { 9 | return fmapp_run(); 10 | } 11 | -------------------------------------------------------------------------------- /include/ver.h: -------------------------------------------------------------------------------- 1 | //v0.5.3 - enable EXT3 support via NTFS access API 2 | //v0.5.2 - fix ntfs and exfat mount/unmount on both ports 3 | //v0.5.1 - fix ntfs mount/unmount 4 | //v0.5.0 - adds ntfs support 5 | //v0.4.0 - adds library support 6 | #define SWVER "v0.5.3" 7 | -------------------------------------------------------------------------------- /udpd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import socket 4 | UDP_IP = "0.0.0.0" 5 | UDP_PORT = 18194 6 | sock = socket.socket(socket.AF_INET, # Internet 7 | socket.SOCK_DGRAM) # UDP 8 | sock.bind((UDP_IP, UDP_PORT)) 9 | while True: 10 | data, addr = sock.recvfrom(UDP_PORT) 11 | print data, 12 | -------------------------------------------------------------------------------- /include/console.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSOLE_H 2 | #define CONSOLE_H 3 | 4 | extern int con_x; 5 | extern int con_y; 6 | 7 | void initConsole(); 8 | 9 | void DbgHeader(char *str); 10 | 11 | void DbgMess(char *str); 12 | 13 | void DbgDraw(); 14 | 15 | void DPrintf(char *format, ...); 16 | 17 | void NPrintf(const char* fmt, ...); 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /include/osk_input.h: -------------------------------------------------------------------------------- 1 | #ifndef OSK_INPUT_H 2 | #define OSK_INPUT_H 3 | 4 | #include 5 | 6 | void UTF16_to_UTF8(u16 *stw, u8 *stb); 7 | void UTF8_to_UTF16(u8 *stb, u16 *stw); 8 | void UTF8_to_Ansi(char *utf8, char *ansi, int len); 9 | void UTF32_to_UTF8(u32 *stw, u8 *stb); 10 | 11 | int Get_OSK_String(char *caption, char *str, int len); 12 | int Get_OSK_String_no_lang(char *caption, char *str, int len); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /include/fsutil.h: -------------------------------------------------------------------------------- 1 | //fsutil.h 2 | #ifndef __FSUTIL__ 3 | #define __FSUTIL__ 4 | 5 | #define FS_S_IFMT 0170000 6 | #define FS_S_IFDIR 0040000 7 | 8 | #define S_ISDIR(m) (((m)&_IFMT) == _IFDIR) 9 | 10 | int fs_path_scan (struct fm_panel *p); 11 | 12 | int fs_job_scan (struct fm_job *p); 13 | 14 | int fs_get_fstype (char *path, int *npo); 15 | 16 | int fatfs_init(); 17 | 18 | //automounter logic 19 | int rootfs_probe (); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/rsxutil.h: -------------------------------------------------------------------------------- 1 | #ifndef __RSXUTIL_H__ 2 | #define __RSXUTIL_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define CB_SIZE 0x100000 8 | #define HOST_SIZE (32*1024*1024) 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern gcmContextData *context; 15 | extern u32 display_width; 16 | extern u32 display_height; 17 | extern u32 curr_fb; 18 | 19 | void set_render_target(u32 index); 20 | void init_screen(void *host_addr,u32 size); 21 | void waitflip(); 22 | void flip(); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/statvfs.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_STATVFS_H 2 | #define _SYS_STATVFS_H 3 | 4 | 5 | #define ST_RDONLY 0x0001 6 | #define ST_NOSUID 0x0002 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include 13 | 14 | typedef __uint32_t fsblkcnt_t; 15 | typedef __uint32_t fsfilcnt_t; 16 | 17 | struct statvfs { 18 | unsigned long f_bsize; 19 | unsigned long f_frsize; 20 | fsblkcnt_t f_blocks; 21 | fsblkcnt_t f_bfree; 22 | fsblkcnt_t f_bavail; 23 | fsfilcnt_t f_files; 24 | fsfilcnt_t f_ffree; 25 | fsfilcnt_t f_favail; 26 | unsigned long f_fsid; 27 | unsigned long f_flag; 28 | unsigned long f_namemax; 29 | }; 30 | 31 | int statvfs(const char *path, struct statvfs *buf); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | 38 | #endif // _SYS_STATVFS_H -------------------------------------------------------------------------------- /include/pad.h: -------------------------------------------------------------------------------- 1 | #ifndef PAD_H 2 | #define PAD_H 3 | 4 | #include 5 | 6 | #define BUTTON_LEFT 32768 7 | #define BUTTON_DOWN 16384 8 | #define BUTTON_RIGHT 8192 9 | #define BUTTON_UP 4096 10 | #define BUTTON_START 2048 11 | #define BUTTON_R3 1024 12 | #define BUTTON_L3 512 13 | #define BUTTON_SELECT 256 14 | 15 | #define BUTTON_SQUARE 128 16 | #define BUTTON_CROSS 64 17 | #define BUTTON_CIRCLE 32 18 | #define BUTTON_TRIANGLE 16 19 | #define BUTTON_R1 8 20 | #define BUTTON_L1 4 21 | #define BUTTON_R2 2 22 | #define BUTTON_L2 1 23 | 24 | extern padInfo padinfo; 25 | extern padData paddata; 26 | 27 | extern unsigned new_pad; // new pad buttons pressed (only can see one time, when it change from 0 to 1) 28 | extern unsigned old_pad; // old pad buttons pressed (only can change when you release the button) 29 | 30 | extern int pad_alive; // if 1 paddata is valid 31 | 32 | extern int rumble1_on; // used for rumble 33 | extern int rumble2_on; 34 | 35 | unsigned ps3pad_read(); // read the first conected pad 36 | 37 | #endif -------------------------------------------------------------------------------- /include/util.h: -------------------------------------------------------------------------------- 1 | //util.h 2 | #ifndef __UTIL_H__ 3 | #define __UTIL_H__ 4 | 5 | #include 6 | 7 | // change to 2D context ( virtual size of the screen is 848.0 x 512.0) 8 | //for 8x8 font, we can split the screen into 106x64 chars - 2 panes w53chars 9 | //we leave 8 lines for progress/status/info below the panes 10 | #define PANEL_W 53 11 | #define PANEL_H 60 12 | #define STATUS_H 4 13 | 14 | #define CBSIZE 256 //char buffer size 15 | 16 | extern char *na_string; 17 | void do_flip (); 18 | 19 | //dialog 20 | int YesNoDialog (char * str); 21 | //progress dialog 22 | int ProgressBarActionGet (); 23 | void DoubleProgressBarDialog(char *caption); 24 | void ProgressBarUpdate(u32 cprc, const char *msg); 25 | void ProgressBar2Update(u32 cprc, const char *msg); 26 | 27 | int fps_update (); 28 | void DrawRect2d (float x, float y, float z, float w, float h, u32 rgba); 29 | int NPad (int btn); 30 | int PPad (int btn); 31 | int APad (int btn); 32 | 33 | //osk_input requires these 34 | void UTF8_to_UTF16(u8 *stb, u16 *stw); 35 | void UTF16_to_UTF8(u16 *stw, u8 *stb); 36 | void Draw_scene(); 37 | void cls(); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /sfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 01.00 5 | 6 | 7 | 133 8 | 9 | 10 | 1 11 | 12 | 13 | HG 14 | 15 | 16 | 2100 17 | 18 | 19 | This application was created with the official non-official SDK called PSL1GHT, for more information visit http://www.psl1ght.com/ . This is in no way associated with Sony Computer Entertainment Inc., please do not contact them for help, they will not be able to provide it. 20 | 21 | 22 | 0 23 | 24 | 25 | 03.4000 26 | 27 | 28 | 63 29 | 30 | 31 | 279 32 | 33 | 34 | Simple File Manager 35 | 36 | 37 | PS3SFM001 38 | 39 | 40 | 01.00 41 | 42 | 43 | -------------------------------------------------------------------------------- /lib/include/fflib.h: -------------------------------------------------------------------------------- 1 | //fflib.h 2 | 3 | #include "types.h" 4 | 5 | #define MAXFDS 128 6 | 7 | //initialize the fatfs managed lib 8 | int fflib_init(); 9 | 10 | /* 11 | attach a drive number/idx to a system device id 12 | 13 | FatFS uses drive numbers like 0:/, 1:/, 2:/.. etc 14 | this allows attaching a system device id to a drive number 15 | if you want to probe for FAT/ExFAT FS on the drive, use 'now' 16 | e.g. fflib_attach (0, 0x010300000000000AULL, 1); 17 | this will assign drive 0 to system device 0x010300000000000AULL and probe for FAT/ExFAT 18 | the assignment will remain even if a FAT/ExFAT FS is not found, use fflib_detach to de-assign 19 | */ 20 | int fflib_attach(int idx, u64 id, int now); 21 | 22 | //detach a drive number/idx from a system device 23 | int fflib_detach(int idx); 24 | 25 | //get system device id assigned to the drive number/idx 26 | u64 fflib_id_get(int idx); 27 | 28 | //get file descriptor associated to a drive number/idx 29 | int fflib_fd_get(int idx); 30 | 31 | //get sector size associated to a drive number/idx 32 | int fflib_ss_get(int idx); 33 | 34 | //set file descriptor associated to a drive number/idx - this shouldn't be used in app 35 | int fflib_fd_set(int idx, int fd); 36 | 37 | //set sector size associated to a drive number/idx - this shouldn't be used in app 38 | int fflib_ss_set(int idx, int ss); 39 | 40 | //returns f_stat on a path: FR_OK or, 41 | //FR_NO_FILE Could not find the file in the directory. 42 | //FR_NO_PATH Could not find the path. A directory in the path name could not be found. 43 | //or other errors according to f_stat 44 | int fflib_is_fatfs (char *path); 45 | -------------------------------------------------------------------------------- /source/pad.c: -------------------------------------------------------------------------------- 1 | #include "pad.h" 2 | #include 3 | 4 | unsigned temp_pad = 0, new_pad = 0, old_pad = 0; 5 | 6 | padInfo padinfo; 7 | padData paddata; 8 | int pad_alive=0; 9 | 10 | 11 | int rumble1_on = 0; 12 | int rumble2_on = 0; 13 | int last_rumble = 0; 14 | 15 | 16 | unsigned ps3pad_read() 17 | { 18 | int n; 19 | 20 | padActParam actparam; 21 | 22 | unsigned butt = 0; 23 | 24 | pad_alive = 0; 25 | 26 | sysUtilCheckCallback(); 27 | 28 | ioPadGetInfo(&padinfo); 29 | 30 | for(n = 0; n < MAX_PADS; n++) { 31 | 32 | if(padinfo.status[n]) { 33 | 34 | ioPadGetData(n, &paddata); 35 | pad_alive = 1; 36 | butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff); 37 | break; 38 | 39 | } 40 | } 41 | 42 | 43 | if(!pad_alive) butt = 0; 44 | else { 45 | actparam.small_motor = 0; 46 | actparam.large_motor = 0; 47 | 48 | if(rumble1_on) { 49 | 50 | actparam.large_motor = 255; 51 | 52 | rumble1_on++; 53 | 54 | if(rumble1_on > 15) rumble1_on = 0; 55 | 56 | } 57 | 58 | if(rumble2_on) { 59 | 60 | actparam.small_motor = 1; 61 | 62 | rumble2_on++; 63 | 64 | if(rumble2_on > 10) rumble2_on = 0; 65 | } 66 | 67 | last_rumble = n; 68 | 69 | ioPadSetActDirect(n, &actparam); 70 | } 71 | 72 | temp_pad = butt; 73 | 74 | new_pad = temp_pad & (~old_pad); old_pad = temp_pad; 75 | 76 | 77 | return butt; 78 | } 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fm_psx 2 | simple file manager for PS3 3 |
4 |
5 | usage: 6 | 7 | - L1 and R1 change active/current panel to left(L1) or right(R1) 8 | - cross and circle, right and left used to navigate in and out of directories 9 | - up and down scroll current selection- rectangle for copy files/dirs 10 | - triangle for delete of copy/dirs 11 | - START rename file/dir 12 | - SELECT create dir 13 |
14 | 15 | todos: 16 | 17 | - sanity checks 18 | - available storage check and report 19 | - other confirmation dialogs on rename/delete 20 | - contextual menu(?!) 21 | 22 | later todos: 23 | + split the framework into file management lib and manager 24 | + write a file management lib that will handle system, ntfs/ext3 and exfat access to files: 25 | - use path names which will include filesystem specification: 26 | * for system: /dev_hdd0/, /dev_bdvd/, /app_home/, /host_root/ 27 | * for ntfs and/or ext3: /ntfs0:/, /ext0:/ 28 | * for ex/fat: /fat0:/ 29 | * others.. 30 | - store FS/file/dir specification in a pointer (e.g. PS3FP) while allowing direct access to its attributes (e.g. fd / file descriptor) for flexibility 31 | - will need to support at mininum ps3_fopen, ps3_fclose, ps3_fseek, ps3_f2sectors, ps3_diropen, ps3_dirnext, ps3_dirclose, etc 32 | - will need to handle detection/scanning of portable storage (with transparent mounting/unmounting) 33 | 34 | 35 | !BE EXTRA CAREFUL WITH SYSTEM FILES/DIRS! 36 |
37 | USE AT YOUR OWN RISK! 38 | 39 | # building 40 | use the opensource toolchain and libs from here: 41 | - https://github.com/bucanero/ps3toolchain 42 | - https://github.com/bucanero/PSL1GHT 43 | - https://github.com/Estwald/PSDK3v2/tree/master/libraries-src/Tiny3D 44 | 45 | additional libraries can be found here but should not be required 46 | - https://github.com/bucanero/psl1ght-libs 47 | -------------------------------------------------------------------------------- /include/mem_allocate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * mem_allocate.h - Memory allocation and destruction calls. 3 | * 4 | * Copyright (c) 2009 Rhys "Shareese" Koedijk 5 | * Copyright (c) 2006 Michael "Chishm" Chisholm 6 | * 7 | * This program/include file is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as published 9 | * by the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program/include file is distributed in the hope that it will be 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software Foundation, 19 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef _MEM_ALLOCATE_H 23 | #define _MEM_ALLOCATE_H 24 | 25 | #include 26 | 27 | static inline void* ntfs_alloc (size_t size) { 28 | return malloc(size); 29 | } 30 | 31 | static inline void* ntfs_align (size_t size) { 32 | #ifdef __wii__ 33 | return memalign(32, size); 34 | #else 35 | return memalign(32, size); 36 | //return malloc(size); 37 | #endif 38 | } 39 | 40 | static inline void ntfs_free (void* mem) { 41 | free(mem); 42 | } 43 | 44 | extern __inline__ void* mem_alloc (size_t size) { 45 | return malloc(size); 46 | } 47 | 48 | extern __inline__ void* mem_calloc (size_t count, size_t size) { 49 | return calloc(count, size); 50 | } 51 | 52 | extern __inline__ void* mem_realloc (void *p, size_t size) { 53 | return realloc(p, size); 54 | } 55 | 56 | extern __inline__ void* mem_align (size_t a, size_t size) { 57 | #ifdef __wii__ 58 | return memalign(a, size); 59 | #else 60 | return memalign(a, size); 61 | #endif 62 | } 63 | 64 | extern __inline__ void mem_free (void* mem) { 65 | free(mem); 66 | } 67 | 68 | #endif /* _MEM_ALLOCATE_H */ 69 | -------------------------------------------------------------------------------- /include/compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * compat.h - Tweaks for Windows compatibility. 3 | * 4 | * Copyright (c) 2002 Richard Russon 5 | * Copyright (c) 2002-2004 Anton Altaparmakov 6 | * Copyright (c) 2008-2009 Szabolcs Szakacsits 7 | * 8 | * This program/include file is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License as published 10 | * by the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program/include file is distributed in the hope that it will be 14 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program (in the main directory of the NTFS-3G 20 | * distribution in the file COPYING); if not, write to the Free Software 21 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef _NTFS_COMPAT_H 25 | #define _NTFS_COMPAT_H 26 | 27 | #ifdef HAVE_CONFIG_H 28 | #include "config.h" 29 | #endif 30 | #ifdef HAVE_SYS_PARAM_H 31 | #include 32 | #endif 33 | 34 | #include /* ENODATA */ 35 | 36 | #ifndef ENODATA 37 | #define ENODATA ENOENT 38 | #endif 39 | 40 | #ifndef PATH_MAX 41 | #define PATH_MAX 4096 42 | #endif 43 | 44 | #ifndef HAVE_FFS 45 | extern int ffs(int i); 46 | #endif /* HAVE_FFS */ 47 | 48 | #ifndef HAVE_DAEMON 49 | extern int daemon(int nochdir, int noclose); 50 | #endif /* HAVE_DAEMON */ 51 | 52 | #ifndef HAVE_STRSEP 53 | extern char *strsep(char **stringp, const char *delim); 54 | #endif /* HAVE_STRSEP */ 55 | 56 | #ifdef WINDOWS 57 | 58 | #define HAVE_STDIO_H /* mimic config.h */ 59 | #define HAVE_STDARG_H 60 | 61 | #define atoll _atoi64 62 | #define fdatasync commit 63 | #define __inline__ inline 64 | #define __attribute__(X) /*nothing*/ 65 | 66 | #else /* !defined WINDOWS */ 67 | 68 | #ifndef O_BINARY 69 | #define O_BINARY 0 /* unix is binary by default */ 70 | #endif 71 | 72 | #ifdef PS3_GEKKO 73 | 74 | //#include "mem_allocate.h" 75 | 76 | #define XATTR_CREATE 1 77 | #define XATTR_REPLACE 2 78 | 79 | #define MINORBITS 20 80 | #define MINORMASK ((1U << MINORBITS) - 1) 81 | 82 | #define major(dev) ((unsigned int) ((dev) >> MINORBITS)) 83 | #define minor(dev) ((unsigned int) ((dev) & MINORMASK)) 84 | #define mkdev(ma,mi) (((ma) << MINORBITS) | (mi)) 85 | #define random rand 86 | 87 | #endif /* defined GEKKO */ 88 | 89 | #endif /* defined WINDOWS */ 90 | 91 | #endif /* defined _NTFS_COMPAT_H */ 92 | 93 | -------------------------------------------------------------------------------- /include/iosupport.h: -------------------------------------------------------------------------------- 1 | //--------------------------------------------------------------------------------- 2 | #ifndef __iosupp_h__ 3 | #define __iosupp_h__ 4 | //--------------------------------------------------------------------------------- 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include 11 | #include 12 | #include "statvfs.h" 13 | 14 | enum { 15 | STD_IN, 16 | STD_OUT, 17 | STD_ERR, 18 | STD_MAX = 16 19 | }; 20 | 21 | 22 | typedef struct { 23 | int device; 24 | void *fileStruct; 25 | } __handle; 26 | 27 | 28 | typedef struct { 29 | const char *name; 30 | int structSize; 31 | int (*open_r)(struct _reent *r, void *fileStruct, const char *path, int flags, int mode); 32 | int (*close_r)(struct _reent *r, int fd); 33 | ssize_t (*write_r)(struct _reent *r, int fd, const char *ptr, size_t len); 34 | ssize_t (*read_r)(struct _reent *r, int fd, char *ptr, size_t len); 35 | off_t (*seek_r)(struct _reent *r, int fd, off_t pos, int dir); 36 | s64 (*seek64_r)(struct _reent *r, int fd, s64 pos, int dir); 37 | int (*fstat_r)(struct _reent *r, int fd, struct stat *st); 38 | int (*stat_r)(struct _reent *r, const char *file, struct stat *st); 39 | int (*link_r)(struct _reent *r, const char *existing, const char *newLink); 40 | int (*unlink_r)(struct _reent *r, const char *name); 41 | int (*chdir_r)(struct _reent *r, const char *name); 42 | int (*rename_r) (struct _reent *r, const char *oldName, const char *newName); 43 | int (*mkdir_r) (struct _reent *r, const char *path, int mode); 44 | 45 | int dirStateSize; 46 | 47 | DIR_ITER* (*diropen_r)(struct _reent *r, DIR_ITER *dirState, const char *path); 48 | int (*dirreset_r)(struct _reent *r, DIR_ITER *dirState); 49 | int (*dirnext_r)(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *filestat); 50 | int (*dirclose_r)(struct _reent *r, DIR_ITER *dirState); 51 | int (*statvfs_r)(struct _reent *r, const char *path, struct statvfs *buf); 52 | int (*ftruncate_r)(struct _reent *r, int fd, off_t len); 53 | int (*fsync_r)(struct _reent *r,int fd); 54 | int (*file_to_sectors)(struct _reent *r,const char *path,uint32_t *sec_out,uint32_t *size_out,int max,int phys); 55 | void *deviceData; 56 | } devoptab_t; 57 | 58 | extern const devoptab_t *devoptab_list[]; 59 | 60 | int AddDevice( const devoptab_t* device); 61 | int FindDevice(const char* name); 62 | int RemoveDevice(const char* name); 63 | void setDefaultDevice( int device ); 64 | const devoptab_t* GetDeviceOpTab (const char *name); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | //--------------------------------------------------------------------------------- 71 | #endif // __iosupp_h__ 72 | //--------------------------------------------------------------------------------- 73 | -------------------------------------------------------------------------------- /include/fm.h: -------------------------------------------------------------------------------- 1 | //fm.h - simple file manager 2 | #ifndef __FM__ 3 | #define __FM__ 4 | 5 | #define KBSZ (1024) //KB: 1024 6 | #define MBSZ (1048576) //MB: 1024*1024 7 | #define GBSZ (1073741824) //GB: 1024*1024*1024 8 | 9 | typedef enum { 10 | FS_TNONE = 0, 11 | FS_TSYS, 12 | FS_TNTFS, 13 | FS_TEXT, 14 | FS_TFAT, 15 | } FS_TYPE; 16 | 17 | struct fm_file { 18 | char *name; 19 | char dir; 20 | unsigned long size; 21 | // 22 | char selected; 23 | // 24 | struct fm_file *prev; 25 | struct fm_file *next; 26 | }; 27 | 28 | struct fm_panel { 29 | char *path; //current path - full path, including drive identifier 30 | struct fm_file *entries; //entries 31 | struct fm_file *history; //browsing history: dirs which were traversed 32 | struct fm_file *current; //current entry/selection 33 | unsigned int current_idx; //index of currently selected item, for scrolling 34 | // 35 | int x, y, w, h; //position+dimentions 36 | char active; //panel is active or not 37 | char fs_type; //file system type for panel 38 | // 39 | int files; 40 | int dirs; 41 | unsigned long long fsize; 42 | }; 43 | 44 | struct fm_job { 45 | char *spath; //current path - full path, including drive identifier 46 | char *dpath; //current path - full path, including drive identifier 47 | struct fm_file *entries; //entries 48 | // 49 | char stype; //file system type for source 50 | char dtype; //file system type for destination 51 | // 52 | int files; 53 | int dirs; 54 | unsigned long long fsize; 55 | }; 56 | 57 | int fm_entry_add (struct fm_file **entries, char *fn, char dir, unsigned long fsz); 58 | int fm_entry_pull (struct fm_file **entries); 59 | 60 | //list file management job 61 | int fm_job_list (char *path); 62 | int fm_job_add (struct fm_job *p, char *fn, char dir, unsigned long fsz); 63 | //clear file management job 64 | int fm_job_clear (struct fm_job *job); 65 | //copy files/dirs from source to destination 66 | int fm_job_copy (char *src, char *dst, int (*ui_render)(int dt)); 67 | //remove files/dirs from source 68 | int fm_job_delete (char *src, int (*ui_render)(int dt)); 69 | int fm_job_rename (char *path, char *old, char *new); 70 | // 71 | int fm_job_newdir (char *path, char *new); 72 | //draw (4) status messages 73 | int fm_status_draw (int dat); 74 | //set status message for index 75 | int fm_status_set (char *sm, int idx, int col); 76 | 77 | int fm_panel_enter (struct fm_panel *p); 78 | int fm_panel_exit (struct fm_panel *p); 79 | int fm_panel_reload (struct fm_panel *p); 80 | 81 | int fm_panel_clear (struct fm_panel *p); 82 | int fm_panel_scan (struct fm_panel *p, char *path); 83 | 84 | int fm_panel_init (struct fm_panel *p, int x, int y, int w, int h, char act); 85 | int fm_panel_draw (struct fm_panel *p); 86 | //scroll current item up/dn 87 | int fm_panel_scroll (struct fm_panel *p, int dn); 88 | //locate item and set as current 89 | int fm_panel_locate (struct fm_panel *p, char *path); 90 | 91 | //add file/dir entry to panel 92 | int fm_panel_add (struct fm_panel *p, char *fn, char dir, unsigned long fsz); 93 | 94 | //remove file/dir entry from panel 95 | int fm_panel_del (struct fm_panel *p, char *fn); 96 | 97 | int fm_fname_get (struct fm_file *link, int cw, char *out); 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * types.h - Misc type definitions not related to on-disk structure. 3 | * Originated from the Linux-NTFS project. 4 | * 5 | * Copyright (c) 2000-2004 Anton Altaparmakov 6 | * 7 | * This program/include file is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as published 9 | * by the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program/include file is distributed in the hope that it will be 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program (in the main directory of the NTFS-3G 19 | * distribution in the file COPYING); if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef _NTFS_TYPES_H 24 | #define _NTFS_TYPES_H 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #if HAVE_STDINT_H || !HAVE_CONFIG_H 31 | #include 32 | #endif 33 | #ifdef HAVE_SYS_TYPES_H 34 | #include 35 | #endif 36 | 37 | #ifdef PS3_GEKKO 38 | //#include 39 | #include "compat.h" 40 | #include 41 | #include 42 | #define BOOL int 43 | #define FALSE 0 44 | #define TRUE 1 45 | 46 | 47 | #if 0 48 | #ifdef HAVE_SYS_TYPES_H 49 | #include 50 | #endif 51 | #else /* GEKKO */ 52 | #endif 53 | 54 | #include 55 | #if 0 56 | typedef uint8_t u8; /* Unsigned types of an exact size */ 57 | typedef uint16_t u16; 58 | typedef uint32_t u32; 59 | typedef uint64_t u64; 60 | 61 | typedef int8_t s8; /* Signed types of an exact size */ 62 | typedef int16_t s16; 63 | typedef int32_t s32; 64 | typedef int64_t s64; 65 | #endif 66 | 67 | #endif /* GEKKO */ 68 | 69 | typedef u16 le16; 70 | typedef u32 le32; 71 | typedef u64 le64; 72 | 73 | /* 74 | * Declare sle{16,32,64} to be unsigned because we do not want sign extension 75 | * on BE architectures. 76 | */ 77 | typedef u16 sle16; 78 | typedef u32 sle32; 79 | typedef u64 sle64; 80 | 81 | typedef u16 ntfschar; /* 2-byte Unicode character type. */ 82 | #define UCHAR_T_SIZE_BITS 1 83 | 84 | /* 85 | * Clusters are signed 64-bit values on NTFS volumes. We define two types, LCN 86 | * and VCN, to allow for type checking and better code readability. 87 | */ 88 | typedef s64 VCN; 89 | typedef sle64 leVCN; 90 | typedef s64 LCN; 91 | typedef sle64 leLCN; 92 | 93 | /* 94 | * The NTFS journal $LogFile uses log sequence numbers which are signed 64-bit 95 | * values. We define our own type LSN, to allow for type checking and better 96 | * code readability. 97 | */ 98 | typedef s64 LSN; 99 | typedef sle64 leLSN; 100 | 101 | /* 102 | * Cygwin has a collision between our BOOL and 's 103 | * As long as this file will be included after were fine. 104 | */ 105 | #ifndef PS3_GEKKO 106 | #ifndef _WINDEF_H 107 | /** 108 | * enum BOOL - These are just to make the code more readable... 109 | */ 110 | typedef enum { 111 | #ifndef FALSE 112 | FALSE = 0, 113 | #endif 114 | #ifndef NO 115 | NO = 0, 116 | #endif 117 | #ifndef ZERO 118 | ZERO = 0, 119 | #endif 120 | #ifndef TRUE 121 | TRUE = 1, 122 | #endif 123 | #ifndef YES 124 | YES = 1, 125 | #endif 126 | #ifndef ONE 127 | ONE = 1, 128 | #endif 129 | } BOOL; 130 | #endif /* defined _WINDEF_H */ 131 | #endif /* defined GECKO */ 132 | 133 | /** 134 | * enum IGNORE_CASE_BOOL - 135 | */ 136 | typedef enum { 137 | CASE_SENSITIVE = 0, 138 | IGNORE_CASE = 1, 139 | } IGNORE_CASE_BOOL; 140 | 141 | #define STATUS_OK (0) 142 | #define STATUS_ERROR (-1) 143 | #define STATUS_RESIDENT_ATTRIBUTE_FILLED_MFT (-2) 144 | #define STATUS_KEEP_SEARCHING (-3) 145 | #define STATUS_NOT_FOUND (-4) 146 | 147 | /* 148 | * Force alignment in a struct if required by processor 149 | */ 150 | union ALIGNMENT { 151 | u64 u64align; 152 | void *ptralign; 153 | } ; 154 | 155 | #endif /* defined _NTFS_TYPES_H */ 156 | 157 | -------------------------------------------------------------------------------- /lib/include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * types.h - Misc type definitions not related to on-disk structure. 3 | * Originated from the Linux-NTFS project. 4 | * 5 | * Copyright (c) 2000-2004 Anton Altaparmakov 6 | * 7 | * This program/include file is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License as published 9 | * by the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program/include file is distributed in the hope that it will be 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program (in the main directory of the NTFS-3G 19 | * distribution in the file COPYING); if not, write to the Free Software 20 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef _NTFS_TYPES_H 24 | #define _NTFS_TYPES_H 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include "config.h" 28 | #endif 29 | 30 | #if HAVE_STDINT_H || !HAVE_CONFIG_H 31 | #include 32 | #endif 33 | #ifdef HAVE_SYS_TYPES_H 34 | #include 35 | #endif 36 | 37 | #ifdef PS3_GEKKO 38 | //#include 39 | #include "compat.h" 40 | #include 41 | #include 42 | #define BOOL int 43 | #define FALSE 0 44 | #define TRUE 1 45 | 46 | 47 | #if 0 48 | #ifdef HAVE_SYS_TYPES_H 49 | #include 50 | #endif 51 | #else /* GEKKO */ 52 | #endif 53 | 54 | #include 55 | #if 0 56 | typedef uint8_t u8; /* Unsigned types of an exact size */ 57 | typedef uint16_t u16; 58 | typedef uint32_t u32; 59 | typedef uint64_t u64; 60 | 61 | typedef int8_t s8; /* Signed types of an exact size */ 62 | typedef int16_t s16; 63 | typedef int32_t s32; 64 | typedef int64_t s64; 65 | #endif 66 | 67 | #endif /* GEKKO */ 68 | 69 | typedef u16 le16; 70 | typedef u32 le32; 71 | typedef u64 le64; 72 | 73 | /* 74 | * Declare sle{16,32,64} to be unsigned because we do not want sign extension 75 | * on BE architectures. 76 | */ 77 | typedef u16 sle16; 78 | typedef u32 sle32; 79 | typedef u64 sle64; 80 | 81 | typedef u16 ntfschar; /* 2-byte Unicode character type. */ 82 | #define UCHAR_T_SIZE_BITS 1 83 | 84 | /* 85 | * Clusters are signed 64-bit values on NTFS volumes. We define two types, LCN 86 | * and VCN, to allow for type checking and better code readability. 87 | */ 88 | typedef s64 VCN; 89 | typedef sle64 leVCN; 90 | typedef s64 LCN; 91 | typedef sle64 leLCN; 92 | 93 | /* 94 | * The NTFS journal $LogFile uses log sequence numbers which are signed 64-bit 95 | * values. We define our own type LSN, to allow for type checking and better 96 | * code readability. 97 | */ 98 | typedef s64 LSN; 99 | typedef sle64 leLSN; 100 | 101 | /* 102 | * Cygwin has a collision between our BOOL and 's 103 | * As long as this file will be included after were fine. 104 | */ 105 | #ifndef PS3_GEKKO 106 | #ifndef _WINDEF_H 107 | /** 108 | * enum BOOL - These are just to make the code more readable... 109 | */ 110 | typedef enum { 111 | #ifndef FALSE 112 | FALSE = 0, 113 | #endif 114 | #ifndef NO 115 | NO = 0, 116 | #endif 117 | #ifndef ZERO 118 | ZERO = 0, 119 | #endif 120 | #ifndef TRUE 121 | TRUE = 1, 122 | #endif 123 | #ifndef YES 124 | YES = 1, 125 | #endif 126 | #ifndef ONE 127 | ONE = 1, 128 | #endif 129 | } BOOL; 130 | #endif /* defined _WINDEF_H */ 131 | #endif /* defined GECKO */ 132 | 133 | /** 134 | * enum IGNORE_CASE_BOOL - 135 | */ 136 | typedef enum { 137 | CASE_SENSITIVE = 0, 138 | IGNORE_CASE = 1, 139 | } IGNORE_CASE_BOOL; 140 | 141 | #define STATUS_OK (0) 142 | #define STATUS_ERROR (-1) 143 | #define STATUS_RESIDENT_ATTRIBUTE_FILLED_MFT (-2) 144 | #define STATUS_KEEP_SEARCHING (-3) 145 | #define STATUS_NOT_FOUND (-4) 146 | 147 | /* 148 | * Force alignment in a struct if required by processor 149 | */ 150 | union ALIGNMENT { 151 | u64 u64align; 152 | void *ptralign; 153 | } ; 154 | 155 | #endif /* defined _NTFS_TYPES_H */ 156 | 157 | -------------------------------------------------------------------------------- /include/libfont2.h: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D - font library / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #ifndef LIBFONT2_H 7 | #define LIBFONT2_H 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* NOTE: LIBFONT is thinkin to work with Tiny3D 2D mode: you need to call tiny3d_Project2D() before to work with draw functions */ 16 | 17 | // initialize all datas. After you call it you don't have any font to use 18 | 19 | void ResetFont(); 20 | 21 | // used as byte_order in AddFontFromBitmapArray() 22 | 23 | #define BIT0_FIRST_PIXEL 0 24 | #define BIT7_FIRST_PIXEL 1 25 | 26 | /* add one font from one bitmap array. You can define the font range with first_char and last_char (in my sample i use two fonts that starts 27 | at chr 32 and finish iat chr 255 and other font starts at 0 and finish at 254. fonts can have one depth of 1, 2, 4, 8 bits (used as pixel intensity) 28 | to create smooth fonts and you can select the byte order (some fonts can use bit 7 as first pixel or bit 0) . 29 | 30 | w and h must be 8, 16, 32, ..... 31 | 32 | It receive one RSX texture pointer and return the texture pointer increased and aligned to 16 bytes think to use this pointer to build the next 33 | RSX texture. 34 | */ 35 | 36 | u8 * AddFontFromBitmapArray(u8 *font, u8 *texture, u8 first_char, u8 last_char, int w, int h, int bits_per_pixel, int byte_order); 37 | 38 | /* 39 | add one bitmap font creating it from True Type Fonts. You can define the font range with first_char and last_char in the range 0 to 255 40 | w and h must be 8, 16, 32, ..... 41 | 42 | The callback is used to create the font externally (it don't need to use freetype library directly) 43 | 44 | It receive one RSX texture pointer and return the texture pointer increased and aligned to 16 bytes think to use this pointer to build the next 45 | RSX texture. 46 | */ 47 | 48 | u8 * AddFontFromTTF(u8 *texture, u8 first_char, u8 last_char, int w, int h, 49 | void (* ttf_callback) (u8 chr, u8 * bitmap, short *w, short *h, short *y_correction)); 50 | 51 | /* 52 | 53 | SetFontTextureMethod: enables/disables multitexture merge with font color. 54 | 55 | It needs an external texture loaded in unit 1 (tiny3d_SetTextureWrap(1, ...)) and tiny3d_SelMultiTexturesMethod() enabled 56 | 57 | */ 58 | 59 | #define FONT_SINGLE_TEXTURE 0 // default method 60 | #define FONT_DOUBLE_TEXTURE 1 // enable and maps external second texture char by char 61 | #define FONT_DOUBLE_TEXTURE2 2 // enable and maps external second texture using the screen coordinates rectangle 62 | #define FONT_DOUBLE_TEXTUREMOD 3 // enable and maps external second texture using the module of coordinates rectangle (fixed with SetDoubleTextureModule()) 63 | 64 | void SetFontTextureMethod(int method); 65 | 66 | // used with FONT_DOUBLE_TEXTUREMOD for double texture method: second texture coordinates is calculated using (virtual_screen % mod)/mod relation 67 | 68 | void SetDoubleTextureModule(int module_x, int module_y); 69 | 70 | /* function to select the current font to use (the first is 0. if you select an undefined font, it uses font 0) */ 71 | 72 | void SetCurrentFont(int nfont); 73 | 74 | // font are resizable: the minimun is 8 x 8 but you can use as you want. Remember the font quality depends of the original size 75 | 76 | void SetFontSize(int sx, int sy); 77 | 78 | // select the color and the background color for the font. if you use 0 for bkcolor background is not drawing 79 | 80 | void SetFontColor(u32 color, u32 bkcolor); 81 | 82 | // enable/disable the autocenter feature. don't use '\n' or unsupported characters here 83 | 84 | void SetFontAutoCenter(int on_off); 85 | 86 | // compatibility with old name 87 | #define SetFontAutocenter SetFontAutoCenter 88 | 89 | // enable the auto new line if width is different to 0. When one word exceed the width specified, it skip to the next line 90 | 91 | void SetFontAutoNewLine(int width); 92 | 93 | // Z used to draw the font. Usually is 0.0f 94 | 95 | void SetFontZ(float z); 96 | 97 | // last X used 98 | 99 | float GetFontX(); 100 | 101 | // last Y used 102 | 103 | float GetFontY(); 104 | 105 | // change the screen width/height limits (usually 848 x 512.0. It is used only for center function and one of multitexture modes) 106 | 107 | void SetFontScreenLimits(float width, float height); 108 | 109 | // last Height used 110 | 111 | float GetFontHeight(); 112 | 113 | // last Width used 114 | 115 | float GetFontWidth(); 116 | 117 | // Get Width of a string 118 | 119 | float WidthFromStr(char* str); 120 | 121 | // function to draw one character 122 | 123 | void DrawChar(float x, float y, float z, u8 chr); 124 | 125 | // function to draw one string. It return X incremented 126 | 127 | float DrawString(float x, float y, char *str); 128 | 129 | // function to draw with fomat string similar to printf. It return X incremented 130 | 131 | float DrawFormatString(float x, float y, char *format, ...); 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif -------------------------------------------------------------------------------- /source/console.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef LIBBUILD 10 | void NPrintf (const char* fmt, ...) { } 11 | void initConsole() {} 12 | #else 13 | #include "console.h" 14 | 15 | #include 16 | #include 17 | 18 | //network debug via UDP 19 | #ifdef DEBUG_IP 20 | #include 21 | #include 22 | 23 | static int SocketFD; 24 | #define DEBUG_PORT 18194 25 | #endif 26 | void debugInit () 27 | { 28 | #ifdef DEBUG_IP 29 | #warning using network debug 30 | struct sockaddr_in stSockAddr; 31 | netInitialize (); 32 | SocketFD = netSocket (AF_INET, SOCK_DGRAM, IPPROTO_UDP); 33 | 34 | memset (&stSockAddr, 0, sizeof stSockAddr); 35 | 36 | stSockAddr.sin_family = AF_INET; 37 | stSockAddr.sin_port = htons (DEBUG_PORT); 38 | inet_pton (AF_INET, DEBUG_IP, &stSockAddr.sin_addr); 39 | 40 | netConnect (SocketFD, (struct sockaddr *)&stSockAddr, sizeof stSockAddr); 41 | 42 | NPrintf ("network debug module initialized\n") ; 43 | NPrintf ("ready to have a lot of fun\n") ; 44 | #endif 45 | } 46 | 47 | void NPrintf (const char* fmt, ...) 48 | { 49 | #ifdef DEBUG_IP 50 | char buffer[0x800]; 51 | va_list arg; 52 | va_start (arg, fmt); 53 | vsnprintf (buffer, sizeof (buffer), fmt, arg); 54 | va_end (arg); 55 | // 56 | netSend (SocketFD, buffer, strlen (buffer), 0); 57 | #endif 58 | } 59 | 60 | /*******************************************************************************************************************************************************/ 61 | /* CONSOLE DEBUG */ 62 | /*******************************************************************************************************************************************************/ 63 | 64 | #define CONSOLE_WIDTH (84) 65 | #define CONSOLE_HEIGHT (27) 66 | 67 | static char dbg_str1[128]; 68 | static char dbg_str2[128]; 69 | 70 | static char dbg_data[128 * CONSOLE_HEIGHT]; 71 | 72 | int con_x = 0, con_y =0; 73 | 74 | void cls2() 75 | { 76 | tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); 77 | 78 | // Enable alpha Test 79 | tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); 80 | 81 | // Enable alpha blending. 82 | tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 83 | TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO, 84 | TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); 85 | } 86 | 87 | 88 | void initConsole() 89 | { 90 | con_x = 0; con_y =0; 91 | dbg_str1[0] = dbg_str2[0] = 0; 92 | memset(dbg_data, 0, 128 * CONSOLE_HEIGHT); 93 | // 94 | debugInit(); 95 | } 96 | 97 | static char buff[4096]; 98 | 99 | void DbgHeader(char *str) 100 | { 101 | strncpy(dbg_str1, str, 128); 102 | } 103 | 104 | void DbgMess(char *str) 105 | { 106 | strncpy(dbg_str2, str, 128); 107 | } 108 | 109 | void DbgDraw() 110 | { 111 | int n; 112 | 113 | cls2(); 114 | 115 | SetFontColor(0x0fcf2fff, 0x00000000); 116 | 117 | SetFontAutoCenter(0); 118 | SetCurrentFont(2); 119 | SetFontSize(8, 8); 120 | 121 | for(n = 0; n < CONSOLE_HEIGHT; n++) { 122 | DrawString(0, 56 + n * 16, &dbg_data[128 * n]); 123 | } 124 | 125 | SetFontColor(0xffffffff, 0x00000000); 126 | SetCurrentFont(2); 127 | 128 | SetFontSize(16, 16); 129 | SetFontAutoCenter(1); 130 | 131 | DrawString(0, 16, dbg_str1); 132 | 133 | DrawString(0, 480, dbg_str2); 134 | 135 | SetFontAutoCenter(0); 136 | } 137 | 138 | void DPrintf(char *format, ...) 139 | { 140 | char *str = (char *) buff; 141 | va_list opt; 142 | 143 | va_start(opt, format); 144 | vsprintf( (void *) buff, format, opt); 145 | va_end(opt); 146 | #ifdef DEBUG_IP 147 | netSend(SocketFD, str, strlen(str), 0); 148 | #endif 149 | 150 | while(*str) { 151 | if(*str == '\n') { 152 | con_y++; 153 | con_x = 0; 154 | if(con_y >= CONSOLE_HEIGHT) { 155 | con_y = CONSOLE_HEIGHT - 1; 156 | memcpy(dbg_data, dbg_data + 128, 128 * (CONSOLE_HEIGHT -1)); 157 | dbg_data[128 * (CONSOLE_HEIGHT -1)] = 0; 158 | } else dbg_data[128 * con_y + con_x] = 0; 159 | } else { 160 | if(con_x < CONSOLE_WIDTH) { 161 | dbg_data[128 * con_y + con_x] = *str; 162 | dbg_data[128 * con_y + con_x + 1] = 0; 163 | con_x++; 164 | } else { 165 | con_y++; 166 | con_x = 0; 167 | if(con_y >= CONSOLE_HEIGHT) { 168 | con_y = CONSOLE_HEIGHT - 1; 169 | memcpy(dbg_data, dbg_data + 128, 128 * (CONSOLE_HEIGHT -1)); 170 | dbg_data[128 * (CONSOLE_HEIGHT -1)] = 0; 171 | 172 | } 173 | 174 | dbg_data[128 * con_y + con_x] = *str; 175 | dbg_data[128 * con_y + con_x + 1] = 0; 176 | con_x++; 177 | } 178 | } 179 | 180 | str++; 181 | } 182 | 183 | } 184 | 185 | #endif -------------------------------------------------------------------------------- /source/osk_input.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include "libfont2.h" 15 | #include "pad.h" 16 | 17 | #include "util.h" 18 | 19 | #define OSKDIALOG_FINISHED 0x503 20 | #define OSKDIALOG_UNLOADED 0x504 21 | #define OSKDIALOG_INPUT_ENTERED 0x505 22 | #define OSKDIALOG_INPUT_CANCELED 0x506 23 | 24 | #define SUCCESS 1 25 | #define FAILED 0 26 | 27 | volatile int osk_event = 0; 28 | volatile int osk_unloaded = 0; 29 | int osk_action = SUCCESS; 30 | 31 | static sys_mem_container_t container_mem; 32 | 33 | static oskCallbackReturnParam OutputReturnedParam; 34 | static oskParam DialogOskParam; 35 | static oskInputFieldInfo inputFieldInfo; 36 | 37 | extern void cls(); 38 | extern void Draw_scene(); 39 | 40 | static void my_eventHandle(u64 status, u64 param, void * userdata) { 41 | 42 | switch((u32) status) { 43 | 44 | case OSKDIALOG_INPUT_CANCELED: 45 | osk_event= OSKDIALOG_INPUT_CANCELED; 46 | break; 47 | 48 | case OSKDIALOG_UNLOADED: 49 | osk_unloaded= 1; 50 | break; 51 | 52 | case OSKDIALOG_INPUT_ENTERED: 53 | osk_event=OSKDIALOG_INPUT_ENTERED; 54 | break; 55 | 56 | case OSKDIALOG_FINISHED: 57 | osk_event=OSKDIALOG_FINISHED; 58 | break; 59 | 60 | default: 61 | break; 62 | } 63 | 64 | 65 | } 66 | 67 | static int osk_level = 0; 68 | 69 | static void OSK_exit(void) 70 | { 71 | if(osk_level == 2) { 72 | oskAbort(); 73 | oskUnloadAsync(&OutputReturnedParam); 74 | 75 | osk_event = 0; 76 | osk_action=FAILED; 77 | } 78 | 79 | if(osk_level >= 1) { 80 | sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT0); 81 | sysMemContainerDestroy(container_mem); 82 | } 83 | 84 | } 85 | 86 | int Get_OSK_String(char *caption, char *str, int len) 87 | { 88 | 89 | int ret=SUCCESS; 90 | 91 | u16 * message = NULL; 92 | u16 * OutWcharTex = NULL; 93 | u16 * InWcharTex = NULL; 94 | 95 | if(len > 256) len = 256; 96 | 97 | osk_level = 0; 98 | atexit(OSK_exit); 99 | 100 | if(sysMemContainerCreate(&container_mem, 8*1024*1024) < 0) return FAILED; 101 | 102 | osk_level = 1; 103 | 104 | message = malloc(strlen(caption)*2+32); 105 | if(!message) {ret=FAILED; goto end;} 106 | 107 | OutWcharTex = malloc(0x420*2); 108 | if(!OutWcharTex) {ret=FAILED; goto end;} 109 | 110 | InWcharTex = malloc(0x420*2); 111 | if(!InWcharTex) {ret=FAILED; goto end;} 112 | 113 | //memset(message, 0, 64); 114 | UTF8_to_UTF16((u8 *) caption, (u16 *) message); 115 | UTF8_to_UTF16((u8 *) str, (u16 *) InWcharTex); 116 | 117 | inputFieldInfo.message = (u16 *) message; 118 | inputFieldInfo.startText = (u16 *) InWcharTex; 119 | inputFieldInfo.maxLength = len; 120 | 121 | OutputReturnedParam.res = OSK_NO_TEXT; //OSK_OK; 122 | OutputReturnedParam.len = len; 123 | 124 | OutputReturnedParam.str = (u16 *) OutWcharTex; 125 | 126 | memset(OutWcharTex, 0, 1024); 127 | 128 | if(oskSetKeyLayoutOption (OSK_10KEY_PANEL | OSK_FULLKEY_PANEL)<0) {ret=FAILED; goto end;} 129 | 130 | DialogOskParam.firstViewPanel = OSK_PANEL_TYPE_ALPHABET_FULL_WIDTH; 131 | DialogOskParam.allowedPanels = (OSK_PANEL_TYPE_ALPHABET | OSK_PANEL_TYPE_NUMERAL); 132 | 133 | if(oskAddSupportLanguage ( OSK_PANEL_TYPE_ALPHABET )<0) {ret=FAILED; goto end;} 134 | 135 | if(oskSetLayoutMode( OSK_LAYOUTMODE_HORIZONTAL_ALIGN_CENTER )<0) {ret=FAILED; goto end;} 136 | 137 | oskPoint pos = {0.0, 0.0}; 138 | 139 | DialogOskParam.controlPoint = pos; 140 | DialogOskParam.prohibitFlags = OSK_PROHIBIT_RETURN; 141 | if(oskSetInitialInputDevice(OSK_DEVICE_PAD)<0) {ret=FAILED; goto end;} 142 | 143 | sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT0); 144 | sysUtilRegisterCallback(SYSUTIL_EVENT_SLOT0, my_eventHandle, NULL); 145 | 146 | osk_action = SUCCESS; 147 | osk_unloaded = false; 148 | 149 | if(oskLoadAsync(container_mem, (const void *) &DialogOskParam, (const void *) &inputFieldInfo)<0) {ret=FAILED; goto end;} 150 | 151 | osk_level = 2; 152 | 153 | while(!osk_unloaded) 154 | { 155 | cls(); 156 | 157 | Draw_scene(); 158 | 159 | tiny3d_Flip(); 160 | 161 | ps3pad_read(); 162 | 163 | switch(osk_event) 164 | { 165 | case OSKDIALOG_INPUT_ENTERED: 166 | oskGetInputText(&OutputReturnedParam); 167 | osk_event = 0; 168 | break; 169 | 170 | case OSKDIALOG_INPUT_CANCELED: 171 | oskAbort(); 172 | oskUnloadAsync(&OutputReturnedParam); 173 | osk_event = 0; 174 | osk_action = FAILED; 175 | break; 176 | 177 | case OSKDIALOG_FINISHED: 178 | oskUnloadAsync(&OutputReturnedParam); 179 | osk_event = 0; 180 | break; 181 | 182 | default: 183 | break; 184 | } 185 | 186 | } 187 | 188 | usleep(150000); // unnecessary but... 189 | 190 | if(OutputReturnedParam.res == OSK_OK && osk_action == SUCCESS) 191 | UTF16_to_UTF8((u16 *) OutWcharTex, (u8 *) str); 192 | else ret=FAILED; 193 | 194 | end: 195 | 196 | sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT0); 197 | sysMemContainerDestroy(container_mem); 198 | 199 | osk_level = 0; 200 | if(message) free(message); 201 | if(OutWcharTex) free(OutWcharTex); 202 | if(InWcharTex) free(InWcharTex); 203 | 204 | return ret; 205 | } -------------------------------------------------------------------------------- /include/storage.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SACD Ripper - http://code.google.com/p/sacd-ripper/ 3 | * 4 | * Copyright (c) 2010-2011 by respective authors. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | */ 21 | 22 | #ifndef __SYS_STORAGE_H__ 23 | #define __SYS_STORAGE_H__ 24 | 25 | #ifndef __lv2ppu__ 26 | #error you need the psl1ght/lv2 ppu compatible compiler! 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | //#include "io_buffer.h" 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | //static typedef int sys_io_buffer_t; 41 | //static typedef int sys_io_block_t; 42 | 43 | #define BD_DEVICE 0x0101000000000006ULL 44 | 45 | /* The generic packet command opcodes for CD/DVD Logical Units, 46 | * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ 47 | #define GPCMD_GET_CONFIGURATION 0x46 48 | #define GPCMD_GET_EVENT_STATUS_NOTIFICATION 0x4a 49 | #define GPCMD_MODE_SELECT_10 0x55 50 | #define GPCMD_MODE_SENSE_10 0x5a 51 | #define GPCMD_READ_CD 0xbe 52 | #define GPCMD_READ_DVD_STRUCTURE 0xad 53 | #define GPCMD_READ_TRACK_RZONE_INFO 0x52 54 | #define GPCMD_READ_TOC_PMA_ATIP 0x43 55 | #define GPCMD_REPORT_KEY 0xa4 56 | #define GPCMD_SEND_KEY 0xa3 57 | #define GPCMD_START_STOP_UNIT 0x1b 58 | 59 | #define LV2_STORAGE_SEND_ATAPI_COMMAND (1) 60 | 61 | struct lv2_atapi_cmnd_block 62 | { 63 | uint8_t pkt[32]; /* packet command block */ 64 | uint32_t pktlen; /* should be 12 for ATAPI 8020 */ 65 | uint32_t blocks; 66 | uint32_t block_size; 67 | uint32_t proto; /* transfer mode */ 68 | uint32_t in_out; /* transfer direction */ 69 | uint32_t unknown; 70 | } __attribute__((packed)); 71 | 72 | typedef struct 73 | { 74 | uint8_t name[7]; 75 | uint8_t unknown01; 76 | uint32_t unknown02; // random nr? 77 | uint32_t zero01; 78 | uint32_t unknown03; // 0x28? 79 | uint32_t unknown04; // 0xd000e990? 80 | uint8_t zero02[16]; 81 | uint64_t total_sectors; 82 | uint32_t sector_size; 83 | uint32_t unknown05; 84 | uint8_t writable; 85 | uint8_t unknown06[3]; 86 | uint32_t unknown07; 87 | } __attribute__((packed)) device_info_t; 88 | 89 | enum lv2_atapi_proto 90 | { 91 | ATAPI_NON_DATA_PROTO = 0, 92 | ATAPI_PIO_DATA_IN_PROTO = 1, 93 | ATAPI_PIO_DATA_OUT_PROTO = 2, 94 | ATAPI_DMA_PROTO = 3 95 | }; 96 | 97 | enum lv2_atapi_in_out 98 | { 99 | ATAPI_DIR_WRITE = 0, /* memory -> device */ 100 | ATAPI_DIR_READ = 1 /* device -> memory */ 101 | }; 102 | 103 | static inline void sys_storage_init_atapi_cmnd( 104 | struct lv2_atapi_cmnd_block *atapi_cmnd 105 | , uint32_t block_size 106 | , uint32_t proto 107 | , uint32_t type) 108 | { 109 | memset(atapi_cmnd, 0, sizeof(struct lv2_atapi_cmnd_block)); 110 | atapi_cmnd->pktlen = 12; 111 | atapi_cmnd->blocks = 1; 112 | atapi_cmnd->block_size = block_size; /* transfer size is block_size * blocks */ 113 | atapi_cmnd->proto = proto; 114 | atapi_cmnd->in_out = type; 115 | } 116 | 117 | static inline int sys_storage_send_atapi_command(uint32_t fd, struct lv2_atapi_cmnd_block *atapi_cmnd, uint8_t *buffer) 118 | { 119 | uint64_t tag; 120 | lv2syscall7(616 121 | , fd 122 | , LV2_STORAGE_SEND_ATAPI_COMMAND 123 | , (uint64_t) atapi_cmnd 124 | , sizeof(struct lv2_atapi_cmnd_block) 125 | , (uint64_t) buffer 126 | , atapi_cmnd->block_size 127 | , (uint64_t) &tag); 128 | 129 | return_to_user_prog(int); 130 | 131 | } 132 | 133 | 134 | static inline int sys_storage_send_device_cmd(uint32_t fd, uint32_t cmd, void * cmd_block, uint32_t cmd_size, void * data_buffer, uint32_t len_data_buffer) 135 | { 136 | lv2syscall6(604 137 | , fd 138 | , cmd 139 | , (uint64_t) cmd_block 140 | , cmd_size 141 | , (uint64_t) data_buffer 142 | , len_data_buffer); 143 | 144 | return_to_user_prog(int); 145 | } 146 | 147 | #if 0 148 | static inline int sys_storage_async_configure(uint32_t fd, sys_io_buffer_t io_buffer, sys_event_queue_t equeue_id, void * sys_event) 149 | { 150 | lv2syscall4(605 151 | , fd 152 | , io_buffer 153 | , equeue_id 154 | , (uint64_t) sys_event); 155 | 156 | return_to_user_prog(int); 157 | } 158 | 159 | 160 | static inline int sys_storage_async_send_device_command(uint32_t fd, uint64_t cmd, 161 | const void *cmdbuf, uint32_t cmdbuf_size, void *databuf, uint32_t databuf_size, uint64_t user_data) 162 | { 163 | lv2syscall7(619 164 | , fd 165 | , cmd 166 | , (uint64_t) cmdbuf 167 | , cmdbuf_size 168 | , (uint64_t) databuf 169 | , databuf_size 170 | , user_data); 171 | 172 | return_to_user_prog(int); 173 | } 174 | #endif 175 | 176 | static inline int sys_storage_get_device_info(uint64_t device, device_info_t *device_info) 177 | { 178 | lv2syscall2(609, device, (uint64_t) device_info); 179 | 180 | return_to_user_prog(int); 181 | } 182 | 183 | static inline int sys_storage_open(uint64_t id, int *fd) 184 | { 185 | lv2syscall4(600, id, 0, (uint64_t) fd, 0); 186 | 187 | return_to_user_prog(int); 188 | } 189 | 190 | static inline int sys_storage_close(int fd) 191 | { 192 | lv2syscall1(601, fd); 193 | 194 | return_to_user_prog(int); 195 | } 196 | 197 | static inline int sys_storage_read(int fd, uint32_t start_sector, uint32_t sectors, uint8_t *bounce_buf, uint32_t *sectors_read) 198 | { 199 | lv2syscall7(602, fd, 0, start_sector, sectors, (uint64_t) bounce_buf, (uint64_t) sectors_read, 0); 200 | 201 | return_to_user_prog(int); 202 | 203 | } 204 | 205 | static inline int sys_storage_write(int fd, uint32_t start_sector, uint32_t sectors, uint8_t *bounce_buf, uint32_t *sectors_read) 206 | { 207 | lv2syscall7(603, fd, 0, start_sector, sectors, (uint64_t) bounce_buf, (uint64_t) sectors_read, 0); 208 | 209 | return_to_user_prog(int); 210 | 211 | } 212 | 213 | /* 214 | static inline int sys_storage_async_read(int fd, uint32_t start_sector, uint32_t sectors, sys_io_block_t bounce_buf, uint64_t user_data) 215 | { 216 | lv2syscall7(606, fd, 0, start_sector, sectors, bounce_buf, user_data, 0); 217 | 218 | return_to_user_prog(int); 219 | 220 | } 221 | */ 222 | 223 | /** 224 | * In order to execute syscall 864 the access rights of LV2 need to be patched 225 | */ 226 | static inline int sys_storage_reset_bd(void) 227 | { 228 | lv2syscall2(864, 0x5004, 0x29); 229 | 230 | return_to_user_prog(int); 231 | 232 | } 233 | 234 | /** 235 | * In order to execute syscall 864 the access rights of LV2 need to be patched 236 | */ 237 | static inline int sys_storage_authenticate_bd(void) 238 | { 239 | lv2syscall2(864, 0x5004, 0x46); 240 | return_to_user_prog(int); 241 | } 242 | 243 | /** 244 | * In order to execute syscall 864 the access rights of LV2 need to be patched 245 | */ 246 | static inline int sys_storage_ctrl_bd(int _func) 247 | { 248 | uint64_t func[0x18/8]; 249 | func[0]= (uint64_t) _func; 250 | 251 | lv2syscall2(864, 0x5007, (uint64_t) &func[0]); 252 | 253 | return_to_user_prog(int); 254 | 255 | } 256 | 257 | 258 | #ifdef __cplusplus 259 | }; 260 | #endif 261 | #endif /* _SYS_STORAGE_H__ */ -------------------------------------------------------------------------------- /Makefile.pkg: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Simple File Manager 14 | APPID := PS3SFM001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | ICON0 := $(CURDIR)/ICON0.PNG 17 | #ICON1 := $(CURDIR)/ICON1.PAM 18 | #PIC1 := $(CURDIR)/PIC1.PNG 19 | SFOXML := $(CURDIR)/sfo.xml 20 | 21 | SCETOOL_FLAGS ?= --self-app-version=0001000000000000 --sce-type=SELF --compress-data=TRUE --self-add-shdrs=TRUE --skip-sections=FALSE --key-revision=1 \ 22 | --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-fw-version=0003004000000000 23 | 24 | include $(PSL1GHT)/ppu_rules 25 | 26 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 27 | SCETOOL_FLAGS += --self-ctrl-flags 4000000000000000000000000000000000000000000000000000000000000002 28 | SCETOOL_FLAGS += --self-cap-flags 00000000000000000000000000000000000000000000007B0000000100000000 29 | 30 | #--------------------------------------------------------------------------------- 31 | # TARGET is the name of the output 32 | # BUILD is the directory where object files & intermediate files will be placed 33 | # SOURCES is a list of directories containing source code 34 | # INCLUDES is a list of directories containing extra header files 35 | #--------------------------------------------------------------------------------- 36 | TARGET := sfm_ps3 37 | BUILD := build 38 | SOURCES := source 39 | DATA := data 40 | SHADERS := shaders 41 | INCLUDES := include ../include lib/include 42 | 43 | #--------------------------------------------------------------------------------- 44 | # any extra libraries we wish to link with the project 45 | #--------------------------------------------------------------------------------- 46 | LIBS := ../lib/libfatfs.a -lsysfs -lfont -lfreetype -lz -ltiny3d -lsimdmath -lgcm_sys -lnet -lio -lsysutil -lrt -llv2 -lsysmodule -lm 47 | 48 | #--------------------------------------------------------------------------------- 49 | # options for code generation 50 | #--------------------------------------------------------------------------------- 51 | 52 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) -DPS3_GEKKO $(DFLAGS) 53 | CXXFLAGS = $(CFLAGS) 54 | 55 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib 60 | #--------------------------------------------------------------------------------- 61 | LIBDIRS := 62 | 63 | #--------------------------------------------------------------------------------- 64 | # no real need to edit anything past this point unless you need to add additional 65 | # rules for different file extensions 66 | #--------------------------------------------------------------------------------- 67 | ifneq ($(BUILD),$(notdir $(CURDIR))) 68 | #--------------------------------------------------------------------------------- 69 | 70 | export OUTPUT := $(CURDIR)/$(TARGET) 71 | 72 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 74 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 75 | 76 | export DEPSDIR := $(CURDIR)/$(BUILD) 77 | 78 | export BUILDDIR := $(CURDIR)/$(BUILD) 79 | 80 | #--------------------------------------------------------------------------------- 81 | # automatically build a list of object files for our project 82 | #--------------------------------------------------------------------------------- 83 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 84 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 85 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 86 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 87 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 88 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 89 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 90 | 91 | VPOFILES := $(VCGFILES:.vcg=.vpo) 92 | FPOFILES := $(FCGFILES:.fcg=.fpo) 93 | 94 | #--------------------------------------------------------------------------------- 95 | # use CXX for linking C++ projects, CC for standard C 96 | #--------------------------------------------------------------------------------- 97 | ifeq ($(strip $(CPPFILES)),) 98 | export LD := $(CC) 99 | else 100 | export LD := $(CXX) 101 | endif 102 | 103 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 104 | $(addsuffix .o,$(VPOFILES)) \ 105 | $(addsuffix .o,$(FPOFILES)) \ 106 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 107 | $(sFILES:.s=.o) $(SFILES:.S=.o) 108 | 109 | #--------------------------------------------------------------------------------- 110 | # build a list of include paths 111 | #--------------------------------------------------------------------------------- 112 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 113 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 114 | $(LIBPSL1GHT_INC) \ 115 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \ 116 | -I$(PS3DEV)/portlibs/ppu/include/freetype2 117 | 118 | #--------------------------------------------------------------------------------- 119 | # build a list of library paths 120 | #--------------------------------------------------------------------------------- 121 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 122 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 123 | 124 | export OUTPUT := $(CURDIR)/$(TARGET) 125 | .PHONY: $(BUILD) clean 126 | 127 | 128 | #--------------------------------------------------------------------------------- 129 | $(BUILD): 130 | @[ -d $@ ] || mkdir -p $@ 131 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 132 | 133 | #--------------------------------------------------------------------------------- 134 | clean: 135 | @echo clean ... 136 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).self EBOOT.BIN 137 | 138 | #--------------------------------------------------------------------------------- 139 | run: 140 | ps3load $(OUTPUT).self 141 | 142 | #--------------------------------------------------------------------------------- 143 | pkg: $(BUILD) $(OUTPUT).pkg 144 | 145 | #--------------------------------------------------------------------------------- 146 | 147 | npdrm: $(BUILD) 148 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 149 | 150 | #--------------------------------------------------------------------------------- 151 | 152 | else 153 | 154 | DEPENDS := $(OFILES:.o=.d) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # main targets 158 | #--------------------------------------------------------------------------------- 159 | $(OUTPUT).self: $(OUTPUT).elf 160 | $(OUTPUT).elf: $(OFILES) 161 | 162 | #--------------------------------------------------------------------------------- 163 | # This rule links in binary data with the .bin extension 164 | #--------------------------------------------------------------------------------- 165 | %.bin.o : %.bin 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.vpo.o : %.vpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | #--------------------------------------------------------------------------------- 177 | %.fpo.o : %.fpo 178 | #--------------------------------------------------------------------------------- 179 | @echo $(notdir $<) 180 | @$(bin2o) 181 | 182 | -include $(DEPENDS) 183 | 184 | #--------------------------------------------------------------------------------- 185 | endif 186 | #--------------------------------------------------------------------------------- 187 | -------------------------------------------------------------------------------- /Makefile.lib: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Simple File Manager 14 | APPID := PS3SFM001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | ICON0 := $(CURDIR)/ICON0.PNG 17 | #ICON1 := $(CURDIR)/ICON1.PAM 18 | #PIC1 := $(CURDIR)/PIC1.PNG 19 | SFOXML := $(CURDIR)/sfo.xml 20 | 21 | SCETOOL_FLAGS ?= --self-app-version=0001000000000000 --sce-type=SELF --compress-data=TRUE --self-add-shdrs=TRUE --skip-sections=FALSE --key-revision=1 \ 22 | --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-fw-version=0003004000000000 23 | 24 | include $(PSL1GHT)/ppu_rules 25 | 26 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 27 | SCETOOL_FLAGS += --self-ctrl-flags 4000000000000000000000000000000000000000000000000000000000000002 28 | SCETOOL_FLAGS += --self-cap-flags 00000000000000000000000000000000000000000000007B0000000100000000 29 | 30 | #--------------------------------------------------------------------------------- 31 | # TARGET is the name of the output 32 | # BUILD is the directory where object files & intermediate files will be placed 33 | # SOURCES is a list of directories containing source code 34 | # INCLUDES is a list of directories containing extra header files 35 | #--------------------------------------------------------------------------------- 36 | TARGET := libsfm_ps3 37 | BUILD := build 38 | SOURCES := source 39 | DATA := data 40 | SHADERS := shaders 41 | INCLUDES := include ../include lib/include 42 | 43 | #--------------------------------------------------------------------------------- 44 | # any extra libraries we wish to link with the project 45 | #--------------------------------------------------------------------------------- 46 | LIBS := ../lib/libfatfs.a -lsysfs -lfont -lfreetype -lz -ltiny3d -lsimdmath -lgcm_sys -lnet -lio -lsysutil -lrt -llv2 -lsysmodule -lm 47 | 48 | #--------------------------------------------------------------------------------- 49 | # options for code generation 50 | #--------------------------------------------------------------------------------- 51 | 52 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) -DPS3_GEKKO $(DFLAGS) -DLIBBUILD 53 | CXXFLAGS = $(CFLAGS) 54 | 55 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 56 | 57 | #--------------------------------------------------------------------------------- 58 | # list of directories containing libraries, this must be the top level containing 59 | # include and lib 60 | #--------------------------------------------------------------------------------- 61 | LIBDIRS := 62 | 63 | #--------------------------------------------------------------------------------- 64 | # no real need to edit anything past this point unless you need to add additional 65 | # rules for different file extensions 66 | #--------------------------------------------------------------------------------- 67 | ifneq ($(BUILD),$(notdir $(CURDIR))) 68 | #--------------------------------------------------------------------------------- 69 | 70 | export OUTPUT := $(CURDIR)/$(TARGET) 71 | 72 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 73 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 74 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 75 | 76 | export DEPSDIR := $(CURDIR)/$(BUILD) 77 | 78 | export BUILDDIR := $(CURDIR)/$(BUILD) 79 | 80 | #--------------------------------------------------------------------------------- 81 | # automatically build a list of object files for our project 82 | #--------------------------------------------------------------------------------- 83 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 84 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 85 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 86 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 87 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 88 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 89 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 90 | 91 | VPOFILES := $(VCGFILES:.vcg=.vpo) 92 | FPOFILES := $(FCGFILES:.fcg=.fpo) 93 | 94 | #--------------------------------------------------------------------------------- 95 | # use CXX for linking C++ projects, CC for standard C 96 | #--------------------------------------------------------------------------------- 97 | ifeq ($(strip $(CPPFILES)),) 98 | export LD := $(CC) 99 | else 100 | export LD := $(CXX) 101 | endif 102 | 103 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 104 | $(addsuffix .o,$(VPOFILES)) \ 105 | $(addsuffix .o,$(FPOFILES)) \ 106 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 107 | $(sFILES:.s=.o) $(SFILES:.S=.o) 108 | 109 | #--------------------------------------------------------------------------------- 110 | # build a list of include paths 111 | #--------------------------------------------------------------------------------- 112 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 113 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 114 | $(LIBPSL1GHT_INC) \ 115 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \ 116 | -I$(PS3DEV)/portlibs/ppu/include/freetype2 117 | 118 | #--------------------------------------------------------------------------------- 119 | # build a list of library paths 120 | #--------------------------------------------------------------------------------- 121 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 122 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 123 | 124 | export OUTPUT := $(CURDIR)/$(TARGET) 125 | .PHONY: $(BUILD) clean 126 | 127 | 128 | #--------------------------------------------------------------------------------- 129 | $(BUILD): 130 | @[ -d $@ ] || mkdir -p $@ 131 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 132 | 133 | #--------------------------------------------------------------------------------- 134 | clean: 135 | @echo clean ... 136 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).self EBOOT.BIN 137 | 138 | #--------------------------------------------------------------------------------- 139 | run: 140 | ps3load $(OUTPUT).self 141 | 142 | #--------------------------------------------------------------------------------- 143 | pkg: $(BUILD) $(OUTPUT).pkg 144 | 145 | #--------------------------------------------------------------------------------- 146 | 147 | npdrm: $(BUILD) 148 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 149 | 150 | #--------------------------------------------------------------------------------- 151 | 152 | else 153 | 154 | DEPENDS := $(OFILES:.o=.d) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # main targets 158 | #--------------------------------------------------------------------------------- 159 | $(OUTPUT).a: $(OFILES) 160 | $(OFILES): $(BINFILES) $(VCGFILES) $(VSAFILES) 161 | 162 | #--------------------------------------------------------------------------------- 163 | # This rule links in binary data with the .bin extension 164 | #--------------------------------------------------------------------------------- 165 | %.bin.o : %.bin 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.vpo.o : %.vpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | #--------------------------------------------------------------------------------- 177 | %.fpo.o : %.fpo 178 | #--------------------------------------------------------------------------------- 179 | @echo $(notdir $<) 180 | @$(bin2o) 181 | 182 | -include $(DEPENDS) 183 | 184 | #--------------------------------------------------------------------------------- 185 | endif 186 | #--------------------------------------------------------------------------------- 187 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Simple File Manager 14 | APPID := PS3SFM001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | ICON0 := $(CURDIR)/ICON0.PNG 17 | #ICON1 := $(CURDIR)/ICON1.PAM 18 | #PIC1 := $(CURDIR)/PIC1.PNG 19 | SFOXML := $(CURDIR)/sfo.xml 20 | 21 | SCETOOL_FLAGS ?= --self-app-version=0001000000000000 --sce-type=SELF --compress-data=TRUE --self-add-shdrs=TRUE --skip-sections=FALSE --key-revision=1 \ 22 | --self-auth-id=1010000001000003 --self-vendor-id=01000002 --self-fw-version=0003004000000000 23 | 24 | include $(PSL1GHT)/ppu_rules 25 | 26 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 27 | SCETOOL_FLAGS += --self-ctrl-flags 4000000000000000000000000000000000000000000000000000000000000002 28 | SCETOOL_FLAGS += --self-cap-flags 00000000000000000000000000000000000000000000007B0000000100000000 29 | 30 | #--------------------------------------------------------------------------------- 31 | # TARGET is the name of the output 32 | # BUILD is the directory where object files & intermediate files will be placed 33 | # SOURCES is a list of directories containing source code 34 | # INCLUDES is a list of directories containing extra header files 35 | #--------------------------------------------------------------------------------- 36 | TARGET := sfm_ps3 37 | BUILD := build 38 | SOURCES := source 39 | DATA := data 40 | SHADERS := shaders 41 | INCLUDES := include ../include lib/include 42 | 43 | #--------------------------------------------------------------------------------- 44 | # any extra libraries we wish to link with the project 45 | #--------------------------------------------------------------------------------- 46 | LIBS := ../lib/libfatfs.a ../lib/libntfs_ext.a -lsysfs -lfont -lfreetype \ 47 | -lz -ltiny3d -lsimdmath -lgcm_sys -lnet -lio -lsysutil -lrt -llv2 \ 48 | -lsysmodule -lm 49 | 50 | #--------------------------------------------------------------------------------- 51 | # options for code generation 52 | #--------------------------------------------------------------------------------- 53 | 54 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) -DPS3_GEKKO $(DFLAGS) 55 | CXXFLAGS = $(CFLAGS) 56 | 57 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 58 | 59 | #--------------------------------------------------------------------------------- 60 | # list of directories containing libraries, this must be the top level containing 61 | # include and lib 62 | #--------------------------------------------------------------------------------- 63 | LIBDIRS := 64 | 65 | #--------------------------------------------------------------------------------- 66 | # no real need to edit anything past this point unless you need to add additional 67 | # rules for different file extensions 68 | #--------------------------------------------------------------------------------- 69 | ifneq ($(BUILD),$(notdir $(CURDIR))) 70 | #--------------------------------------------------------------------------------- 71 | 72 | export OUTPUT := $(CURDIR)/$(TARGET) 73 | 74 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 75 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 76 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 77 | 78 | export DEPSDIR := $(CURDIR)/$(BUILD) 79 | 80 | export BUILDDIR := $(CURDIR)/$(BUILD) 81 | 82 | #--------------------------------------------------------------------------------- 83 | # automatically build a list of object files for our project 84 | #--------------------------------------------------------------------------------- 85 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 86 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 87 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 88 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 89 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 90 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 91 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 92 | 93 | VPOFILES := $(VCGFILES:.vcg=.vpo) 94 | FPOFILES := $(FCGFILES:.fcg=.fpo) 95 | 96 | #--------------------------------------------------------------------------------- 97 | # use CXX for linking C++ projects, CC for standard C 98 | #--------------------------------------------------------------------------------- 99 | ifeq ($(strip $(CPPFILES)),) 100 | export LD := $(CC) 101 | else 102 | export LD := $(CXX) 103 | endif 104 | 105 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 106 | $(addsuffix .o,$(VPOFILES)) \ 107 | $(addsuffix .o,$(FPOFILES)) \ 108 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 109 | $(sFILES:.s=.o) $(SFILES:.S=.o) 110 | 111 | #--------------------------------------------------------------------------------- 112 | # build a list of include paths 113 | #--------------------------------------------------------------------------------- 114 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 115 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 116 | $(LIBPSL1GHT_INC) \ 117 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \ 118 | -I$(PS3DEV)/portlibs/ppu/include/freetype2 119 | 120 | #--------------------------------------------------------------------------------- 121 | # build a list of library paths 122 | #--------------------------------------------------------------------------------- 123 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 124 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 125 | 126 | export OUTPUT := $(CURDIR)/$(TARGET) 127 | .PHONY: $(BUILD) clean 128 | 129 | 130 | #--------------------------------------------------------------------------------- 131 | $(BUILD): 132 | @[ -d $@ ] || mkdir -p $@ 133 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 134 | 135 | #--------------------------------------------------------------------------------- 136 | clean: 137 | @echo clean ... 138 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).self EBOOT.BIN 139 | 140 | #--------------------------------------------------------------------------------- 141 | run: 142 | ps3load $(OUTPUT).self 143 | 144 | #--------------------------------------------------------------------------------- 145 | pkg: $(BUILD) $(OUTPUT).pkg 146 | 147 | #--------------------------------------------------------------------------------- 148 | 149 | npdrm: $(BUILD) 150 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 151 | 152 | #--------------------------------------------------------------------------------- 153 | 154 | else 155 | 156 | DEPENDS := $(OFILES:.o=.d) 157 | 158 | #--------------------------------------------------------------------------------- 159 | # main targets 160 | #--------------------------------------------------------------------------------- 161 | $(OUTPUT).self: $(OUTPUT).elf 162 | $(OUTPUT).elf: $(OFILES) 163 | 164 | #--------------------------------------------------------------------------------- 165 | # This rule links in binary data with the .bin extension 166 | #--------------------------------------------------------------------------------- 167 | %.bin.o : %.bin 168 | #--------------------------------------------------------------------------------- 169 | @echo $(notdir $<) 170 | @$(bin2o) 171 | 172 | #--------------------------------------------------------------------------------- 173 | %.vpo.o : %.vpo 174 | #--------------------------------------------------------------------------------- 175 | @echo $(notdir $<) 176 | @$(bin2o) 177 | 178 | #--------------------------------------------------------------------------------- 179 | %.fpo.o : %.fpo 180 | #--------------------------------------------------------------------------------- 181 | @echo $(notdir $<) 182 | @$(bin2o) 183 | 184 | -include $(DEPENDS) 185 | 186 | #--------------------------------------------------------------------------------- 187 | endif 188 | #--------------------------------------------------------------------------------- 189 | -------------------------------------------------------------------------------- /source/msxfont.c: -------------------------------------------------------------------------------- 1 | /* 2 | _____ ___ ____ 3 | ____| | ____| PSX2 OpenSource Project 4 | | ___| |____ (C)2001, Gustavo Scotti (gustavo@scotti.com) 5 | ------------------------------------------------------------------------ 6 | font.c 7 | EE UGLY DEBUG ON SCREEN - FONT BASE 8 | This is mostly based on Duke's work 9 | */ 10 | 11 | 12 | unsigned char msx[]= 13 | "\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c" 14 | "\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00" 15 | "\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00" 16 | "\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00" 17 | "\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00" 18 | "\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70" 19 | "\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0" 20 | "\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00" 21 | "\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00" 22 | "\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10" 23 | "\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10" 24 | "\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00" 25 | "\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10" 26 | "\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00" 27 | "\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80" 28 | "\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00" 29 | "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00" 30 | "\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00" 31 | "\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00" 32 | "\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00" 33 | "\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00" 34 | "\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00" 35 | "\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00" 36 | "\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00" 37 | "\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00" 38 | "\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00" 39 | "\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00" 40 | "\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00" 41 | "\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00" 42 | "\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40" 43 | "\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00" 44 | "\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00" 45 | "\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00" 46 | "\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00" 47 | "\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00" 48 | "\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00" 49 | "\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00" 50 | "\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00" 51 | "\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00" 52 | "\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00" 53 | "\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00" 54 | "\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00" 55 | "\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00" 56 | "\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00" 57 | "\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00" 58 | "\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00" 59 | "\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00" 60 | "\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00" 61 | "\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00" 62 | "\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00" 63 | "\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00" 64 | "\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70" 65 | "\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00" 66 | "\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00" 67 | "\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00" 68 | "\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00" 69 | "\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08" 70 | "\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00" 71 | "\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00" 72 | "\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00" 73 | "\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70" 74 | "\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00" 75 | "\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00" 76 | "\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00" 77 | "\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00" 78 | "\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00" 79 | "\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00" 80 | "\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60" 81 | "\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00" 82 | "\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00" 83 | "\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00" 84 | "\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00" 85 | "\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00" 86 | "\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00" 87 | "\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00" 88 | "\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00" 89 | "\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00" 90 | "\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20" 91 | "\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00" 92 | "\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40" 93 | "\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00" 94 | "\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00" 95 | "\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00" 96 | "\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0" 97 | "\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00" 98 | "\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c" 99 | "\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00" 100 | "\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00" 101 | "\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00" 102 | "\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00" 103 | "\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00" 104 | "\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00" 105 | "\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20" 106 | "\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00" 107 | "\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00" 108 | "\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70" 109 | "\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f" 110 | "\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00" 111 | "\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00" 112 | "\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0" 113 | "\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03" 114 | "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88" 115 | "\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00" 116 | "\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00" 117 | "\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff" 118 | "\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00" 119 | "\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00" 120 | "\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc" 121 | "\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00" 122 | "\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff" 123 | "\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0" 124 | "\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00" 125 | "\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0" 126 | "\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00" 127 | "\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00" 128 | "\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00" 129 | "\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00" 130 | "\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20" 131 | "\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00" 132 | "\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00" 133 | "\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00" 134 | "\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00" 135 | "\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40" 136 | "\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00" 137 | "\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00" 138 | "\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00" 139 | "\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00" 140 | "\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00"; 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /include/ntfs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ntfs.h - Simple functionality for startup, mounting and unmounting of NTFS-based devices. 3 | * 4 | * Copyright (c) 2013 Estwald 5 | * Copyright (c) 2010 Dimok 6 | * Copyright (c) 2009 Rhys "Shareese" Koedijk 7 | * Copyright (c) 2006 Michael "Chishm" Chisholm 8 | * 9 | * This program/include file is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License as published 11 | * by the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program/include file is distributed in the hope that it will be 15 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software Foundation, 21 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef _LIBNTFS_H 25 | #define _LIBNTFS_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include // file flags 37 | #include 38 | 39 | #ifndef ATTRIBUTE_ALIGN 40 | # define ATTRIBUTE_ALIGN(v) __attribute__((aligned(v))) 41 | #endif 42 | #ifndef ATTRIBUTE_PACKED 43 | # define ATTRIBUTE_PACKED __attribute__((packed)) 44 | #endif 45 | 46 | // disc_io.h 47 | #define FEATURE_MEDIUM_CANREAD 0x00000001 48 | #define FEATURE_MEDIUM_CANWRITE 0x00000002 49 | #define FEATURE_PS3_SD 0x00000100 50 | #define FEATURE_PS3_USB 0x00000200 51 | #define FEATURE_PS3_BDVD 0x00000400 52 | 53 | typedef uint32_t sec_t; 54 | 55 | typedef bool (* FN_MEDIUM_STARTUP)(void) ; 56 | typedef bool (* FN_MEDIUM_ISINSERTED)(void) ; 57 | typedef bool (* FN_MEDIUM_READSECTORS)(sec_t sector, sec_t numSectors, void* buffer) ; 58 | typedef bool (* FN_MEDIUM_WRITESECTORS)(sec_t sector, sec_t numSectors, const void* buffer) ; 59 | typedef bool (* FN_MEDIUM_CLEARSTATUS)(void) ; 60 | typedef bool (* FN_MEDIUM_SHUTDOWN)(void) ; 61 | 62 | struct DISC_INTERFACE_STRUCT { 63 | unsigned long ioType ; 64 | unsigned long features ; 65 | FN_MEDIUM_STARTUP startup ; 66 | FN_MEDIUM_ISINSERTED isInserted ; 67 | FN_MEDIUM_READSECTORS readSectors ; 68 | FN_MEDIUM_WRITESECTORS writeSectors ; 69 | FN_MEDIUM_CLEARSTATUS clearStatus ; 70 | FN_MEDIUM_SHUTDOWN shutdown ; 71 | } ; 72 | 73 | typedef struct DISC_INTERFACE_STRUCT DISC_INTERFACE; 74 | 75 | 76 | /* NTFS errno values */ 77 | #define ENOPART 3000 /* No partition was found */ 78 | #define EINVALPART 3001 /* Specified partition is invalid or not supported */ 79 | #define EDIRTY 3002 /* Volume is dirty and NTFS_RECOVER was not specified during mount */ 80 | #define EHIBERNATED 3003 /* Volume is hibernated and NTFS_IGNORE_HIBERFILE was not specified during mount */ 81 | 82 | /* NTFS cache options */ 83 | #define CACHE_DEFAULT_PAGE_COUNT 128 /* The default number of pages in the cache */ 84 | #define CACHE_DEFAULT_PAGE_SIZE 8 /* The default number of sectors per cache page */ 85 | 86 | /* NTFS mount flags */ 87 | #define NTFS_DEFAULT 0x00000000 /* Standard mount, expects a clean, non-hibernated volume */ 88 | #define NTFS_SHOW_HIDDEN_FILES 0x00000001 /* Display hidden files when enumerating directories */ 89 | #define NTFS_SHOW_SYSTEM_FILES 0x00000002 /* Display system files when enumerating directories */ 90 | #define NTFS_UPDATE_ACCESS_TIMES 0x00000004 /* Update file and directory access times */ 91 | #define NTFS_RECOVER 0x00000008 /* Reset $LogFile if dirty (i.e. from unclean disconnect) */ 92 | #define NTFS_IGNORE_HIBERFILE 0x00000010 /* Mount even if volume is hibernated */ 93 | #define NTFS_READ_ONLY 0x00000020 /* Mount in read only mode */ 94 | #define NTFS_IGNORE_CASE 0x00000040 /* Ignore case sensitivity. Everything must be and will be provided in lowercase. */ 95 | #define NTFS_SU NTFS_SHOW_HIDDEN_FILES | NTFS_SHOW_SYSTEM_FILES 96 | #define NTFS_FORCE NTFS_RECOVER | NTFS_IGNORE_HIBERFILE 97 | 98 | /** 99 | * ntfs_md - NTFS mount descriptor 100 | */ 101 | typedef struct _ntfs_md { 102 | char name[32]; /* Mount name (can be accessed as "name:/") */ 103 | const DISC_INTERFACE *interface; /* Block device containing the mounted partition */ 104 | sec_t startSector; /* Local block address to first sector of partition */ 105 | } ntfs_md; 106 | 107 | /** 108 | * Find all NTFS partitions on a block device. 109 | * 110 | * @param INTERFACE The block device to search 111 | * @param PARTITIONS (out) A pointer to receive the array of partition start sectors 112 | * 113 | * @return The number of entries in PARTITIONS or -1 if an error occurred (see errno) 114 | * @note The caller is responsible for freeing PARTITIONS when finished with it 115 | */ 116 | extern int ntfsFindPartitions (const DISC_INTERFACE *interface, sec_t **partitions); 117 | 118 | /** 119 | * Mount all NTFS partitions on all inserted block devices. 120 | * 121 | * @param MOUNTS (out) A pointer to receive the array of mount descriptors 122 | * @param FLAGS Additional mounting flags. (see above) 123 | * 124 | * @return The number of entries in MOUNTS or -1 if an error occurred (see errno) 125 | * @note The caller is responsible for freeing MOUNTS when finished with it 126 | * @note All device caches are setup using default values (see above) 127 | */ 128 | extern int ntfsMountAll (ntfs_md **mounts, u32 flags); 129 | 130 | /** 131 | * Mount all NTFS partitions on a block devices. 132 | * 133 | * @param INTERFACE The block device to mount. 134 | * @param MOUNTS (out) A pointer to receive the array of mount descriptors 135 | * @param FLAGS Additional mounting flags. (see above) 136 | * 137 | * @return The number of entries in MOUNTS or -1 if an error occurred (see errno) 138 | * @note The caller is responsible for freeing MOUNTS when finished with it 139 | * @note The device cache is setup using default values (see above) 140 | */ 141 | extern int ntfsMountDevice (const DISC_INTERFACE* interface, ntfs_md **mounts, u32 flags); 142 | 143 | /** 144 | * Mount a NTFS partition from a specific sector on a block device. 145 | * 146 | * @param NAME The name to mount the device under (can then be accessed as "NAME:/") 147 | * @param INTERFACE The block device to mount 148 | * @param STARTSECTOR The sector the partition begins at (see @ntfsFindPartitions) 149 | * @param CACHEPAGECOUNT The total number of pages in the device cache 150 | * @param CACHEPAGESIZE The number of sectors per cache page 151 | * @param FLAGS Additional mounting flags (see above) 152 | * 153 | * @return True if mount was successful, false if no partition was found or an error occurred (see errno) 154 | * @note ntfsFindPartitions should be used first to locate the partitions start sector 155 | */ 156 | extern bool ntfsMount (const char *name, const DISC_INTERFACE *interface, sec_t startSector, u32 cachePageCount, u32 cachePageSize, u32 flags); 157 | 158 | /** 159 | * Unmount a NTFS partition. 160 | * 161 | * @param NAME The name of mount used in ntfsMountSimple() and ntfsMount() 162 | * @param FORCE If true unmount even if the device is busy (may lead to data lose) 163 | */ 164 | extern void ntfsUnmount (const char *name, bool force); 165 | 166 | /** 167 | * Get the volume name of a mounted NTFS partition. 168 | * 169 | * @param NAME The name of mount (see @ntfsMountAll, @ntfsMountDevice, and @ntfsMount) 170 | * 171 | * @return The volumes name if successful or NULL if an error occurred (see errno) 172 | */ 173 | extern const char *ntfsGetVolumeName (const char *name); 174 | 175 | /** 176 | * Set the volume name of a mounted NTFS partition. 177 | * 178 | * @param NAME The name of mount (see @ntfsMountAll, @ntfsMountDevice, and @ntfsMount) 179 | * @param VOLUMENAME The new volume name 180 | * 181 | * @return True if mount was successful, false if an error occurred (see errno) 182 | * @note The mount must be write-enabled else this will fail 183 | */ 184 | extern bool ntfsSetVolumeName (const char *name, const char *volumeName); 185 | 186 | // file operations 187 | 188 | int ps3ntfs_open(const char *path, int flags, int mode); 189 | int ps3ntfs_close(int fd); 190 | int ps3ntfs_write(int fd, const char *ptr, size_t len); 191 | int ps3ntfs_read(int fd, char *ptr, size_t len); 192 | off_t ps3ntfs_seek(int fd, off_t pos, int dir); 193 | s64 ps3ntfs_seek64(int fd, s64 pos, int dir); 194 | int ps3ntfs_fstat(int fd, struct stat *st); 195 | int ps3ntfs_stat(const char *file, struct stat *st); 196 | int ps3ntfs_link(const char *existing, const char *newLink); 197 | int ps3ntfs_unlink(const char *name); 198 | 199 | int ps3ntfs_chdir(const char *name); 200 | int ps3ntfs_rename(const char *oldName, const char *newName); 201 | int ps3ntfs_mkdir(const char *path, int mode); 202 | int ps3ntfs_file_to_sectors(const char *path, uint32_t *sec_out, uint32_t *size_out, int max, int phys); 203 | int ps3ntfs_get_fd_from_FILE(FILE *fp); 204 | 205 | typedef struct { 206 | int device; 207 | void *dirStruct; 208 | } DIR_ITER; 209 | 210 | DIR_ITER* ps3ntfs_diropen(const char *path); 211 | int ps3ntfs_dirreset(DIR_ITER *dirState); 212 | int ps3ntfs_dirnext(DIR_ITER *dirState, char *filename, struct stat *filestat); 213 | int ps3ntfs_dirclose(DIR_ITER *dirState); 214 | 215 | // map file functions to libc open, fopen, ... 216 | void NTFS_init_system_io(void); 217 | void NTFS_deinit_system_io(void); 218 | 219 | 220 | #ifndef _SYS_STATVFS_H 221 | #define _SYS_STATVFS_H 222 | 223 | #define ST_RDONLY 0x0001 224 | #define ST_NOSUID 0x0002 225 | 226 | typedef __uint32_t fsblkcnt_t; 227 | typedef __uint32_t fsfilcnt_t; 228 | 229 | struct statvfs { 230 | unsigned long f_bsize; 231 | unsigned long f_frsize; 232 | fsblkcnt_t f_blocks; 233 | fsblkcnt_t f_bfree; 234 | fsblkcnt_t f_bavail; 235 | fsfilcnt_t f_files; 236 | fsfilcnt_t f_ffree; 237 | fsfilcnt_t f_favail; 238 | unsigned long f_fsid; 239 | unsigned long f_flag; 240 | unsigned long f_namemax; 241 | }; 242 | 243 | #endif 244 | 245 | int ps3ntfs_statvfs(const char *path, struct statvfs *buf); 246 | int ps3ntfs_ftruncate(int fd, off_t len); 247 | int ps3ntfs_fsync(int fd); 248 | int ps3ntfs_errno(void); 249 | 250 | bool PS3_NTFS_IsInserted(int fd); // fd from 0 to 7 (usb000... usb007) 251 | bool PS3_NTFS_Shutdown(int fd); // fd from 0 to 7 (usb000... usb007) 252 | 253 | extern const DISC_INTERFACE __io_ntfs_usb000; 254 | extern const DISC_INTERFACE __io_ntfs_usb001; 255 | extern const DISC_INTERFACE __io_ntfs_usb002; 256 | extern const DISC_INTERFACE __io_ntfs_usb003; 257 | extern const DISC_INTERFACE __io_ntfs_usb004; 258 | extern const DISC_INTERFACE __io_ntfs_usb005; 259 | extern const DISC_INTERFACE __io_ntfs_usb006; 260 | extern const DISC_INTERFACE __io_ntfs_usb007; 261 | 262 | 263 | #ifdef __cplusplus 264 | } 265 | #endif 266 | 267 | #endif /* _LIBNTFS_H */ 268 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define this to 1 if you want to enable support of encrypted files in 4 | libntfs and utilities. */ 5 | #undef ENABLE_CRYPTO 6 | 7 | /* Define to 1 if debug should be enabled */ 8 | #undef ENABLE_DEBUG 9 | 10 | /* Define to 1 if the nfconv patch should be enabled */ 11 | #undef ENABLE_NFCONV 12 | 13 | /* Define this to 1 if you want to enable generation of DCE compliant UUIDs. 14 | */ 15 | #undef ENABLE_UUID 16 | 17 | /* Define to 1 if using internal fuse */ 18 | #undef FUSE_INTERNAL 19 | 20 | /* Define to 1 if you have the `atexit' function. */ 21 | #define HAVE_ATEXIT 1 22 | 23 | #define HAVE_NETINET_IN_H 1 24 | 25 | /* Define to 1 if you have the `basename' function. */ 26 | #undef HAVE_BASENAME 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #undef HAVE_BYTESWAP_H 30 | 31 | /* Define to 1 if you have the `clock_gettime' function. */ 32 | #undef HAVE_CLOCK_GETTIME 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_CTYPE_H 1 36 | 37 | /* Define to 1 if you have the `daemon' function. */ 38 | #undef HAVE_DAEMON 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #undef HAVE_DLFCN_H 42 | 43 | /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ 44 | #undef HAVE_DOPRNT 45 | 46 | /* Define to 1 if you have the `dup2' function. */ 47 | #undef HAVE_DUP2 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #undef HAVE_ENDIAN_H 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_ERRNO_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_FCNTL_H 1 57 | 58 | /* Define to 1 if you have the `fdatasync' function. */ 59 | #undef HAVE_FDATASYNC 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #undef HAVE_FEATURES_H 63 | 64 | /* Define to 1 if you have the `ffs' function. */ 65 | #define HAVE_FFS 1 66 | 67 | /* Define to 1 if you have the `fork' function. */ 68 | #define HAVE_FORK 1 69 | 70 | /* Define to 1 if you have the `getmntent' function. */ 71 | #undef HAVE_GETMNTENT 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_GETOPT_H 1 75 | 76 | /* Define to 1 if you have the `getopt_long' function. */ 77 | #define HAVE_GETOPT_LONG 1 78 | 79 | /* Define to 1 if you have the `gettimeofday' function. */ 80 | #undef HAVE_GETTIMEOFDAY 81 | 82 | /* Define to 1 if you have the `hasmntopt' function. */ 83 | #undef HAVE_HASMNTOPT 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #define HAVE_INTTYPES_H 1 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_LIBGEN_H 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #undef HAVE_LIBINTL_H 93 | 94 | /* Define to 1 if you have the header file. */ 95 | #define HAVE_LIMITS_H 1 96 | 97 | /* Define to 1 if you have the header file. */ 98 | #undef HAVE_LINUX_FD_H 99 | 100 | /* Define to 1 if you have the header file. */ 101 | #undef HAVE_LINUX_HDREG_H 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #undef HAVE_LINUX_MAJOR_H 105 | 106 | /* Define to 1 if you have the header file. */ 107 | #define HAVE_LOCALE_H 1 108 | 109 | /* Define to 1 if you have the header file. */ 110 | #define HAVE_MACHINE_ENDIAN_H 1 111 | 112 | /* Define to 1 if you have the header file. */ 113 | #define HAVE_MALLOC_H 1 114 | 115 | /* Define to 1 if mbrtowc and mbstate_t are properly declared. */ 116 | #define HAVE_MBRTOWC 1 117 | 118 | /* Define to 1 if you have the `mbsinit' function. */ 119 | #define HAVE_MBSINIT 1 120 | 121 | /* Define to 1 if you have the `memcpy' function. */ 122 | #define HAVE_MEMCPY 1 123 | 124 | /* Define to 1 if you have the `memmove' function. */ 125 | #define HAVE_MEMMOVE 1 126 | 127 | /* Define to 1 if you have the header file. */ 128 | #undef HAVE_MEMORY_H 129 | 130 | /* Define to 1 if you have the `memset' function. */ 131 | #define HAVE_MEMSET 1 132 | 133 | /* Define to 1 if you have the header file. */ 134 | #undef HAVE_MNTENT_H 135 | 136 | /* Define to 1 if you have the header file. */ 137 | #define HAVE_PWD_H 1 138 | 139 | /* Define to 1 if you have the `random' function. */ 140 | #undef HAVE_RANDOM 141 | 142 | /* Define to 1 if you have the `realpath' function. */ 143 | #undef HAVE_REALPATH 144 | 145 | /* Define to 1 if you have the `regcomp' function. */ 146 | #undef HAVE_REGCOMP 147 | 148 | /* Define to 1 if you have the `setlocale' function. */ 149 | #define HAVE_SETLOCALE 1 150 | 151 | /* Define to 1 if you have the `setxattr' function. */ 152 | #undef HAVE_SETXATTR 153 | 154 | /* Define to 1 if you have the `snprintf' function. */ 155 | #define HAVE_SNPRINTF 1 156 | 157 | /* Define to 1 if `stat' has the bug that it succeeds when given the 158 | zero-length file name argument. */ 159 | #undef HAVE_STAT_EMPTY_STRING_BUG 160 | 161 | /* Define to 1 if you have the header file. */ 162 | #define HAVE_STDARG_H 1 163 | 164 | /* Define to 1 if stdbool.h conforms to C99. */ 165 | #define HAVE_STDBOOL_H 1 166 | 167 | /* Define to 1 if you have the header file. */ 168 | #define HAVE_STDDEF_H 1 169 | 170 | /* Define to 1 if you have the header file. */ 171 | #define HAVE_STDINT_H 1 172 | 173 | /* Define to 1 if you have the header file. */ 174 | #define HAVE_STDIO_H 1 175 | 176 | /* Define to 1 if you have the header file. */ 177 | #define HAVE_STDLIB_H 1 178 | 179 | /* Define to 1 if you have the `strcasecmp' function. */ 180 | #define HAVE_STRCASECMP 1 181 | 182 | /* Define to 1 if you have the `strchr' function. */ 183 | #define HAVE_STRCHR 1 184 | 185 | /* Define to 1 if you have the `strdup' function. */ 186 | #define HAVE_STRDUP 1 187 | 188 | /* Define to 1 if you have the `strerror' function. */ 189 | #define HAVE_STRERROR 1 190 | 191 | /* Define to 1 if you have the `strftime' function. */ 192 | #define HAVE_STRFTIME 1 193 | 194 | /* Define to 1 if you have the header file. */ 195 | #undef HAVE_STRINGS_H 196 | 197 | /* Define to 1 if you have the header file. */ 198 | #define HAVE_STRING_H 1 199 | 200 | /* Define to 1 if you have the `strnlen' function. */ 201 | #define HAVE_STRNLEN 1 202 | 203 | /* Define to 1 if you have the `strsep' function. */ 204 | #define HAVE_STRSEP 1 205 | 206 | /* Define to 1 if you have the `strtol' function. */ 207 | #define HAVE_STRTOL 1 208 | 209 | /* Define to 1 if you have the `strtoul' function. */ 210 | #define HAVE_STRTOUL 1 211 | 212 | /* Define to 1 if `st_atim' is member of `struct stat'. */ 213 | #undef HAVE_STRUCT_STAT_ST_ATIM 214 | 215 | /* Define to 1 if `st_atimensec' is member of `struct stat'. */ 216 | #undef HAVE_STRUCT_STAT_ST_ATIMENSEC 217 | 218 | /* Define to 1 if `st_atimespec' is member of `struct stat'. */ 219 | #undef HAVE_STRUCT_STAT_ST_ATIMESPEC 220 | 221 | /* Define to 1 if `st_blocks' is member of `struct stat'. */ 222 | #undef HAVE_STRUCT_STAT_ST_BLOCKS 223 | 224 | /* Define to 1 if `st_rdev' is member of `struct stat'. */ 225 | #undef HAVE_STRUCT_STAT_ST_RDEV 226 | 227 | /* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use 228 | `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ 229 | #undef HAVE_ST_BLOCKS 230 | 231 | /* Define to 1 if you have the `sysconf' function. */ 232 | #define HAVE_SYSCONF 1 233 | 234 | /* Define to 1 if you have the header file. */ 235 | #undef HAVE_SYSLOG_H 236 | 237 | /* Define to 1 if you have the header file. */ 238 | #undef HAVE_SYS_BYTEORDER_H 239 | 240 | /* Define to 1 if you have the header file. */ 241 | #undef HAVE_SYS_DISK_H 242 | 243 | /* Define to 1 if you have the header file. */ 244 | #undef HAVE_SYS_ENDIAN_H 245 | 246 | /* Define to 1 if you have the header file. */ 247 | #undef HAVE_SYS_IOCTL_H 248 | 249 | /* Define to 1 if you have the header file. */ 250 | #undef HAVE_SYS_MKDEV_H 251 | 252 | /* Define to 1 if you have the header file. */ 253 | #undef HAVE_SYS_MOUNT_H 254 | 255 | /* Define to 1 if you have the header file. */ 256 | #define HAVE_SYS_PARAM_H 1 257 | 258 | /* Define to 1 if you have the header file. */ 259 | #define HAVE_SYS_STATVFS_H 1 260 | 261 | /* Define to 1 if you have the header file. */ 262 | #define HAVE_SYS_STAT_H 1 263 | 264 | /* Define to 1 if you have the header file. */ 265 | #undef HAVE_SYS_SYSMACROS_H 266 | 267 | /* Define to 1 if you have the header file. */ 268 | #define HAVE_SYS_TYPES_H 1 269 | 270 | /* Define to 1 if you have the header file. */ 271 | #undef HAVE_SYS_VFS_H 272 | 273 | /* Define to 1 if you have the header file. */ 274 | #define HAVE_TIME_H 1 275 | 276 | /* Define to 1 if you have the header file. */ 277 | #define HAVE_UNISTD_H 1 278 | 279 | /* Define to 1 if you have the `utime' function. */ 280 | #undef HAVE_UTIME 281 | 282 | /* Define to 1 if you have the `utimensat' function. */ 283 | #undef HAVE_UTIMENSAT 284 | 285 | /* Define to 1 if you have the header file. */ 286 | #define HAVE_UTIME_H 1 287 | 288 | /* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */ 289 | #undef HAVE_UTIME_NULL 290 | 291 | /* Define to 1 if you have the `vprintf' function. */ 292 | #define HAVE_VPRINTF 1 293 | 294 | /* Define to 1 if you have the header file. */ 295 | #define HAVE_WCHAR_H 1 296 | 297 | /* Define to 1 if you have the header file. */ 298 | #undef HAVE_WINDOWS_H 299 | 300 | /* Define to 1 if the system has the type `_Bool'. */ 301 | #undef HAVE__BOOL 302 | 303 | /* Don't update /etc/mtab */ 304 | #undef IGNORE_MTAB 305 | 306 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing 307 | slash. */ 308 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK 309 | 310 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 311 | #undef NO_MINUS_C_MINUS_O 312 | 313 | /* Don't use default IO ops */ 314 | #undef NO_NTFS_DEVICE_DEFAULT_IO_OPS 315 | 316 | /* Name of package */ 317 | #define PACKAGE "ntfs-3g" 318 | 319 | /* Define to the address where bug reports for this package should be sent. */ 320 | #define PACKAGE_BUGREPORT "ntfs-3g-devel@lists.sf.net" 321 | 322 | /* Define to the full name of this package. */ 323 | #define PACKAGE_NAME "ntfs-3g" 324 | 325 | /* Define to the full name and version of this package. */ 326 | #define PACKAGE_STRING "ntfs-3g 2013.1.13" 327 | 328 | /* Define to the one symbol short name of this package. */ 329 | #define PACKAGE_TARNAME "ntfs-3g" 330 | 331 | /* Define to the version of this package. */ 332 | #define PACKAGE_VERSION "2013.1.13" 333 | 334 | /* POSIX ACL support */ 335 | #undef POSIXACLS 336 | 337 | /* Define to 1 if you have the ANSI C header files. */ 338 | #define STDC_HEADERS 1 339 | 340 | /* Version number of package */ 341 | #define VERSION "2013.1.13" 342 | 343 | /* Define to 1 if this is a Windows OS */ 344 | #undef WINDOWS 345 | 346 | /* Define to 1 if your processor stores words with the most significant byte 347 | first (like Motorola and SPARC, unlike Intel and VAX). */ 348 | #define WORDS_BIGENDIAN 1 349 | 350 | /* Define to 1 if your processor stores words with the least significant byte 351 | first (like Intel and VAX, unlike Motorola and SPARC). */ 352 | #undef WORDS_LITTLEENDIAN 353 | 354 | /* system extended attributes mappings */ 355 | #undef XATTR_MAPPINGS 356 | 357 | /* Number of bits in a file offset, on hosts where this is settable. */ 358 | #define _FILE_OFFSET_BITS 64 359 | 360 | /* Enable GNU extensions on systems that have them. */ 361 | #ifndef _GNU_SOURCE 362 | # undef _GNU_SOURCE 363 | #endif 364 | 365 | /* Define for large files, on AIX-style hosts. */ 366 | #define _LARGE_FILES 1 367 | 368 | /* Required define if using POSIX threads */ 369 | #undef _REENTRANT 370 | 371 | /* Define to empty if `const' does not conform to ANSI C. */ 372 | #undef const 373 | 374 | /* Define to `__inline__' or `__inline' if that's what the C compiler 375 | calls it, or to nothing if 'inline' is not supported under any name. */ 376 | #ifndef __cplusplus 377 | #define inline __inline__ 378 | #endif 379 | 380 | /* Define to `long int' if does not define. */ 381 | #undef off_t 382 | 383 | /* Define to `unsigned int' if does not define. */ 384 | #undef size_t 385 | 386 | /* Define to 1 if you have the header file. */ 387 | #define HAVE_MATH_H 1 388 | -------------------------------------------------------------------------------- /lib/include/ffconf.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------/ 2 | / FatFs Functional Configurations 3 | /---------------------------------------------------------------------------*/ 4 | 5 | #define FFCONF_DEF 86606 /* Revision ID */ 6 | 7 | /*---------------------------------------------------------------------------/ 8 | / Function Configurations 9 | /---------------------------------------------------------------------------*/ 10 | 11 | #define FF_FS_READONLY 0 12 | /* This option switches read-only configuration. (0:Read/Write or 1:Read-only) 13 | / Read-only configuration removes writing API functions, f_write(), f_sync(), 14 | / f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree() 15 | / and optional writing functions as well. */ 16 | 17 | 18 | #define FF_FS_MINIMIZE 0 19 | /* This option defines minimization level to remove some basic API functions. 20 | / 21 | / 0: Basic functions are fully enabled. 22 | / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename() 23 | / are removed. 24 | / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1. 25 | / 3: f_lseek() function is removed in addition to 2. */ 26 | 27 | 28 | #define FF_USE_STRFUNC 2 29 | /* This option switches string functions, f_gets(), f_putc(), f_puts() and f_printf(). 30 | / 31 | / 0: Disable string functions. 32 | / 1: Enable without LF-CRLF conversion. 33 | / 2: Enable with LF-CRLF conversion. */ 34 | 35 | 36 | #define FF_USE_FIND 1 37 | /* This option switches filtered directory read functions, f_findfirst() and 38 | / f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ 39 | 40 | 41 | #define FF_USE_MKFS 1 42 | /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */ 43 | 44 | 45 | #define FF_USE_FASTSEEK 1 46 | /* This option switches fast seek function. (0:Disable or 1:Enable) */ 47 | 48 | 49 | #define FF_USE_EXPAND 1 50 | /* This option switches f_expand function. (0:Disable or 1:Enable) */ 51 | 52 | 53 | #define FF_USE_CHMOD 1 54 | /* This option switches attribute manipulation functions, f_chmod() and f_utime(). 55 | / (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */ 56 | 57 | 58 | #define FF_USE_LABEL 1 59 | /* This option switches volume label functions, f_getlabel() and f_setlabel(). 60 | / (0:Disable or 1:Enable) */ 61 | 62 | 63 | #define FF_USE_FORWARD 1 64 | /* This option switches f_forward() function. (0:Disable or 1:Enable) */ 65 | 66 | 67 | /*---------------------------------------------------------------------------/ 68 | / Locale and Namespace Configurations 69 | /---------------------------------------------------------------------------*/ 70 | 71 | #define FF_CODE_PAGE 0 72 | /* This option specifies the OEM code page to be used on the target system. 73 | / Incorrect code page setting can cause a file open failure. 74 | / 75 | / 437 - U.S. 76 | / 720 - Arabic 77 | / 737 - Greek 78 | / 771 - KBL 79 | / 775 - Baltic 80 | / 850 - Latin 1 81 | / 852 - Latin 2 82 | / 855 - Cyrillic 83 | / 857 - Turkish 84 | / 860 - Portuguese 85 | / 861 - Icelandic 86 | / 862 - Hebrew 87 | / 863 - Canadian French 88 | / 864 - Arabic 89 | / 865 - Nordic 90 | / 866 - Russian 91 | / 869 - Greek 2 92 | / 932 - Japanese (DBCS) 93 | / 936 - Simplified Chinese (DBCS) 94 | / 949 - Korean (DBCS) 95 | / 950 - Traditional Chinese (DBCS) 96 | / 0 - Include all code pages above and configured by f_setcp() 97 | */ 98 | 99 | 100 | #define FF_USE_LFN 2 101 | #define FF_MAX_LFN 255 102 | /* The FF_USE_LFN switches the support for LFN (long file name). 103 | / 104 | / 0: Disable LFN. FF_MAX_LFN has no effect. 105 | / 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe. 106 | / 2: Enable LFN with dynamic working buffer on the STACK. 107 | / 3: Enable LFN with dynamic working buffer on the HEAP. 108 | / 109 | / To enable the LFN, ffunicode.c needs to be added to the project. The LFN function 110 | / requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and 111 | / additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled. 112 | / The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can 113 | / be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN 114 | / specification. 115 | / When use stack for the working buffer, take care on stack overflow. When use heap 116 | / memory for the working buffer, memory management functions, ff_memalloc() and 117 | / ff_memfree() exemplified in ffsystem.c, need to be added to the project. */ 118 | 119 | 120 | #define FF_LFN_UNICODE 2 121 | /* This option switches the character encoding on the API when LFN is enabled. 122 | / 123 | / 0: ANSI/OEM in current CP (TCHAR = char) 124 | / 1: Unicode in UTF-16 (TCHAR = WCHAR) 125 | / 2: Unicode in UTF-8 (TCHAR = char) 126 | / 3: Unicode in UTF-32 (TCHAR = DWORD) 127 | / 128 | / Also behavior of string I/O functions will be affected by this option. 129 | / When LFN is not enabled, this option has no effect. */ 130 | 131 | 132 | #define FF_LFN_BUF 255 133 | #define FF_SFN_BUF 12 134 | /* This set of options defines size of file name members in the FILINFO structure 135 | / which is used to read out directory items. These values should be suffcient for 136 | / the file names to read. The maximum possible length of the read file name depends 137 | / on character encoding. When LFN is not enabled, these options have no effect. */ 138 | 139 | 140 | #define FF_STRF_ENCODE 3 141 | /* When FF_LFN_UNICODE >= 1 with LFN enabled, string I/O functions, f_gets(), 142 | / f_putc(), f_puts and f_printf() convert the character encoding in it. 143 | / This option selects assumption of character encoding ON THE FILE to be 144 | / read/written via those functions. 145 | / 146 | / 0: ANSI/OEM in current CP 147 | / 1: Unicode in UTF-16LE 148 | / 2: Unicode in UTF-16BE 149 | / 3: Unicode in UTF-8 150 | */ 151 | 152 | 153 | #define FF_FS_RPATH 0 154 | /* This option configures support for relative path. 155 | / 156 | / 0: Disable relative path and remove related functions. 157 | / 1: Enable relative path. f_chdir() and f_chdrive() are available. 158 | / 2: f_getcwd() function is available in addition to 1. 159 | */ 160 | 161 | 162 | /*---------------------------------------------------------------------------/ 163 | / Drive/Volume Configurations 164 | /---------------------------------------------------------------------------*/ 165 | 166 | #define FF_VOLUMES 8 167 | /* Number of volumes (logical drives) to be used. (1-10) */ 168 | 169 | 170 | #define FF_STR_VOLUME_ID 0 171 | #define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" 172 | /* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings. 173 | / When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive 174 | / number in the path name. FF_VOLUME_STRS defines the volume ID strings for each 175 | / logical drives. Number of items must not be less than FF_VOLUMES. Valid 176 | / characters for the volume ID strings are A-Z, a-z and 0-9, however, they are 177 | / compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is 178 | / not defined, a user defined volume string table needs to be defined as: 179 | / 180 | / const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",... 181 | */ 182 | 183 | 184 | #define FF_MULTI_PARTITION 0 185 | /* This option switches support for multiple volumes on the physical drive. 186 | / By default (0), each logical drive number is bound to the same physical drive 187 | / number and only an FAT volume found on the physical drive will be mounted. 188 | / When this function is enabled (1), each logical drive number can be bound to 189 | / arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk() 190 | / funciton will be available. */ 191 | 192 | 193 | #define FF_MIN_SS 512 194 | #define FF_MAX_SS 4096 195 | /* This set of options configures the range of sector size to be supported. (512, 196 | / 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and 197 | / harddisk. But a larger value may be required for on-board flash memory and some 198 | / type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured 199 | / for variable sector size mode and disk_ioctl() function needs to implement 200 | / GET_SECTOR_SIZE command. */ 201 | 202 | 203 | #define FF_LBA64 0 204 | /* This option switches support for 64-bit LBA. (0:Disable or 1:Enable) 205 | / To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */ 206 | 207 | 208 | #define FF_MIN_GPT 0x100000000 209 | /* Minimum number of sectors to switch GPT format to create partition in f_mkfs and 210 | / f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */ 211 | 212 | 213 | #define FF_USE_TRIM 0 214 | /* This option switches support for ATA-TRIM. (0:Disable or 1:Enable) 215 | / To enable Trim function, also CTRL_TRIM command should be implemented to the 216 | / disk_ioctl() function. */ 217 | 218 | 219 | 220 | /*---------------------------------------------------------------------------/ 221 | / System Configurations 222 | /---------------------------------------------------------------------------*/ 223 | 224 | #define FF_FS_TINY 0 225 | /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny) 226 | / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes. 227 | / Instead of private sector buffer eliminated from the file object, common sector 228 | / buffer in the filesystem object (FATFS) is used for the file data transfer. */ 229 | 230 | 231 | #define FF_FS_EXFAT 1 232 | /* This option switches support for exFAT filesystem. (0:Disable or 1:Enable) 233 | / To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1) 234 | / Note that enabling exFAT discards ANSI C (C89) compatibility. */ 235 | 236 | 237 | #define FF_FS_NORTC 1 238 | #define FF_NORTC_MON 1 239 | #define FF_NORTC_MDAY 1 240 | #define FF_NORTC_YEAR 2020 241 | /* The option FF_FS_NORTC switches timestamp functiton. If the system does not have 242 | / any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable 243 | / the timestamp function. Every object modified by FatFs will have a fixed timestamp 244 | / defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time. 245 | / To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be 246 | / added to the project to read current time form real-time clock. FF_NORTC_MON, 247 | / FF_NORTC_MDAY and FF_NORTC_YEAR have no effect. 248 | / These options have no effect in read-only configuration (FF_FS_READONLY = 1). */ 249 | 250 | 251 | #define FF_FS_NOFSINFO 0 252 | /* If you need to know correct free space on the FAT32 volume, set bit 0 of this 253 | / option, and f_getfree() function at first time after volume mount will force 254 | / a full FAT scan. Bit 1 controls the use of last allocated cluster number. 255 | / 256 | / bit0=0: Use free cluster count in the FSINFO if available. 257 | / bit0=1: Do not trust free cluster count in the FSINFO. 258 | / bit1=0: Use last allocated cluster number in the FSINFO if available. 259 | / bit1=1: Do not trust last allocated cluster number in the FSINFO. 260 | */ 261 | 262 | 263 | #define FF_FS_LOCK 0 264 | /* The option FF_FS_LOCK switches file lock function to control duplicated file open 265 | / and illegal operation to open objects. This option must be 0 when FF_FS_READONLY 266 | / is 1. 267 | / 268 | / 0: Disable file lock function. To avoid volume corruption, application program 269 | / should avoid illegal open, remove and rename to the open objects. 270 | / >0: Enable file lock function. The value defines how many files/sub-directories 271 | / can be opened simultaneously under file lock control. Note that the file 272 | / lock control is independent of re-entrancy. */ 273 | 274 | 275 | /* #include // O/S definitions */ 276 | #define FF_FS_REENTRANT 0 277 | #define FF_FS_TIMEOUT 1000 278 | #define FF_SYNC_t HANDLE 279 | /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs 280 | / module itself. Note that regardless of this option, file access to different 281 | / volume is always re-entrant and volume control functions, f_mount(), f_mkfs() 282 | / and f_fdisk() function, are always not re-entrant. Only file/directory access 283 | / to the same volume is under control of this function. 284 | / 285 | / 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect. 286 | / 1: Enable re-entrancy. Also user provided synchronization handlers, 287 | / ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj() 288 | / function, must be added to the project. Samples are available in 289 | / option/syscall.c. 290 | / 291 | / The FF_FS_TIMEOUT defines timeout period in unit of time tick. 292 | / The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*, 293 | / SemaphoreHandle_t and etc. A header file for O/S definitions needs to be 294 | / included somewhere in the scope of ff.h. */ 295 | 296 | 297 | 298 | /*--- End of configuration options ---*/ 299 | -------------------------------------------------------------------------------- /source/util.c: -------------------------------------------------------------------------------- 1 | //util.c 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "util.h" 12 | #include "rsxutil.h" 13 | #include "pad.h" 14 | #include "ttf_render.h" 15 | 16 | #define S_PI 3.14159265f 17 | #define D_PI 6.28318531f 18 | 19 | char *na_string = "n/a"; 20 | 21 | int NPad (int btn) 22 | { 23 | if (new_pad & btn) 24 | return 1; 25 | return 0; 26 | } 27 | 28 | int PPad (int btn) 29 | { 30 | if (old_pad & btn) 31 | return 1; 32 | return 0; 33 | } 34 | 35 | #define PPAD_SKIP 5 //skip old pad report every 5 calls to reduce speed 36 | int APad (int btn) 37 | { 38 | static int pps = PPAD_SKIP; 39 | if (NPad(btn)) 40 | { 41 | pps = PPAD_SKIP; 42 | return 1; 43 | } 44 | if (PPad(btn)) 45 | { 46 | if (pps--) 47 | return 0; 48 | pps = PPAD_SKIP; 49 | return 1; 50 | } 51 | return 0; 52 | } 53 | 54 | void DrawRect2d (float x, float y, float z, float w, float h, u32 rgba) 55 | { 56 | tiny3d_SetPolygon (TINY3D_QUADS); 57 | tiny3d_VertexPos (x, y, z); 58 | tiny3d_VertexColor (rgba); 59 | tiny3d_VertexPos (x + w, y, z); 60 | tiny3d_VertexPos (x + w, y + h, z); 61 | tiny3d_VertexPos (x, y + h, z); 62 | tiny3d_End (); 63 | } 64 | 65 | #if 0 66 | unsigned long get_millis () 67 | { 68 | struct timeval tv; 69 | gettimeofday (&tv, NULL); 70 | return (unsigned long)((unsigned long long)tv.tv_sec * CLK_TCK + 71 | (unsigned long long)tv.tv_usec * (1000000L / CLK_TCK)); 72 | } 73 | #endif 74 | 75 | int fps_update () 76 | { 77 | static time_t times = 0, timee; 78 | static int fpsv = -1; 79 | static int fpsh = 0; 80 | // 81 | if (times == 0) 82 | time (×); 83 | time (&timee); 84 | // 85 | if (timee > times) 86 | { 87 | fpsh = fpsv; 88 | times = timee; 89 | fpsv = -1; 90 | } 91 | fpsv++; 92 | // 93 | return fpsh; 94 | } 95 | 96 | 97 | void do_flip () 98 | { 99 | sysUtilCheckCallback (); 100 | flip (); 101 | tiny3d_Flip (); 102 | } 103 | 104 | static msgType mdialogyesno = MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_YESNO | MSG_DIALOG_DEFAULT_CURSOR_NO; 105 | static msgType mdialogyesno2 = MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_YESNO | MSG_DIALOG_DISABLE_CANCEL_ON; 106 | static msgType mdialogyesno3 = MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_YESNO; 107 | 108 | static msgType mdialogok = MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK; 109 | 110 | static msgType mdialog = MSG_DIALOG_NORMAL | MSG_DIALOG_DISABLE_CANCEL_ON; 111 | 112 | static volatile int dialog_action = 0; 113 | 114 | static void my_dialog(msgButton button, void *userdata) 115 | { 116 | switch(button) 117 | { 118 | case MSG_DIALOG_BTN_YES: 119 | dialog_action = 1; 120 | break; 121 | case MSG_DIALOG_BTN_NO: 122 | case MSG_DIALOG_BTN_ESCAPE: 123 | case MSG_DIALOG_BTN_NONE: 124 | dialog_action = 2; 125 | break; 126 | default: 127 | break; 128 | } 129 | } 130 | 131 | static void my_dialog2(msgButton button, void *userdata) 132 | { 133 | switch(button) 134 | { 135 | case MSG_DIALOG_BTN_OK: 136 | case MSG_DIALOG_BTN_ESCAPE: 137 | case MSG_DIALOG_BTN_NONE: 138 | dialog_action = 1; 139 | break; 140 | default: 141 | break; 142 | } 143 | } 144 | 145 | static void wait_dialog () 146 | { 147 | while(!dialog_action) 148 | { 149 | do_flip (); 150 | } 151 | 152 | msgDialogAbort (); 153 | usleep (100000); 154 | } 155 | 156 | void OKTimerDialog (char * str, float milliseconds) 157 | { 158 | dialog_action = 0; 159 | 160 | msgDialogOpen2 (mdialogok, str, my_dialog2, (void*) 0x0000aaab, NULL ); 161 | msgDialogClose (milliseconds); 162 | 163 | wait_dialog (); 164 | } 165 | 166 | 167 | void OKDialog (char * str) 168 | { 169 | dialog_action = 0; 170 | 171 | msgDialogOpen2 (mdialogok, str, my_dialog2, (void*) 0x0000aaab, NULL ); 172 | 173 | wait_dialog (); 174 | } 175 | 176 | 177 | void TimerDialog (char * str, float milliseconds) 178 | { 179 | dialog_action = 0; 180 | 181 | msgDialogOpen2(mdialog, str, my_dialog2, (void*) 0x0000aaab, NULL ); 182 | msgDialogClose(milliseconds); 183 | 184 | wait_dialog(); 185 | } 186 | 187 | int YesNoTimerDialog (char * str, float milliseconds) 188 | { 189 | dialog_action = 0; 190 | 191 | msgDialogOpen2 (mdialogyesno, str, my_dialog, (void*) 0x0000aaaa, NULL ); 192 | msgDialogClose (milliseconds); 193 | 194 | wait_dialog (); 195 | 196 | return dialog_action; 197 | } 198 | 199 | int YesNoDialog(char * str) 200 | { 201 | dialog_action = 0; 202 | 203 | msgDialogOpen2(mdialogyesno, str, my_dialog, (void*) 0x0000aaaa, NULL ); 204 | 205 | wait_dialog(); 206 | 207 | return dialog_action; 208 | } 209 | 210 | int YesNoDefaultYesDialog (char * str) 211 | { 212 | dialog_action = 0; 213 | 214 | msgDialogOpen2(mdialogyesno3, str, my_dialog, (void*) 0x0000aaaa, NULL ); 215 | 216 | wait_dialog(); 217 | 218 | return dialog_action; 219 | } 220 | 221 | int YesNoTimer2Dialog (char * str, float milliseconds) 222 | { 223 | dialog_action = 0; 224 | 225 | msgDialogOpen2(mdialogyesno2, str, my_dialog, (void*) 0x0000aaaa, NULL ); 226 | msgDialogClose(milliseconds); 227 | 228 | wait_dialog(); 229 | 230 | return dialog_action; 231 | } 232 | 233 | int YesNo2Dialog (char * str) 234 | { 235 | dialog_action = 0; 236 | 237 | msgDialogOpen2(mdialogyesno2, str, my_dialog, (void*) 0x0000aaaa, NULL ); 238 | 239 | wait_dialog(); 240 | 241 | return dialog_action; 242 | } 243 | 244 | //progress bar dialog box 245 | static volatile int progress_action = 0; 246 | 247 | static volatile u32 prev_prc0 = 0; 248 | static volatile u32 prev_prc1 = 0; 249 | 250 | static msgType mdialogprogress = MSG_DIALOG_SINGLE_PROGRESSBAR | MSG_DIALOG_MUTE_ON | MSG_DIALOG_DISABLE_CANCEL_ON | MSG_DIALOG_BKG_INVISIBLE; 251 | static msgType mdialogprogress2 = MSG_DIALOG_DOUBLE_PROGRESSBAR | MSG_DIALOG_MUTE_ON; 252 | 253 | static void progress_callback(msgButton button, void *userdata) 254 | { 255 | switch(button) 256 | { 257 | //case MSG_DIALOG_BTN_OK: 258 | case MSG_DIALOG_BTN_YES: 259 | progress_action = 1; 260 | break; 261 | case MSG_DIALOG_BTN_NO: 262 | case MSG_DIALOG_BTN_ESCAPE: 263 | progress_action = 2; 264 | break; 265 | case MSG_DIALOG_BTN_NONE: 266 | case MSG_DIALOG_BTN_INVALID: 267 | progress_action = -1; 268 | break; 269 | default: 270 | break; 271 | } 272 | } 273 | 274 | void ProgressBarUpdate(u32 cprc, const char *msg) 275 | { 276 | if (msg) 277 | { 278 | msgDialogProgressBarSetMsg (MSG_PROGRESSBAR_INDEX0, msg); 279 | } 280 | if (cprc > prev_prc0) 281 | { 282 | msgDialogProgressBarInc (MSG_PROGRESSBAR_INDEX0, cprc - prev_prc0); 283 | prev_prc0 = cprc; 284 | } 285 | else if (cprc < prev_prc0) 286 | { 287 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 288 | prev_prc0 = 0; 289 | } 290 | do_flip (); 291 | } 292 | 293 | void ProgressBar2Update(u32 cprc, const char *msg) 294 | { 295 | if (msg) 296 | { 297 | msgDialogProgressBarSetMsg (MSG_PROGRESSBAR_INDEX1, msg); 298 | } 299 | if (cprc > prev_prc1) 300 | { 301 | msgDialogProgressBarInc (MSG_PROGRESSBAR_INDEX1, cprc - prev_prc1); 302 | prev_prc1 = cprc; 303 | } 304 | else if (cprc < prev_prc1) 305 | { 306 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1); 307 | prev_prc1 = 0; 308 | } 309 | // 310 | do_flip (); 311 | } 312 | 313 | void SingleProgressBarDialog(char *caption) 314 | { 315 | progress_action = 0; 316 | prev_prc0 = 0; 317 | 318 | msgDialogOpen2(mdialogprogress, caption, progress_callback, (void *) 0xadef0044, NULL); 319 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 320 | 321 | //2 322 | do_flip (); 323 | 324 | //3 325 | //Update message and progress 326 | //ProgressBarUpdate(prc, msg); 327 | 328 | //4: 1 = OK, YES; 2 = NO/ESC/CANCEL; -1 = NONE 329 | //if(ProgressBarActionGet() == 2) break; 330 | 331 | //5 332 | //msgDialogAbort(); 333 | } 334 | 335 | void DoubleProgressBarDialog(char *caption) 336 | { 337 | progress_action = 0; 338 | prev_prc0 = 0; 339 | prev_prc1 = 0; 340 | 341 | msgDialogOpen2(mdialogprogress2, caption, progress_callback, (void *) 0xadef0042, NULL); 342 | msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0, ""); 343 | msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1, ""); 344 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 345 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1); 346 | 347 | //2 348 | do_flip (); 349 | 350 | //3 351 | //Update message and progress 352 | //ProgressBarUpdate(prc, msg); 353 | //ProgressBar2Update(prc, msg); 354 | 355 | //4: 1 = OK, YES; 2 = NO/ESC/CANCEL; -1 = NONE 356 | //if(ProgressBarActionGet() == 2) break; 357 | 358 | //5 359 | //msgDialogAbort(); 360 | } 361 | 362 | int ProgressBarActionGet () 363 | { 364 | return progress_action; 365 | } 366 | 367 | #if 0 368 | static int my_game_copy(char *path, char *path2) 369 | { 370 | 371 | progress_action2 = 0; 372 | 373 | bar1_countparts = 0.0f; 374 | bar2_countparts = 0.0f; 375 | 376 | msgDialogOpen2(mdialogprogress2, progress_bar_title, progress_callback, (void *) 0xadef0045, NULL); 377 | 378 | msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX0, " "); 379 | msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1, " "); 380 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 381 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1); 382 | 383 | sysUtilCheckCallback(); tiny3d_Flip(); 384 | 385 | global_device_bytes = 0; 386 | 387 | if(fast_copy_async(path, path2, 1) < 0) {abort_copy = 665; msgDialogAbort(); return FAILED;} 388 | 389 | int ret = _my_game_copy(path, path2); 390 | 391 | int ret2 = fast_copy_process(); 392 | 393 | fast_copy_async(path, path2, 0); 394 | 395 | msgDialogAbort(); 396 | 397 | if(ret < 0 || ret2 < 0) return FAILED; 398 | 399 | return SUCCESS; 400 | } 401 | // 402 | /***********************************************************************************************************/ 403 | /* msgDialog */ 404 | /***********************************************************************************************************/ 405 | 406 | 407 | static msgType mdialogprogress = MSG_DIALOG_SINGLE_PROGRESSBAR | MSG_DIALOG_MUTE_ON; 408 | static msgType mdialogprogress2 = MSG_DIALOG_DOUBLE_PROGRESSBAR | MSG_DIALOG_MUTE_ON; 409 | 410 | static volatile int progress_action = 0; 411 | 412 | static void progress_callback(msgButton button, void *userdata) 413 | { 414 | switch(button) 415 | { 416 | case MSG_DIALOG_BTN_OK: 417 | progress_action = 1; 418 | break; 419 | case MSG_DIALOG_BTN_NO: 420 | case MSG_DIALOG_BTN_ESCAPE: 421 | progress_action = 2; 422 | break; 423 | case MSG_DIALOG_BTN_NONE: 424 | progress_action = -1; 425 | break; 426 | default: 427 | 428 | break; 429 | } 430 | } 431 | 432 | static void update_bar(u32 cpart) 433 | { 434 | msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0, (u32) cpart); 435 | sysUtilCheckCallback(); tiny3d_Flip(); 436 | } 437 | 438 | static void update_bar2(u32 cpart) 439 | { 440 | msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX1, (u32) cpart); 441 | sysUtilCheckCallback(); tiny3d_Flip(); 442 | } 443 | 444 | static void single_bar(char *caption) 445 | { 446 | progress_action = 0; 447 | 448 | msgDialogOpen2(mdialogprogress, caption, progress_callback, (void *) 0xadef0044, NULL); 449 | 450 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 451 | 452 | sysUtilCheckCallback();tiny3d_Flip(); 453 | } 454 | 455 | static float progress_0 = 0.0f; 456 | 457 | static void double_bar(char *caption) 458 | { 459 | progress_action = 0; 460 | 461 | msgDialogOpen2(mdialogprogress2, caption, progress_callback, (void *) 0xadef0042, NULL); 462 | 463 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX0); 464 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1); 465 | 466 | progress_0 = 0.0f; 467 | sysUtilCheckCallback();tiny3d_Flip(); 468 | } 469 | 470 | single_bar("Deleting..."); 471 | 472 | float parts = 100.0f / (float) files; 473 | float cpart = 0; 474 | 475 | for(n = 0; n < nentries; n++) 476 | { 477 | if(!(entries[n].d_type & IS_MARKED)) continue; // skip no marked 478 | if(progress_action == 2) break; 479 | 480 | cpart += parts; 481 | if(cpart >= 1.0f) 482 | { 483 | update_bar((u32) cpart); 484 | .. 485 | sysUtilCheckCallback(); tiny3d_Flip(); 486 | msgDialogAbort(); 487 | usleep(250000); 488 | 489 | // 490 | msgDialogProgressBarReset(MSG_PROGRESSBAR_INDEX1); write_progress = 0; 491 | msgDialogProgressBarSetMsg(MSG_PROGRESSBAR_INDEX1, getfilename_part(fast_files[current_fast_file_r].pathw)); 492 | 493 | msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX0, (u32) bar1_countparts); 494 | bar1_countparts-= (float) ((u32) bar1_countparts); 495 | } 496 | 497 | msgDialogProgressBarInc(MSG_PROGRESSBAR_INDEX1, (u32) bar2_countparts); 498 | 499 | #endif 500 | 501 | //4th 502 | //extern int app_render (int dat); 503 | 504 | void Draw_scene() 505 | { 506 | //app_render (0); 507 | } 508 | 509 | #ifndef LIBBUILD 510 | void cls() 511 | { 512 | tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); 513 | 514 | // Enable alpha Test 515 | tiny3d_AlphaTest(1, 1, TINY3D_ALPHA_FUNC_GEQUAL); 516 | 517 | // Enable alpha blending. 518 | tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 519 | TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO, 520 | TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); 521 | reset_ttf_frame(); 522 | } 523 | 524 | void UTF16_to_UTF8(u16 *stw, u8 *stb) 525 | { 526 | while(stw[0]) 527 | { 528 | if((stw[0] & 0xFF80) == 0) 529 | { 530 | *(stb++) = stw[0] & 0xFF; // utf16 00000000 0xxxxxxx utf8 0xxxxxxx 531 | } 532 | else if((stw[0] & 0xF800) == 0) 533 | { 534 | // utf16 00000yyy yyxxxxxx utf8 110yyyyy 10xxxxxx 535 | *(stb++) = ((stw[0]>>6) & 0xFF) | 0xC0; *(stb++) = (stw[0] & 0x3F) | 0x80; 536 | } 537 | else if((stw[0] & 0xFC00) == 0xD800 && (stw[1] & 0xFC00) == 0xDC00) 538 | { 539 | // utf16 110110ww wwzzzzyy 110111yy yyxxxxxx (wwww = uuuuu - 1) 540 | // utf8 1111000uu 10uuzzzz 10yyyyyy 10xxxxxx 541 | *(stb++)= (((stw[0] + 64)>>8) & 0x3) | 0xF0; *(stb++)= (((stw[0]>>2) + 16) & 0x3F) | 0x80; 542 | *(stb++)= ((stw[0]>>4) & 0x30) | 0x80 | ((stw[1]<<2) & 0xF); *(stb++)= (stw[1] & 0x3F) | 0x80; 543 | stw++; 544 | } 545 | else 546 | { 547 | // utf16 zzzzyyyy yyxxxxxx utf8 1110zzzz 10yyyyyy 10xxxxxx 548 | *(stb++)= ((stw[0]>>12) & 0xF) | 0xE0; *(stb++)= ((stw[0]>>6) & 0x3F) | 0x80; *(stb++)= (stw[0] & 0x3F) | 0x80; 549 | } 550 | 551 | stw++; 552 | } 553 | 554 | *stb = 0; 555 | } 556 | 557 | void UTF8_to_UTF16(u8 *stb, u16 *stw) 558 | { 559 | int n, m; 560 | u32 UTF32; 561 | while(*stb) 562 | { 563 | if(*stb & 128) 564 | { 565 | m = 1; 566 | 567 | if((*stb & 0xf8) == 0xf0) 568 | { 569 | // 4 bytes 570 | UTF32 = (u32) (*(stb++) & 3); 571 | m = 3; 572 | } 573 | else if((*stb & 0xE0) == 0xE0) 574 | { 575 | // 3 bytes 576 | UTF32 = (u32) (*(stb++) & 0xf); 577 | m = 2; 578 | } 579 | else if((*stb & 0xE0) == 0xC0) 580 | { 581 | // 2 bytes 582 | UTF32 = (u32) (*(stb++) & 0x1f); 583 | m = 1; 584 | } 585 | else {stb++; continue;} // Error! 586 | 587 | for(n = 0; n < m; n++) 588 | { 589 | if(!*stb) break; // Error! 590 | 591 | if((*stb & 0xc0) != 0x80) break; // Error! 592 | UTF32 = (UTF32 <<6) |((u32) (*(stb++) & 63)); 593 | } 594 | 595 | if((n != m) && !*stb) break; 596 | 597 | } else UTF32 = (u32) *(stb++); 598 | 599 | if(UTF32<65536) 600 | *stw++= (u16) UTF32; 601 | else 602 | { 603 | //110110ww wwzzzzyy 110111yy yyxxxxxx 604 | *stw++= (((u16) (UTF32>>10)) & 0x3ff) | 0xD800; 605 | *stw++= (((u16) (UTF32)) & 0x3ff) | 0xDC00; 606 | } 607 | } 608 | 609 | *stw++ = 0; 610 | } 611 | 612 | #endif 613 | -------------------------------------------------------------------------------- /lib/include/ff.h: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | / FatFs - Generic FAT Filesystem module R0.14 / 3 | /-----------------------------------------------------------------------------/ 4 | / 5 | / Copyright (C) 2019, ChaN, all right reserved. 6 | / 7 | / FatFs module is an open source software. Redistribution and use of FatFs in 8 | / source and binary forms, with or without modification, are permitted provided 9 | / that the following condition is met: 10 | 11 | / 1. Redistributions of source code must retain the above copyright notice, 12 | / this condition and the following disclaimer. 13 | / 14 | / This software is provided by the copyright holder and contributors "AS IS" 15 | / and any warranties related to this software are DISCLAIMED. 16 | / The copyright owner or contributors be NOT LIABLE for any damages caused 17 | / by use of this software. 18 | / 19 | /----------------------------------------------------------------------------*/ 20 | 21 | 22 | #ifndef FF_DEFINED 23 | #define FF_DEFINED 86606 /* Revision ID */ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include "ffconf.h" /* FatFs configuration options */ 30 | 31 | #if FF_DEFINED != FFCONF_DEF 32 | #error Wrong configuration file (ffconf.h). 33 | #endif 34 | 35 | 36 | /* Integer types used for FatFs API */ 37 | 38 | #if defined(_WIN32) /* Main development platform */ 39 | #define FF_INTDEF 2 40 | #include 41 | typedef unsigned __int64 QWORD; 42 | #elif defined(PS3_GEKKO) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */ 43 | #define FF_INTDEF 2 44 | #include 45 | typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ 46 | typedef unsigned char BYTE; /* char must be 8-bit */ 47 | typedef uint16_t WORD; /* 16-bit unsigned integer */ 48 | typedef uint32_t DWORD; /* 32-bit unsigned integer */ 49 | typedef uint64_t QWORD; /* 64-bit unsigned integer */ 50 | typedef WORD WCHAR; /* UTF-16 character type */ 51 | #else /* Earlier than C99 */ 52 | #define FF_INTDEF 1 53 | typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ 54 | typedef unsigned char BYTE; /* char must be 8-bit */ 55 | typedef unsigned short WORD; /* 16-bit unsigned integer */ 56 | typedef unsigned long DWORD; /* 32-bit unsigned integer */ 57 | typedef WORD WCHAR; /* UTF-16 character type */ 58 | #endif 59 | 60 | 61 | /* Definitions of volume management */ 62 | 63 | #if FF_MULTI_PARTITION /* Multiple partition configuration */ 64 | typedef struct { 65 | BYTE pd; /* Physical drive number */ 66 | BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */ 67 | } PARTITION; 68 | extern PARTITION VolToPart[]; /* Volume - Partition mapping table */ 69 | #endif 70 | 71 | #if FF_STR_VOLUME_ID 72 | #ifndef FF_VOLUME_STRS 73 | extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */ 74 | #endif 75 | #endif 76 | 77 | 78 | 79 | /* Type of path name strings on FatFs API */ 80 | 81 | #ifndef _INC_TCHAR 82 | #define _INC_TCHAR 83 | 84 | #if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */ 85 | typedef WCHAR TCHAR; 86 | #define _T(x) L ## x 87 | #define _TEXT(x) L ## x 88 | #elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */ 89 | typedef char TCHAR; 90 | #define _T(x) u8 ## x 91 | #define _TEXT(x) u8 ## x 92 | #elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */ 93 | typedef DWORD TCHAR; 94 | #define _T(x) U ## x 95 | #define _TEXT(x) U ## x 96 | #elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3) 97 | #error Wrong FF_LFN_UNICODE setting 98 | #else /* ANSI/OEM code in SBCS/DBCS */ 99 | typedef char TCHAR; 100 | #define _T(x) x 101 | #define _TEXT(x) x 102 | #endif 103 | 104 | #endif 105 | 106 | 107 | 108 | /* Type of file size and LBA variables */ 109 | 110 | #if FF_FS_EXFAT 111 | #if FF_INTDEF != 2 112 | #error exFAT feature wants C99 or later 113 | #endif 114 | typedef QWORD FSIZE_t; 115 | #if FF_LBA64 116 | typedef QWORD LBA_t; 117 | #else 118 | typedef DWORD LBA_t; 119 | #endif 120 | #else 121 | #if FF_LBA64 122 | #error exFAT needs to be enabled when enable 64-bit LBA 123 | #endif 124 | typedef DWORD FSIZE_t; 125 | typedef DWORD LBA_t; 126 | #endif 127 | 128 | 129 | 130 | /* Filesystem object structure (FATFS) */ 131 | 132 | typedef struct { 133 | BYTE fs_type; /* Filesystem type (0:not mounted) */ 134 | BYTE pdrv; /* Associated physical drive */ 135 | BYTE n_fats; /* Number of FATs (1 or 2) */ 136 | BYTE wflag; /* win[] flag (b0:dirty) */ 137 | BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */ 138 | WORD id; /* Volume mount ID */ 139 | WORD n_rootdir; /* Number of root directory entries (FAT12/16) */ 140 | WORD csize; /* Cluster size [sectors] */ 141 | #if FF_MAX_SS != FF_MIN_SS 142 | WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */ 143 | #endif 144 | #if FF_USE_LFN 145 | WCHAR* lfnbuf; /* LFN working buffer */ 146 | #endif 147 | #if FF_FS_EXFAT 148 | BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */ 149 | #endif 150 | #if FF_FS_REENTRANT 151 | FF_SYNC_t sobj; /* Identifier of sync object */ 152 | #endif 153 | #if !FF_FS_READONLY 154 | DWORD last_clst; /* Last allocated cluster */ 155 | DWORD free_clst; /* Number of free clusters */ 156 | #endif 157 | #if FF_FS_RPATH 158 | DWORD cdir; /* Current directory start cluster (0:root) */ 159 | #if FF_FS_EXFAT 160 | DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */ 161 | DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */ 162 | DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */ 163 | #endif 164 | #endif 165 | DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */ 166 | DWORD fsize; /* Size of an FAT [sectors] */ 167 | LBA_t volbase; /* Volume base sector */ 168 | LBA_t fatbase; /* FAT base sector */ 169 | LBA_t dirbase; /* Root directory base sector/cluster */ 170 | LBA_t database; /* Data base sector */ 171 | #if FF_FS_EXFAT 172 | LBA_t bitbase; /* Allocation bitmap base sector */ 173 | #endif 174 | LBA_t winsect; /* Current sector appearing in the win[] */ 175 | BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */ 176 | } FATFS; 177 | 178 | 179 | 180 | /* Object ID and allocation information (FFOBJID) */ 181 | 182 | typedef struct { 183 | FATFS* fs; /* Pointer to the hosting volume of this object */ 184 | WORD id; /* Hosting volume mount ID */ 185 | BYTE attr; /* Object attribute */ 186 | BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */ 187 | DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */ 188 | FSIZE_t objsize; /* Object size (valid when sclust != 0) */ 189 | #if FF_FS_EXFAT 190 | DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */ 191 | DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */ 192 | DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */ 193 | DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */ 194 | DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */ 195 | #endif 196 | #if FF_FS_LOCK 197 | UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */ 198 | #endif 199 | } FFOBJID; 200 | 201 | 202 | 203 | /* File object structure (FIL) */ 204 | 205 | typedef struct { 206 | FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */ 207 | BYTE flag; /* File status flags */ 208 | BYTE err; /* Abort flag (error code) */ 209 | FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */ 210 | DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */ 211 | LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */ 212 | #if !FF_FS_READONLY 213 | LBA_t dir_sect; /* Sector number containing the directory entry (not used at exFAT) */ 214 | BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */ 215 | #endif 216 | #if FF_USE_FASTSEEK 217 | DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */ 218 | #endif 219 | #if !FF_FS_TINY 220 | BYTE buf[FF_MAX_SS]; /* File private data read/write window */ 221 | #endif 222 | } FIL; 223 | 224 | 225 | 226 | /* Directory object structure (DIR) */ 227 | 228 | typedef struct { 229 | FFOBJID obj; /* Object identifier */ 230 | DWORD dptr; /* Current read/write offset */ 231 | DWORD clust; /* Current cluster */ 232 | LBA_t sect; /* Current sector (0:Read operation has terminated) */ 233 | BYTE* dir; /* Pointer to the directory item in the win[] */ 234 | BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */ 235 | #if FF_USE_LFN 236 | DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */ 237 | #endif 238 | #if FF_USE_FIND 239 | const TCHAR* pat; /* Pointer to the name matching pattern */ 240 | #endif 241 | } FDIR; 242 | 243 | 244 | 245 | /* File information structure (FILINFO) */ 246 | 247 | typedef struct { 248 | FSIZE_t fsize; /* File size */ 249 | WORD fdate; /* Modified date */ 250 | WORD ftime; /* Modified time */ 251 | BYTE fattrib; /* File attribute */ 252 | #if FF_USE_LFN 253 | TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */ 254 | TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */ 255 | #else 256 | TCHAR fname[12 + 1]; /* File name */ 257 | #endif 258 | } FILINFO; 259 | 260 | 261 | 262 | /* Format parameter structure (MKFS_PARM) */ 263 | 264 | typedef struct { 265 | BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */ 266 | BYTE n_fat; /* Number of FATs */ 267 | UINT align; /* Data area alignment (sector) */ 268 | UINT n_root; /* Number of root directory entries */ 269 | DWORD au_size; /* Cluster size (byte) */ 270 | } MKFS_PARM; 271 | 272 | 273 | 274 | /* File function return code (FRESULT) */ 275 | 276 | typedef enum { 277 | FR_OK = 0, /* (0) Succeeded */ 278 | FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */ 279 | FR_INT_ERR, /* (2) Assertion failed */ 280 | FR_NOT_READY, /* (3) The physical drive cannot work */ 281 | FR_NO_FILE, /* (4) Could not find the file */ 282 | FR_NO_PATH, /* (5) Could not find the path */ 283 | FR_INVALID_NAME, /* (6) The path name format is invalid */ 284 | FR_DENIED, /* (7) Access denied due to prohibited access or directory full */ 285 | FR_EXIST, /* (8) Access denied due to prohibited access */ 286 | FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */ 287 | FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */ 288 | FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */ 289 | FR_NOT_ENABLED, /* (12) The volume has no work area */ 290 | FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */ 291 | FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */ 292 | FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */ 293 | FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */ 294 | FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */ 295 | FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */ 296 | FR_INVALID_PARAMETER, /* (19) Given parameter is invalid */ 297 | //-dbg 298 | FR_DBG_ERR1, 299 | FR_DBG_ERR2, 300 | FR_DBG_ERR3, 301 | FR_DBG_ERR4, 302 | FR_DBG_ERR5, 303 | FR_DBG_ERR6, 304 | FR_DBG_ERR7, 305 | FR_DBG_ERR8, 306 | } FRESULT; 307 | 308 | 309 | 310 | /*--------------------------------------------------------------*/ 311 | /* FatFs module application interface */ 312 | 313 | FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */ 314 | FRESULT f_close (FIL* fp); /* Close an open file object */ 315 | FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */ 316 | FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */ 317 | FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */ 318 | FRESULT f_truncate (FIL* fp); /* Truncate the file */ 319 | FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */ 320 | FRESULT f_opendir (FDIR* dp, const TCHAR* path); /* Open a directory */ 321 | FRESULT f_closedir (FDIR* dp); /* Close an open directory */ 322 | FRESULT f_readdir (FDIR* dp, FILINFO* fno); /* Read a directory item */ 323 | FRESULT f_findfirst (FDIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */ 324 | FRESULT f_findnext (FDIR* dp, FILINFO* fno); /* Find next file */ 325 | FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */ 326 | FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */ 327 | FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */ 328 | FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */ 329 | FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */ 330 | FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */ 331 | FRESULT f_chdir (const TCHAR* path); /* Change current directory */ 332 | FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ 333 | FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ 334 | FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ 335 | FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */ 336 | FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ 337 | FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */ 338 | FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */ 339 | FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ 340 | FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */ 341 | FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */ 342 | FRESULT f_setcp (WORD cp); /* Set current code page */ 343 | int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ 344 | int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */ 345 | int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */ 346 | TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */ 347 | 348 | #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize)) 349 | #define f_error(fp) ((fp)->err) 350 | #define f_tell(fp) ((fp)->fptr) 351 | #define f_size(fp) ((fp)->obj.objsize) 352 | #define f_rewind(fp) f_lseek((fp), 0) 353 | #define f_rewinddir(dp) f_readdir((dp), 0) 354 | #define f_rmdir(path) f_unlink(path) 355 | #define f_unmount(path) f_mount(0, path, 0) 356 | 357 | #ifndef EOF 358 | #define EOF (-1) 359 | #endif 360 | 361 | 362 | 363 | 364 | /*--------------------------------------------------------------*/ 365 | /* Additional user defined functions */ 366 | 367 | /* RTC function */ 368 | #if !FF_FS_READONLY && !FF_FS_NORTC 369 | DWORD get_fattime (void); 370 | #endif 371 | 372 | /* LFN support functions */ 373 | #if FF_USE_LFN >= 1 /* Code conversion (defined in unicode.c) */ 374 | WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */ 375 | WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */ 376 | DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */ 377 | #endif 378 | #if FF_USE_LFN == 3 /* Dynamic memory allocation */ 379 | void* ff_memalloc (UINT msize); /* Allocate memory block */ 380 | void ff_memfree (void* mblock); /* Free memory block */ 381 | #endif 382 | 383 | /* Sync functions */ 384 | #if FF_FS_REENTRANT 385 | int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */ 386 | int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */ 387 | void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */ 388 | int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */ 389 | #endif 390 | 391 | 392 | 393 | 394 | /*--------------------------------------------------------------*/ 395 | /* Flags and offset address */ 396 | 397 | 398 | /* File access mode and open method flags (3rd argument of f_open) */ 399 | #define FA_READ 0x01 400 | #define FA_WRITE 0x02 401 | #define FA_OPEN_EXISTING 0x00 402 | #define FA_CREATE_NEW 0x04 403 | #define FA_CREATE_ALWAYS 0x08 404 | #define FA_OPEN_ALWAYS 0x10 405 | #define FA_OPEN_APPEND 0x30 406 | 407 | /* Fast seek controls (2nd argument of f_lseek) */ 408 | #define CREATE_LINKMAP ((FSIZE_t)0 - 1) 409 | 410 | /* Format options (2nd argument of f_mkfs) */ 411 | #define FM_FAT 0x01 412 | #define FM_FAT32 0x02 413 | #define FM_EXFAT 0x04 414 | #define FM_ANY 0x07 415 | #define FM_SFD 0x08 416 | 417 | /* Filesystem type (FATFS.fs_type) */ 418 | #define FS_FAT12 1 419 | #define FS_FAT16 2 420 | #define FS_FAT32 3 421 | #define FS_EXFAT 4 422 | 423 | /* File attribute bits for directory entry (FILINFO.fattrib) */ 424 | #define AM_RDO 0x01 /* Read only */ 425 | #define AM_HID 0x02 /* Hidden */ 426 | #define AM_SYS 0x04 /* System */ 427 | #define AM_DIR 0x10 /* Directory */ 428 | #define AM_ARC 0x20 /* Archive */ 429 | 430 | 431 | #ifdef __cplusplus 432 | } 433 | #endif 434 | 435 | #endif /* FF_DEFINED */ 436 | -------------------------------------------------------------------------------- /source/libfont.c: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D - font library / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include "libfont2.h" 10 | #include "ttf_render.h" 11 | 12 | struct t_font_description 13 | { 14 | int w, h, bh; 15 | 16 | u8 first_char; 17 | u8 last_char; 18 | 19 | u32 rsx_text_offset; 20 | u32 rsx_bytes_per_char; 21 | u32 color_format; 22 | 23 | short fw[256]; // chr width 24 | short fy[256]; // chr y correction 25 | }; 26 | 27 | static struct t_font_datas 28 | { 29 | 30 | int number_of_fonts; 31 | 32 | int current_font; 33 | 34 | struct t_font_description fonts[9]; 35 | 36 | int sx, sy; 37 | 38 | u32 color, bkcolor; 39 | 40 | int autocenter; 41 | int autonewline; 42 | 43 | u32 rsx_text_bk_offset; 44 | int enable_doubletextures; 45 | 46 | float screen_w, screen_h; 47 | 48 | int mod_x, mod_y; 49 | 50 | float X,Y,Z; 51 | 52 | } font_datas; 53 | 54 | 55 | void ResetFont() 56 | { 57 | font_datas.current_font = font_datas.number_of_fonts =0; 58 | 59 | font_datas.color = 0xffffffff; 60 | font_datas.bkcolor = 0; 61 | font_datas.autocenter = 0; 62 | font_datas.X = font_datas.Y = font_datas.Z = 0.0f; 63 | font_datas.autonewline = 0; 64 | 65 | font_datas.sx = font_datas.sy = 8; 66 | 67 | font_datas.rsx_text_bk_offset = 0; 68 | 69 | font_datas.enable_doubletextures = 0; 70 | 71 | font_datas.screen_w = 848.0f; 72 | font_datas.screen_h = 512.0f; 73 | 74 | font_datas.mod_x = font_datas.mod_y = 32; 75 | 76 | } 77 | 78 | u8 * AddFontFromBitmapArray(u8 *font, u8 *texture, u8 first_char, u8 last_char, int w, int h, int bits_per_pixel, int byte_order) 79 | { 80 | int n, a, b; 81 | u8 i; 82 | 83 | if(font_datas.number_of_fonts >= 8) return texture; 84 | 85 | font_datas.fonts[font_datas.number_of_fonts].w = w; 86 | font_datas.fonts[font_datas.number_of_fonts].h = h; 87 | font_datas.fonts[font_datas.number_of_fonts].bh = h; 88 | font_datas.fonts[font_datas.number_of_fonts].color_format = TINY3D_TEX_FORMAT_A4R4G4B4; //TINY3D_TEX_FORMAT_A8R8G8B8; 89 | font_datas.fonts[font_datas.number_of_fonts].first_char = first_char; 90 | font_datas.fonts[font_datas.number_of_fonts].last_char = last_char; 91 | font_datas.autocenter =0; 92 | 93 | font_datas.color = 0xffffffff; 94 | font_datas.bkcolor = 0x0; 95 | 96 | font_datas.sx = w; 97 | font_datas.sy = h; 98 | 99 | font_datas.Z = 0.0f; 100 | 101 | for(n = 0; n < 256; n++) { 102 | font_datas.fonts[font_datas.number_of_fonts].fw[n] = 0; 103 | font_datas.fonts[font_datas.number_of_fonts].fy[n] = 0; 104 | } 105 | 106 | if(!font_datas.rsx_text_bk_offset) { 107 | 108 | texture = (u8 *) ((((long) texture) + 15) & ~15); 109 | font_datas.rsx_text_bk_offset = tiny3d_TextureOffset(texture); 110 | memset(texture, 255, 8 * 8 * 2); 111 | texture += 8 * 8 * 2; 112 | texture = (u8 *) ((((long) texture) + 15) & ~15); 113 | } 114 | 115 | for(n = first_char; n <= last_char; n++) { 116 | 117 | font_datas.fonts[font_datas.number_of_fonts].fw[n] = w; 118 | 119 | texture = (u8 *) ((((long) texture) + 15) & ~15); 120 | 121 | if(n == first_char) font_datas.fonts[font_datas.number_of_fonts].rsx_text_offset = tiny3d_TextureOffset(texture); 122 | 123 | if(n == first_char+1) font_datas.fonts[font_datas.number_of_fonts].rsx_bytes_per_char = tiny3d_TextureOffset(texture) 124 | - font_datas.fonts[font_datas.number_of_fonts].rsx_text_offset; 125 | 126 | for(a = 0; a < h; a++) { 127 | for(b = 0; b < w; b++) { 128 | 129 | i = font[(b * bits_per_pixel)/8]; 130 | 131 | if(byte_order) 132 | i= (i << ((b & (7/bits_per_pixel)) * bits_per_pixel))>> (8-bits_per_pixel); 133 | else 134 | i >>= (b & (7/bits_per_pixel)) * bits_per_pixel; 135 | 136 | i = (i & ((1 << bits_per_pixel)-1)) * 255 / ((1 << bits_per_pixel)-1); 137 | 138 | if(i) {//TINY3D_TEX_FORMAT_A1R5G5B5 139 | //i>>=3; 140 | //*((u16 *) texture) = (1<<15) | (i<<10) | (i<<5) | (i); 141 | //TINY3D_TEX_FORMAT_A4R4G4B4 142 | i>>=4; 143 | *((u16 *) texture) = (i<<12) | 0xfff; 144 | 145 | } else { 146 | 147 | texture[0] = texture[1] = 0x0; //texture[2] = 0x0; 148 | //texture[3] = 0x0; // alpha 149 | } 150 | texture+=2; 151 | 152 | } 153 | 154 | font += (w * bits_per_pixel) / 8; 155 | 156 | } 157 | 158 | } 159 | 160 | texture = (u8 *) ((((long) texture) + 15) & ~15); 161 | 162 | font_datas.number_of_fonts++; 163 | 164 | return texture; 165 | } 166 | 167 | u8 * AddFontFromTTF(u8 *texture, u8 first_char, u8 last_char, int w, int h, 168 | void (* ttf_callback) (u8 chr, u8 * bitmap, short *w, short *h, short *y_correction)) 169 | { 170 | int n, a, b; 171 | u8 i; 172 | u8 *font; 173 | static u8 letter_bitmap[257 * 256]; 174 | 175 | int bits_per_pixel = 8; 176 | 177 | if(font_datas.number_of_fonts >= 8) return texture; 178 | 179 | if(h < 8) h = 8; 180 | if(w < 8) w = 8; 181 | if(h > 256) h = 256; 182 | if(w > 256) w = 256; 183 | 184 | font_datas.fonts[font_datas.number_of_fonts].w = w; 185 | font_datas.fonts[font_datas.number_of_fonts].h = h; 186 | font_datas.fonts[font_datas.number_of_fonts].bh = h+4; 187 | font_datas.fonts[font_datas.number_of_fonts].color_format = TINY3D_TEX_FORMAT_A4R4G4B4; 188 | font_datas.fonts[font_datas.number_of_fonts].first_char = first_char; 189 | font_datas.fonts[font_datas.number_of_fonts].last_char = last_char; 190 | font_datas.autocenter =0; 191 | 192 | font_datas.color = 0xffffffff; 193 | font_datas.bkcolor = 0x0; 194 | 195 | font_datas.sx = w; 196 | font_datas.sy = h; 197 | 198 | font_datas.Z = 0.0f; 199 | 200 | for(n = 0; n < 256; n++) { 201 | font_datas.fonts[font_datas.number_of_fonts].fw[n] = 0; 202 | font_datas.fonts[font_datas.number_of_fonts].fy[n] = 0; 203 | } 204 | 205 | if(!font_datas.rsx_text_bk_offset) { 206 | 207 | texture = (u8 *) ((((long) texture) + 15) & ~15); 208 | font_datas.rsx_text_bk_offset = tiny3d_TextureOffset(texture); 209 | memset(texture, 255, 8 * 8 * 2); 210 | texture += 8 * 8 * 2; 211 | texture = (u8 *) ((((long) texture) + 15) & ~15); 212 | } 213 | 214 | for(n = first_char; n <= last_char; n++) { 215 | 216 | short hh = h; 217 | 218 | font = letter_bitmap; 219 | 220 | font_datas.fonts[font_datas.number_of_fonts].fw[n] = (short) w; 221 | 222 | ttf_callback((u8) (n & 255), letter_bitmap, &font_datas.fonts[font_datas.number_of_fonts].fw[n], &hh, &font_datas.fonts[font_datas.number_of_fonts].fy[n]); 223 | 224 | // letter background correction 225 | if((hh + font_datas.fonts[font_datas.number_of_fonts].fy[n]) > font_datas.fonts[font_datas.number_of_fonts].bh) 226 | font_datas.fonts[font_datas.number_of_fonts].bh = hh + font_datas.fonts[font_datas.number_of_fonts].fy[n]; 227 | 228 | texture = (u8 *) ((((long) texture) + 15) & ~15); 229 | 230 | if(n == first_char) font_datas.fonts[font_datas.number_of_fonts].rsx_text_offset = tiny3d_TextureOffset(texture); 231 | 232 | if(n == first_char+1) font_datas.fonts[font_datas.number_of_fonts].rsx_bytes_per_char = tiny3d_TextureOffset(texture) 233 | - font_datas.fonts[font_datas.number_of_fonts].rsx_text_offset; 234 | 235 | for(a = 0; a < h; a++) { 236 | for(b = 0; b < w; b++) { 237 | 238 | i = font[(b * bits_per_pixel)/8]; 239 | 240 | i >>= (b & (7/bits_per_pixel)) * bits_per_pixel; 241 | 242 | i = (i & ((1 << bits_per_pixel)-1)) * 255 / ((1 << bits_per_pixel)-1); 243 | 244 | if(i) {//TINY3D_TEX_FORMAT_A4R4G4B4 245 | i>>=4; 246 | *((u16 *) texture) = (i<<12) | 0xfff; 247 | } else { 248 | 249 | texture[0] = texture[1] = 0x0; //texture[2] = 0x0; 250 | //texture[3] = 0x0; // alpha 251 | } 252 | texture+=2; 253 | 254 | } 255 | 256 | font += (w * bits_per_pixel) / 8; 257 | 258 | } 259 | 260 | } 261 | 262 | texture = (u8 *) ((((long) texture) + 15) & ~15); 263 | 264 | font_datas.number_of_fonts++; 265 | 266 | return texture; 267 | } 268 | 269 | void SetCurrentFont(int nfont) 270 | { 271 | if(nfont < -1 || nfont >= font_datas.number_of_fonts) nfont = 0; 272 | if(nfont == -1) nfont = 8; 273 | 274 | font_datas.current_font = nfont; 275 | } 276 | 277 | void SetFontSize(int sx, int sy) 278 | { 279 | if(sx < 8) sx = 8; 280 | if(sy < 8) sy = 8; 281 | 282 | font_datas.sx = sx; 283 | font_datas.sy = sy; 284 | } 285 | 286 | void SetFontColor(u32 color, u32 bkcolor) 287 | { 288 | font_datas.color = color; 289 | font_datas.bkcolor = bkcolor; 290 | } 291 | 292 | void SetFontTextureMethod(int method) 293 | { 294 | font_datas.enable_doubletextures = method; 295 | } 296 | 297 | void SetDoubleTextureModule(int module_x, int module_y) 298 | { 299 | font_datas.mod_x = module_x; 300 | font_datas.mod_y = module_y; 301 | } 302 | 303 | void SetFontAutoCenter(int on_off) 304 | { 305 | font_datas.autocenter = on_off; 306 | font_datas.autonewline = 0; 307 | } 308 | 309 | void SetFontAutoNewLine(int width) 310 | { 311 | font_datas.autonewline = width; 312 | font_datas.autocenter = 0; 313 | } 314 | 315 | void SetFontZ(float z) 316 | { 317 | font_datas.Z = z; 318 | } 319 | 320 | float GetFontX() 321 | { 322 | return font_datas.X; 323 | } 324 | 325 | float GetFontY() 326 | { 327 | return font_datas.Y; 328 | } 329 | 330 | void SetFontScreenLimits(float width, float height) 331 | { 332 | font_datas.screen_w = width; 333 | font_datas.screen_h = height; 334 | } 335 | 336 | float WidthFromStr(char *str) 337 | { 338 | if( str ==NULL) return 0; 339 | 340 | float w = 0; 341 | 342 | u8 *ustr = (u8 *) str; 343 | 344 | while(*ustr) 345 | w += font_datas.sx * font_datas.fonts[font_datas.current_font].fw[*(ustr++)] / font_datas.fonts[font_datas.current_font].w; 346 | 347 | if(w==0) return (float) display_ttf_string(0, 0, str, 0, 0, font_datas.sx, font_datas.sy); 348 | 349 | return w; 350 | } 351 | 352 | float GetFontHeight() 353 | { 354 | return font_datas.sy; 355 | } 356 | 357 | float GetFontWidth() 358 | { 359 | return font_datas.sx; 360 | } 361 | 362 | #define MOD_FLOAT(x,y) (((float)(((u32) (x)) % y)) / (float) y) 363 | 364 | void DrawChar(float x, float y, float z, u8 chr) 365 | { 366 | float dx = font_datas.sx, dy = font_datas.sy; 367 | float dx2 = (font_datas.sx * font_datas.fonts[font_datas.current_font].fw[chr]) / font_datas.fonts[font_datas.current_font].w; 368 | float dy2 = (float) (font_datas.sy * font_datas.fonts[font_datas.current_font].bh) / (float) font_datas.fonts[font_datas.current_font].h; 369 | 370 | if(font_datas.number_of_fonts <= 0) return; 371 | 372 | if(chr < font_datas.fonts[font_datas.current_font].first_char) return; 373 | 374 | if(font_datas.bkcolor) { 375 | 376 | tiny3d_SetTextureWrap(0, font_datas.rsx_text_bk_offset, 8, 377 | 8, 8 * 2, 378 | TINY3D_TEX_FORMAT_A4R4G4B4, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); 379 | 380 | 381 | tiny3d_SetPolygon(TINY3D_QUADS); 382 | 383 | tiny3d_VertexPos(x , y , z); 384 | tiny3d_VertexColor(font_datas.bkcolor); 385 | tiny3d_VertexTexture(0.0f, 0.0f); 386 | 387 | tiny3d_VertexPos(x + dx2, y , z); 388 | 389 | tiny3d_VertexPos(x + dx2, y + dy2, z); 390 | 391 | tiny3d_VertexPos(x , y + dy2, z); 392 | 393 | tiny3d_End(); 394 | } 395 | 396 | y += (float) (font_datas.fonts[font_datas.current_font].fy[chr] * font_datas.sy) / (float) (font_datas.fonts[font_datas.current_font].h); 397 | 398 | if(chr > font_datas.fonts[font_datas.current_font].last_char) return; 399 | 400 | // Load sprite texture 401 | tiny3d_SetTextureWrap(0, font_datas.fonts[font_datas.current_font].rsx_text_offset + font_datas.fonts[font_datas.current_font].rsx_bytes_per_char 402 | * (chr - font_datas.fonts[font_datas.current_font].first_char), font_datas.fonts[font_datas.current_font].w, 403 | font_datas.fonts[font_datas.current_font].h, font_datas.fonts[font_datas.current_font].w * 404 | ((font_datas.fonts[font_datas.current_font].color_format == TINY3D_TEX_FORMAT_A8R8G8B8) ? 4 : 2), 405 | font_datas.fonts[font_datas.current_font].color_format, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); 406 | 407 | tiny3d_SetPolygon(TINY3D_QUADS); 408 | 409 | tiny3d_VertexPos(x , y , z); 410 | tiny3d_VertexColor(font_datas.color); 411 | tiny3d_VertexTexture(0.0f, 0.0f); 412 | 413 | switch(font_datas.enable_doubletextures) { 414 | case 1: 415 | tiny3d_VertexTexture2(0.0f, 0.0f); 416 | break; 417 | case 2: 418 | tiny3d_VertexTexture2((x)/848.0f, (y)/512.0f); 419 | break; 420 | case 3: 421 | tiny3d_VertexTexture2(MOD_FLOAT(x, font_datas.mod_x), MOD_FLOAT(y, font_datas.mod_y)); 422 | break; 423 | default: 424 | break; 425 | } 426 | 427 | tiny3d_VertexPos(x + dx, y , z); 428 | tiny3d_VertexTexture(0.95f, 0.0f); 429 | 430 | switch(font_datas.enable_doubletextures) { 431 | case 1: 432 | tiny3d_VertexTexture2(0.95f, 0.0f); 433 | break; 434 | case 2: 435 | tiny3d_VertexTexture2((x+dx)/848.0f, y/512.0f); 436 | break; 437 | case 3: 438 | tiny3d_VertexTexture2(MOD_FLOAT(x+dx, font_datas.mod_x), MOD_FLOAT(y, font_datas.mod_y)); 439 | break; 440 | default: 441 | break; 442 | } 443 | 444 | tiny3d_VertexPos(x + dx, y + dy, z); 445 | tiny3d_VertexTexture(0.95f, 0.95f); 446 | 447 | switch(font_datas.enable_doubletextures) { 448 | case 1: 449 | tiny3d_VertexTexture2(0.95f, 0.95f); 450 | break; 451 | case 2: 452 | tiny3d_VertexTexture2((x+dx)/848.0f, (y+dy)/512.0f); 453 | break; 454 | case 3: 455 | tiny3d_VertexTexture2(MOD_FLOAT(x+dx, font_datas.mod_x), MOD_FLOAT(y+dy,font_datas.mod_y)); 456 | break; 457 | default: 458 | break; 459 | } 460 | 461 | tiny3d_VertexPos(x , y + dy, z); 462 | tiny3d_VertexTexture(0.0f, 0.95f); 463 | 464 | switch(font_datas.enable_doubletextures) { 465 | case 1: 466 | tiny3d_VertexTexture2(0.0f, 0.95f); 467 | break; 468 | case 2: 469 | tiny3d_VertexTexture2(x/848.0f, (y+dy)/512.0f); 470 | break; 471 | case 3: 472 | tiny3d_VertexTexture2(MOD_FLOAT(x, font_datas.mod_x), MOD_FLOAT(y+dy, font_datas.mod_y)); 473 | break; 474 | default: 475 | break; 476 | } 477 | 478 | tiny3d_End(); 479 | 480 | } 481 | 482 | static int i_must_break_line(char *str, float x) 483 | { 484 | int xx =0; 485 | 486 | while(*str) { 487 | if(((u8)*str) <= 32) break; 488 | xx += font_datas.sx * font_datas.fonts[font_datas.current_font].fw[((u8)*str)] / font_datas.fonts[font_datas.current_font].w; 489 | str++; 490 | } 491 | 492 | 493 | if(*str && (x+xx) >= font_datas.autonewline) return 1; 494 | 495 | return 0; 496 | } 497 | 498 | float DrawString(float x, float y, char *str) 499 | { 500 | if(y<0) return x; 501 | 502 | if(font_datas.current_font == 8) { 503 | int len; 504 | 505 | set_ttf_window(0, 0, 848, 512, font_datas.autonewline ? WIN_AUTO_LF : 0); 506 | len = display_ttf_string(0, 0, str, 0, 0, font_datas.sx, font_datas.sy); 507 | 508 | if(font_datas.autocenter) { 509 | 510 | x= (font_datas.screen_w - len) / 2; 511 | 512 | } 513 | 514 | if(font_datas.bkcolor) { 515 | 516 | tiny3d_SetTextureWrap(0, font_datas.rsx_text_bk_offset, 8, 517 | 8, 8 * 2, 518 | TINY3D_TEX_FORMAT_A4R4G4B4, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); 519 | 520 | 521 | tiny3d_SetPolygon(TINY3D_QUADS); 522 | 523 | tiny3d_VertexPos(x , y , font_datas.Z); 524 | tiny3d_VertexColor(font_datas.bkcolor); 525 | tiny3d_VertexTexture(0.0f, 0.0f); 526 | 527 | tiny3d_VertexPos(x + (float) len, y , font_datas.Z); 528 | 529 | tiny3d_VertexPos(x + (float) len, y + (float) Y_ttf/*font_datas.sy*/ , font_datas.Z); 530 | 531 | tiny3d_VertexPos(x , y + (float) Y_ttf/*font_datas.sy*/, font_datas.Z); 532 | 533 | tiny3d_End(); 534 | } 535 | 536 | Z_ttf = font_datas.Z; 537 | x = (float) display_ttf_string(x, y, str, font_datas.color, 0, font_datas.sx, font_datas.sy); 538 | Z_ttf = 0.0f; 539 | 540 | font_datas.X = x; font_datas.Y = Y_ttf; 541 | return x; 542 | 543 | } 544 | 545 | if(font_datas.autocenter) { 546 | 547 | x= (font_datas.screen_w - WidthFromStr(str)) / 2; 548 | 549 | } 550 | 551 | while (*str) { 552 | 553 | if(*str == '\n') { 554 | x = 0.0f; 555 | y += font_datas.sy * font_datas.fonts[font_datas.current_font].bh / font_datas.fonts[font_datas.current_font].h; 556 | str++; 557 | continue; 558 | } else { 559 | if(font_datas.autonewline && i_must_break_line(str, x)) { 560 | x = 0.0f; 561 | y += font_datas.sy * font_datas.fonts[font_datas.current_font].bh / font_datas.fonts[font_datas.current_font].h; 562 | } 563 | } 564 | 565 | DrawChar(x, y, font_datas.Z, (u8) *str); 566 | x += font_datas.sx * font_datas.fonts[font_datas.current_font].fw[((u8)*str)] / font_datas.fonts[font_datas.current_font].w; 567 | str++; 568 | } 569 | 570 | font_datas.X = x; font_datas.Y = y; 571 | 572 | return x; 573 | } 574 | 575 | static char buff[4096]; 576 | 577 | float DrawFormatString(float x, float y, char *format, ...) 578 | { 579 | if(y<0) return x; 580 | 581 | char *str = (char *) buff; 582 | va_list opt; 583 | 584 | va_start(opt, format); 585 | vsprintf( (void *) buff, format, opt); 586 | va_end(opt); 587 | 588 | if(font_datas.current_font == 8) { 589 | int len; 590 | 591 | set_ttf_window(0, 0, 848, 512, font_datas.autonewline ? WIN_AUTO_LF : 0); 592 | len = display_ttf_string(0, 0, str, 0, 0, font_datas.sx, font_datas.sy); 593 | 594 | if(font_datas.autocenter) { 595 | 596 | x= (font_datas.screen_w - len) / 2; 597 | 598 | } 599 | 600 | if(font_datas.bkcolor) { 601 | 602 | tiny3d_SetTextureWrap(0, font_datas.rsx_text_bk_offset, 8, 603 | 8, 8 * 2, 604 | TINY3D_TEX_FORMAT_A4R4G4B4, TEXTWRAP_CLAMP, TEXTWRAP_CLAMP, TEXTURE_LINEAR); 605 | 606 | 607 | tiny3d_SetPolygon(TINY3D_QUADS); 608 | 609 | tiny3d_VertexPos(x , y , font_datas.Z); 610 | tiny3d_VertexColor(font_datas.bkcolor); 611 | tiny3d_VertexTexture(0.0f, 0.0f); 612 | 613 | tiny3d_VertexPos(x + (float) len, y , font_datas.Z); 614 | 615 | tiny3d_VertexPos(x + (float) len, y + (float) Y_ttf/*font_datas.sy*/ , font_datas.Z); 616 | 617 | tiny3d_VertexPos(x , y + (float) Y_ttf/*font_datas.sy*/, font_datas.Z); 618 | 619 | tiny3d_End(); 620 | } 621 | 622 | Z_ttf = font_datas.Z; 623 | x = (float) display_ttf_string(x, y, str, font_datas.color, 0, font_datas.sx, font_datas.sy); 624 | Z_ttf = 0.0f; 625 | 626 | font_datas.X = x; font_datas.Y = Y_ttf; 627 | return x; 628 | 629 | } 630 | 631 | if(font_datas.autocenter) { 632 | 633 | x = (font_datas.screen_w - WidthFromStr(str)) / 2; 634 | 635 | } 636 | 637 | while (*str) { 638 | 639 | if(*str == '\n') { 640 | x = 0.0f; 641 | y += font_datas.sy * font_datas.fonts[font_datas.current_font].bh / font_datas.fonts[font_datas.current_font].h; 642 | str++; 643 | continue; 644 | } else { 645 | if(font_datas.autonewline && i_must_break_line(str, x)) { 646 | x = 0.0f; 647 | y += font_datas.sy * font_datas.fonts[font_datas.current_font].bh / font_datas.fonts[font_datas.current_font].h; 648 | } 649 | } 650 | 651 | DrawChar(x, y, font_datas.Z, (u8) *str); 652 | 653 | x += font_datas.sx * font_datas.fonts[font_datas.current_font].fw[((u8)*str)] / font_datas.fonts[font_datas.current_font].w; 654 | str++; 655 | } 656 | 657 | font_datas.X = x; font_datas.Y = y; 658 | 659 | return x; 660 | } 661 | 662 | 663 | -------------------------------------------------------------------------------- /source/fsutil.c: -------------------------------------------------------------------------------- 1 | //fsutil.c 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "ff.h" 19 | #include "fflib.h" 20 | #include "fm.h" 21 | #include "fsutil.h" 22 | #include "console.h" 23 | 24 | //***************************************************************************** 25 | //NTFS 26 | #include "ntfs.h" 27 | 28 | static const DISC_INTERFACE *disc_ntfs[8]= { 29 | &__io_ntfs_usb000, 30 | &__io_ntfs_usb001, 31 | &__io_ntfs_usb002, 32 | &__io_ntfs_usb003, 33 | &__io_ntfs_usb004, 34 | &__io_ntfs_usb005, 35 | &__io_ntfs_usb006, 36 | &__io_ntfs_usb007 37 | }; 38 | // mounts from /dev_usb000 to 007 39 | static ntfs_md *mounts[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; 40 | // 41 | int ntfs_scan_path (struct fm_panel *p); 42 | int ntfs_job_scan (struct fm_job *p, char *path); 43 | //----------------------------------------------------------------------------- 44 | 45 | //sys fs 46 | #define FS_S_IFMT 0170000 47 | #define FS_S_IFDIR 0040000 48 | #define DT_DIR 1 49 | 50 | struct fs_root { 51 | u64 devid; 52 | char *fs; 53 | int fs_type; 54 | int fs_idx; 55 | int fs_parts; 56 | }; 57 | 58 | static struct fs_root rootfs[] = { 59 | //ntfs needs index 0 to 7, move SYS at the end 60 | {0x010300000000000AULL, NULL, FS_TNONE, -1, -1}, 61 | {0x010300000000000BULL, NULL, FS_TNONE, -1, -1}, 62 | {0x010300000000000CULL, NULL, FS_TNONE, -1, -1}, 63 | {0x010300000000000DULL, NULL, FS_TNONE, -1, -1}, 64 | {0x010300000000000EULL, NULL, FS_TNONE, -1, -1}, 65 | {0x010300000000000FULL, NULL, FS_TNONE, -1, -1}, 66 | {0x010300000000001FULL, NULL, FS_TNONE, -1, -1}, 67 | {0x0103000000000020ULL, NULL, FS_TNONE, -1, -1}, 68 | {0x0ULL, "sys:/", FS_TSYS, 0, 0}, 69 | }; 70 | //fs type counters 71 | static int fs_fat_k = 0; 72 | static int fs_ext_k = 0; 73 | static int fs_ntfs_k = 0; 74 | 75 | int sys_scan_path (struct fm_panel *p); 76 | int fat_scan_path (struct fm_panel *p); 77 | 78 | int sys_job_scan (struct fm_job *p, char *path); 79 | int fat_job_scan (struct fm_job *p, char *path); 80 | /* 81 | sysFsGetFreeSize("/dev_hdd0/", &blockSize, &freeSize); 82 | sprintf(filename, "/dev_usb00%c/", 47+find_device); 83 | sysFsGetFreeSize(filename, &blockSize, &freeSize); 84 | if(find_device==11) sprintf(filename, "/dev_bdvd"); 85 | 86 | //dir 87 | sysFSDirent dir; 88 | DIR_ITER *pdir = NULL; 89 | 90 | if(is_ntfs) {pdir = ps3ntfs_diropen(path); if(pdir) ret = 0; else ret = -1; } 91 | else ret=sysLv2FsOpenDir(path, &dfd); 92 | 93 | while ((!is_ntfs && !sysLv2FsReadDir(dfd, &dir, &read)) 94 | || (is_ntfs && ps3ntfs_dirnext(pdir, dir.d_name, &st) == 0)) { 95 | 96 | if(is_ntfs) ps3ntfs_dirclose(pdir); else sysLv2FsCloseDir(dfd); 97 | //file 98 | ret = sysLv2FsOpen(path, 0, &fd, S_IRWXU | S_IRWXG | S_IRWXO, NULL, 0); 99 | ret = sysLv2FsOpen(temp_buffer, SYS_O_WRONLY | SYS_O_CREAT | SYS_O_TRUNC, &fd, 0777, NULL, 0); 100 | if(flags & CPY_FILE1_IS_NTFS) {fd = ps3ntfs_open(path, O_RDONLY, 0);if(fd < 0) ret = -1; else ret = 0;} 101 | 102 | fd2 = ps3ntfs_open(path2, O_WRONLY | O_CREAT | O_TRUNC, 0);if(fd2 < 0) ret = -1; else ret = 0; 103 | ret = sysLv2FsOpen(path2, SYS_O_WRONLY | SYS_O_CREAT | SYS_O_TRUNC, &fd2, 0777, NULL, 0); 104 | sysLv2FsChmod(path2, FS_S_IFMT | 0777); 105 | 106 | {ret = ps3ntfs_write(v->fd, v->mem, v->size); v->readed = (u64) ret; if(ret>0) ret = 0;} 107 | else ret=sysLv2FsWrite(v->fd, v->mem, v->size, &v->readed); 108 | 109 | if(flags & ASYNC_NTFS) ps3ntfs_close(v->fd); else sysLv2FsClose(v->fd); 110 | 111 | */ 112 | // np is normalized path offset, from path fat0:/abc/ means np is 3 such that norm path is path + 3 -> 0:/abc/ 113 | int fs_get_fstype (char *path, int *np) 114 | { 115 | if (!path) 116 | return FS_TNONE; 117 | //FAT/ExFAT path 118 | if (strncmp (path, "fat", 3) == 0) 119 | { 120 | if (np) 121 | *np = 3; 122 | return FS_TFAT; 123 | } 124 | //EXT path 125 | else if (strncmp (path, "ext", 3) == 0) 126 | { 127 | if (np) 128 | *np = 0; //ext and ntfs need this prefix 129 | //return FS_TEXT; 130 | // NTFS driver is covering EXT access 131 | // rest of code can be cleaned-up 132 | return FS_TNTFS; 133 | } 134 | //NTFS path 135 | else if (strncmp (path, "ntfs", 4) == 0) 136 | { 137 | if (np) 138 | *np = 0; //ext and ntfs need this prefix 139 | return FS_TNTFS; 140 | } 141 | //sys path 142 | else if (strncmp (path, "sys:", 4) == 0) 143 | { 144 | if (np) 145 | *np = 4; 146 | return FS_TSYS; 147 | } 148 | // 149 | return FS_TNONE; 150 | } 151 | 152 | int fs_job_scan (struct fm_job *job) 153 | { 154 | if (!job->spath) 155 | { 156 | job->stype = FS_TNONE; 157 | return -1; 158 | } 159 | int npo = 0; 160 | job->stype = fs_get_fstype (job->spath, &npo); 161 | switch (job->stype) 162 | { 163 | //scan FAT/ExFAT path 164 | //if (strncmp (job->spath, "fat", 3) == 0) 165 | case FS_TFAT: 166 | { 167 | FATFS fs; /* Ponter to the filesystem object */ 168 | char *nsrc = job->spath + npo; 169 | int res = f_mount (&fs, nsrc, 0); /* Mount the default drive */ 170 | if (res != FR_OK) 171 | { 172 | NPrintf ("!job:failed mounting fat path %s, res %d\n", job->spath, res); 173 | return res; 174 | } 175 | NPrintf ("job:scanning fat path %s\n", job->spath); 176 | res = fat_job_scan (job, nsrc); 177 | f_mount (NULL, nsrc, 0); /* UnMount the default drive */ 178 | return res; 179 | } 180 | //scan EXT path 181 | //else if (strncmp (job->spath, "ext", 3) == 0) 182 | case FS_TEXT: 183 | { 184 | return 1;//ext_scan_path (p); 185 | } 186 | //scan NTFS path 187 | //else if (strncmp (job->spath, "ntfs", 4) == 0) 188 | case FS_TNTFS: 189 | { 190 | return ntfs_job_scan (job, job->spath); 191 | } 192 | //scan sys path 193 | case FS_TSYS: 194 | { 195 | NPrintf ("job:scanning sys path %s\n", job->spath); 196 | return sys_job_scan (job, job->spath + npo); 197 | } 198 | } 199 | return 0; 200 | } 201 | 202 | //probe for supported FSs on various devices 203 | static int _attach_fs (int k, char *flag, int *fsk, int fst, char *devfs) 204 | { 205 | NPrintf ("_attach_fs on dev %d fs %d knt %d\n", k, fst, *fsk); 206 | rootfs[k].fs = strdup (devfs); 207 | rootfs[k].fs_type = fst; 208 | rootfs[k].fs_idx = *fsk; 209 | // 210 | int lk = *fsk; 211 | *fsk = ++lk; 212 | lk = *flag; 213 | *flag = ++lk; 214 | NPrintf ("_attach_fs on dev %d fs %d knt %d\n", k, fst, *fsk); 215 | // 216 | return 1; 217 | } 218 | 219 | static int _detach_fs (int k, char *flag, int *fsk) 220 | { 221 | NPrintf ("_detach_fs on dev %d fs %d knt %d\n", k, rootfs[k].fs_type, *fsk); 222 | rootfs[k].fs_type = FS_TNONE; 223 | rootfs[k].fs_parts = -1; 224 | rootfs[k].fs_idx = -1; 225 | free (rootfs[k].fs); 226 | rootfs[k].fs = NULL; 227 | // 228 | int lk = *fsk; 229 | *fsk = --lk; 230 | lk = *flag; 231 | *flag = ++lk; 232 | NPrintf ("_detach_fs on dev %d knt %d\n", k, *fsk); 233 | // 234 | return 1; 235 | } 236 | 237 | int rootfs_probe () 238 | { 239 | char devfs[15]; 240 | char flag = 0; //notify caller that there is a change 241 | int k, res; 242 | NPrintf ("rootfs_probe in mounted: %dFAT %dNTFS %dEXT3\n", fs_fat_k, fs_ntfs_k, fs_ext_k); 243 | //check existing for unplug 244 | for (k = 0; k < sizeof (rootfs) / sizeof (struct fs_root); k++) 245 | { 246 | if (rootfs[k].fs && rootfs[k].devid > 0) 247 | { 248 | //are these still plugged in? 249 | NPrintf ("rootfs_probe probing detach on dev %d fs: %s idx %d\n", k, rootfs[k].fs, rootfs[k].fs_idx); 250 | //FAT 251 | if (fs_fat_k && rootfs[k].fs_type == FS_TFAT /*&& !fflib_is_fatfs (rootfs[k].fs + 3)*/) 252 | { 253 | char *path = rootfs[k].fs + 3; 254 | FDIR dir; 255 | FATFS fs; /* Work area (filesystem object) for logical drive */ 256 | if (f_mount (&fs, path, 0) == FR_OK) 257 | { 258 | //todo: maybe use the same approach as in PS3_NTFS_IsInserted 259 | /* 260 | int r; 261 | device_info_t disc_info; 262 | disc_info.unknown03 = 0x12345678; // hack for Iris Manager Disc Less 263 | r = sys_storage_get_device_info (id, &disc_info); 264 | if (r < 0) 265 | { 266 | if (r == 0x80010002) 267 | { 268 | PS3_NTFS_Shutdown (fd); 269 | } 270 | return false; 271 | } 272 | */ 273 | if (f_opendir (&dir, path) == FR_OK) 274 | { 275 | f_closedir (&dir); 276 | f_mount (0, path, 0); 277 | continue; 278 | } 279 | f_mount (0, path, 0); 280 | } 281 | NPrintf ("rootfs_probe detach fat%d: on dev %d fs: %s\n", rootfs[k].fs_idx, k, rootfs[k].fs); 282 | //no longer valid - detach 283 | fflib_detach (rootfs[k].fs_idx); 284 | // 285 | _detach_fs (k, &flag, &fs_fat_k); 286 | continue; 287 | } 288 | //NTFS 289 | if (fs_ntfs_k && rootfs[k].fs_type == FS_TNTFS) 290 | { 291 | if (rootfs[k].fs_parts > 0 && !PS3_NTFS_IsInserted (k)) 292 | { 293 | if (mounts[k]) 294 | { 295 | int j; 296 | for (j = 0; j < rootfs[k].fs_parts; j++) 297 | if ((mounts[k] + j)->name[0]) 298 | { 299 | ntfsUnmount ((mounts[k] + j)->name, true); 300 | (mounts[k] + j)->name[0] = 0; 301 | } 302 | free (mounts[k]); 303 | mounts[k]= NULL; 304 | } 305 | // PS3_NTFS_IsInserted calls PS3_NTFS_Shutdown on failure.. anyway 306 | PS3_NTFS_Shutdown (k); 307 | NPrintf ("rootfs_probe detach NTFS %d on dev %d fs: %s\n", rootfs[k].fs_idx, k, rootfs[k].fs); 308 | //no longer valid - detach 309 | _detach_fs (k, &flag, &fs_ntfs_k); 310 | continue; 311 | } //mount count > 0 312 | } 313 | //EXT 314 | if (fs_ext_k && rootfs[k].fs_type == FS_TEXT) 315 | { 316 | if (0) 317 | { 318 | //no longer valid - detach 319 | _detach_fs (k, &flag, &fs_ext_k); 320 | continue; 321 | } 322 | } 323 | } 324 | } 325 | //check new devices 326 | for (k = 0; k < sizeof (rootfs) / sizeof (struct fs_root); k++) 327 | { 328 | if (rootfs[k].fs == NULL && rootfs[k].devid > 0) 329 | { 330 | //check for new devices connected 331 | NPrintf ("rootfs_probe probing attach on %d for 0x%llx or %lld %d\n", k, rootfs[k].devid, rootfs[k].devid, (rootfs[k].devid<0)); 332 | //probe FAT 333 | res = fflib_attach (fs_fat_k, rootfs[k].devid, 1); 334 | if (0 == res) 335 | { 336 | snprintf (devfs, 14, "fat%d:/", fs_fat_k); 337 | _attach_fs (k, &flag, &fs_fat_k, FS_TFAT, devfs); 338 | NPrintf ("rootfs_probe attach fat%d: on dev %d\n", rootfs[k].fs_idx, k); 339 | //move on, this is taken now 340 | continue; 341 | } 342 | else 343 | { 344 | int res2 = fflib_detach (fs_fat_k); 345 | NPrintf ("!rootfs_probe attach fat%d: on dev %d, res %d, res2 %d\n", fs_fat_k, k, res, res2); 346 | } 347 | //probe NTFS 348 | if (1) 349 | { 350 | int ntfsParts = ntfsMountDevice (disc_ntfs[k], &mounts[k], NTFS_DEFAULT | NTFS_RECOVER); 351 | NPrintf ("rootfs_probe attach ntfs%d: on dev %d, count %d\n", fs_ntfs_k, k, ntfsParts); 352 | if (ntfsParts > 0) 353 | { 354 | rootfs[k].fs_parts = ntfsParts; 355 | //mount ONLY first partition 356 | if((mounts[k])->name[0]) 357 | { 358 | snprintf (devfs, 14, "%s:/", (mounts[k])->name); 359 | _attach_fs (k, &flag, &fs_ntfs_k, FS_TNTFS, devfs); 360 | NPrintf ("rootfs_probe attach ntfs%d: on dev %d as %s\n", rootfs[k].fs_idx, k, rootfs[k].fs); 361 | #if 0 362 | //stat for free space 363 | struct statvfs vfs; 364 | u64 freeSpace = 0; 365 | snprintf (devfs, 14, "/%s:/", (mounts[k])->name); 366 | if (!ps3ntfs_statvfs (devfs, &vfs) < 0) 367 | freeSpace = (((u64)vfs.f_bsize * vfs.f_bfree)); 368 | NPrintf ("rootfs_probe attach ntfs%d: on dev %d as %s, free %lluMB\n", rootfs[k].fs_idx, k, rootfs[k].fs, freeSpace/MBSZ); 369 | #endif 370 | } 371 | //move on, this is taken now 372 | continue; 373 | } 374 | } 375 | //probe EXT 376 | } //if nothing is mounted on the USB drive 377 | } 378 | // 379 | NPrintf ("rootfs_probe out mounted: %dFAT %dNTFS %dEXT3\n", fs_fat_k, fs_ntfs_k, fs_ext_k); 380 | // 381 | return flag; 382 | } 383 | 384 | int root_scan_path (struct fm_panel *p) 385 | { 386 | //probe rootfs devices - done in app update by mount monitoring 387 | //rootfs_probe (); 388 | // 389 | int k; 390 | for (k = 0; k < sizeof (rootfs) / sizeof (struct fs_root); k++) 391 | { 392 | if (rootfs[k].fs) 393 | fm_panel_add (p, rootfs[k].fs, 1, 0); 394 | } 395 | return 0; 396 | } 397 | 398 | int fs_path_scan (struct fm_panel *p) 399 | { 400 | if (!p->path) 401 | { 402 | p->fs_type = FS_TNONE; 403 | return root_scan_path (p); 404 | } 405 | p->fs_type = fs_get_fstype (p->path, NULL); 406 | switch (p->fs_type) 407 | { 408 | //scan FAT/ExFAT path 409 | //if (strncmp (p->path, "fat", 3) == 0) 410 | case FS_TFAT: 411 | { 412 | NPrintf ("scanning fat path %s\n", p->path); 413 | return fat_scan_path (p); 414 | } 415 | //scan EXT path 416 | //else if (strncmp (p->path, "ext", 3) == 0) 417 | case FS_TEXT: 418 | { 419 | return 1;//ext_scan_path (p); 420 | } 421 | //scan NTFS path 422 | //else if (strncmp (p->path, "ntfs", 4) == 0) 423 | case FS_TNTFS: 424 | { 425 | return ntfs_scan_path (p); 426 | } 427 | //scan sys path 428 | case FS_TSYS: 429 | { 430 | NPrintf ("scanning sys path %s\n", p->path); 431 | return sys_scan_path (p); 432 | } 433 | } 434 | return 0; 435 | } 436 | 437 | int sys_scan_path (struct fm_panel *p) 438 | { 439 | char lp[256]; 440 | int dfd; 441 | u64 read; 442 | sysFSDirent dir; 443 | char *lpath = p->path + 4; //from 'sys:/' to '/' 444 | int res = sysLv2FsOpenDir (lpath, &dfd); 445 | if (res) 446 | { 447 | NPrintf ("!failed sysLv2FsOpenDir path %s, res %d\n", p->path, res); 448 | return res; 449 | } 450 | for (; !sysLv2FsReadDir (dfd, &dir, &read); ) 451 | { 452 | if (!read) 453 | break; 454 | if (!strcmp (dir.d_name, ".") || !strcmp (dir.d_name, "..")) 455 | continue; 456 | // 457 | if (dir.d_type & DT_DIR) 458 | { 459 | fm_panel_add (p, dir.d_name, 1, 0); 460 | } 461 | else 462 | { 463 | snprintf (lp, 255, "%s/%s", lpath, dir.d_name); 464 | sysFSStat stat; 465 | res = sysLv2FsStat (lp, &stat); 466 | //NPrintf ("sysLv2FsStat for '%s', res %d\n", lp, res); 467 | if (res >= 0) 468 | fm_panel_add (p, dir.d_name, 0, stat.st_size); 469 | else 470 | fm_panel_add (p, dir.d_name, 0, -1); 471 | } 472 | } 473 | sysLv2FsCloseDir (dfd); 474 | // 475 | return 0; 476 | } 477 | 478 | int fat_scan_path (struct fm_panel *p) 479 | { 480 | char lp[256]; 481 | FRESULT res = 0; 482 | FDIR dir; 483 | FILINFO fno; 484 | FATFS fs; /* Ponter to the filesystem object */ 485 | char *lpath = p->path + 3; 486 | res = f_mount (&fs, lpath, 0); /* Mount the default drive */ 487 | if (res != FR_OK) 488 | return res; 489 | //strip the 'fat' preffix on path from 'fat0:/' to '0:/' 490 | res = f_opendir (&dir, lpath); /* Open the directory */ 491 | NPrintf ("scanning fat path %s, res %d\n", lpath, res); 492 | // 493 | if (res == FR_OK) 494 | { 495 | for (;;) 496 | { 497 | FRESULT res1 = f_readdir (&dir, &fno); /* Read a directory item */ 498 | if (res1 != FR_OK || fno.fname[0] == 0) 499 | break; /* Break on error or end of dir */ 500 | if (fno.fattrib & AM_DIR) 501 | { /* It is a directory */ 502 | fm_panel_add (p, fno.fname, 1, 0); 503 | } 504 | else 505 | { /* It is a file. */ 506 | snprintf (lp, 255, "%s/%s", lpath, fno.fname); 507 | //NPrintf ("FAT f_stat for '%s', res %d\n", lp, res); 508 | if (f_stat (lp, &fno) == FR_OK) 509 | fm_panel_add (p, fno.fname, 0, fno.fsize); 510 | else 511 | fm_panel_add (p, fno.fname, 0, -1); 512 | } 513 | } 514 | f_closedir (&dir); 515 | } 516 | else 517 | { 518 | ;//DPrintf("!unable to open path '%s' result %d\n", path, res); 519 | } 520 | f_mount (NULL, lpath, 0); /* UnMount the default drive */ 521 | // 522 | return res; 523 | } 524 | 525 | int ntfs_scan_path (struct fm_panel *p) 526 | { 527 | char lp[256]; 528 | DIR_ITER *pdir = NULL; 529 | sysFSDirent dir; 530 | struct stat st; 531 | //strip the 'fat' preffix on path from 'fat0:/' to '0:/' 532 | pdir = ps3ntfs_diropen (p->path); 533 | NPrintf ("scanning ntfs path %s, res %d\n", p->path, pdir); 534 | // 535 | if (pdir) 536 | { 537 | for (;;) 538 | { 539 | if (ps3ntfs_dirnext (pdir, dir.d_name, &st)) 540 | break; // Break on error or end of dir 541 | //skip parent and child listing 542 | if (!strcmp(dir.d_name, ".") || !strcmp(dir.d_name, "..")) 543 | continue; 544 | if (S_ISDIR(st.st_mode)) 545 | { 546 | // It is a directory 547 | fm_panel_add (p, dir.d_name, 1, 0); 548 | } 549 | else 550 | { 551 | // It is a file 552 | snprintf (lp, 255, "%s/%s", p->path, dir.d_name); 553 | //NPrintf ("FAT f_stat for '%s', res %d\n", lp, res); 554 | if (ps3ntfs_stat (lp, &st) < 0) 555 | fm_panel_add (p, dir.d_name, 0, -1); 556 | else 557 | fm_panel_add (p, dir.d_name, 0, st.st_size); 558 | } 559 | } 560 | ps3ntfs_dirclose (pdir); 561 | } 562 | else 563 | { 564 | ;//DPrintf("!unable to open path '%s' result %d\n", path, res); 565 | } 566 | // 567 | return 0; 568 | } 569 | 570 | int sys_job_scan (struct fm_job *p, char *path) 571 | { 572 | char lp[256]; 573 | int dfd; 574 | u64 read; 575 | sysFSDirent dir; 576 | sysFSStat stat; 577 | int res = sysLv2FsOpenDir (path, &dfd); 578 | if (res) 579 | { 580 | //NPrintf ("!failed sysLv2FsOpenDir path %s, res %d\n", path, res); 581 | //add file 582 | res = sysLv2FsStat (path, &stat); 583 | //NPrintf ("sysLv2FsStat for '%s', res %d\n", lp, res); 584 | if (res >= 0) 585 | //fm_job_add (p, dir.d_name, 0, stat.st_size); 586 | fm_job_add (p, path, 0, stat.st_size); 587 | return res; 588 | } 589 | //add dir 590 | fm_job_add (p, path, 1, 0); 591 | // 592 | for (; !sysLv2FsReadDir (dfd, &dir, &read); ) 593 | { 594 | if (!read) 595 | break; 596 | if (!strcmp (dir.d_name, ".") || !strcmp (dir.d_name, "..")) 597 | continue; 598 | // 599 | snprintf (lp, 255, "%s/%s", path, dir.d_name); 600 | if (dir.d_type & DT_DIR) 601 | { 602 | //fm_job_add (p, dir.d_name, 1, 0); 603 | //fm_job_add (p, lp, 1, 0); 604 | //recurse 605 | sys_job_scan (p, lp); 606 | } 607 | else 608 | { 609 | res = sysLv2FsStat (lp, &stat); 610 | //NPrintf ("sysLv2FsStat for '%s', res %d\n", lp, res); 611 | if (res >= 0) 612 | //fm_job_add (p, dir.d_name, 0, stat.st_size); 613 | fm_job_add (p, lp, 0, stat.st_size); 614 | else 615 | //fm_job_add (p, dir.d_name, 0, -1); 616 | fm_job_add (p, lp, 0, -1); 617 | } 618 | } 619 | sysLv2FsCloseDir (dfd); 620 | // 621 | return 0; 622 | } 623 | 624 | int fat_job_scan (struct fm_job *p, char *path) 625 | { 626 | char lp[256]; 627 | FRESULT res; 628 | FDIR dir; 629 | FILINFO fno; 630 | #if 1 631 | //file or dir? 632 | res = f_stat (path, &fno); 633 | if (res != FR_OK) 634 | { 635 | NPrintf ("!job:f_stat fat path %s, res %d\n", path, res); 636 | return res; 637 | } 638 | if (fno.fattrib & AM_DIR) 639 | { 640 | //add dir 641 | fm_job_add (p, path, 1, 0); 642 | } 643 | else 644 | { 645 | //add file 646 | fm_job_add (p, path, 0, fno.fsize); 647 | f_mount (NULL, path, 0); /* UnMount the default drive */ 648 | // 649 | return res; 650 | } 651 | #endif 652 | //open dir 653 | res = f_opendir (&dir, path); /* Open the directory */ 654 | NPrintf ("job:scanning fat path %s, res %d\n", path, res); 655 | // 656 | if (res == FR_OK) 657 | { 658 | for (;;) 659 | { 660 | FRESULT res1 = f_readdir (&dir, &fno); /* Read a directory item */ 661 | if (res1 != FR_OK || fno.fname[0] == 0) 662 | { 663 | //NPrintf ("job:done f_readdir fat path %s, res1 %d\n", path, res1); 664 | break; /* Break on error or end of dir */ 665 | } 666 | snprintf (lp, 255, "%s/%s", path, fno.fname); 667 | //NPrintf ("job:processing %s\n", lp); 668 | if (fno.fattrib & AM_DIR) 669 | { /* It is a directory */ 670 | //fm_job_add (p, fno.fname, 1, 0); 671 | //fm_job_add (p, lp, 1, 0); 672 | //recurse 673 | fat_job_scan (p, lp); 674 | } 675 | else 676 | { /* It is a file. */ 677 | //NPrintf ("FAT f_stat for '%s', res %d\n", lp, res); 678 | if (f_stat (lp, &fno) == FR_OK) 679 | //fm_job_add (p, fno.fname, 0, fno.fsize); 680 | fm_job_add (p, lp, 0, fno.fsize); 681 | else 682 | //fm_job_add (p, fno.fname, 0, -1); 683 | fm_job_add (p, lp, 0, -1); 684 | } 685 | } 686 | f_closedir (&dir); 687 | } 688 | else 689 | { 690 | NPrintf("job:!unable to open path '%s' result %d\n", path, res); 691 | } 692 | // 693 | return res; 694 | } 695 | 696 | 697 | int ntfs_job_scan (struct fm_job *p, char *path) 698 | { 699 | char lp[256]; 700 | DIR_ITER *pdir = NULL; 701 | sysFSDirent dir; 702 | struct stat st; 703 | int res; 704 | #if 1 705 | //file or dir? 706 | if ((res = ps3ntfs_stat (path, &st)) < 0) 707 | { 708 | NPrintf ("!job:ps3ntfs_stat NTFS path %s, res %d\n", path, res); 709 | return res; 710 | } 711 | if (S_ISDIR (st.st_mode)) 712 | { 713 | //add dir 714 | fm_job_add (p, path, 1, 0); 715 | } 716 | else 717 | { 718 | //add file 719 | fm_job_add (p, path, 0, st.st_size); 720 | return res; 721 | } 722 | #endif 723 | //open dir 724 | pdir = ps3ntfs_diropen (path); 725 | NPrintf ("job:scanning NTFS path %s, res %d\n", path, pdir); 726 | // 727 | if (pdir) 728 | { 729 | for (;;) 730 | { 731 | if (ps3ntfs_dirnext (pdir, dir.d_name, &st)) 732 | break; // Break on error or end of dir 733 | //skip parent and child listing 734 | if (!strcmp(dir.d_name, ".") || !strcmp(dir.d_name, "..")) 735 | continue; 736 | snprintf (lp, 255, "%s/%s", path, dir.d_name); 737 | if (S_ISDIR (st.st_mode)) 738 | { 739 | // It is a directory - recurse call 740 | ntfs_job_scan (p, lp); 741 | } 742 | else 743 | { 744 | // It is a file 745 | if (ps3ntfs_stat (lp, &st) < 0) 746 | fm_job_add (p, lp, 0, -1); 747 | else 748 | fm_job_add (p, lp, 0, st.st_size); 749 | } 750 | } 751 | ps3ntfs_dirclose (pdir); 752 | } 753 | else 754 | { 755 | NPrintf("job:!unable to open NTFS path '%s' result %d\n", path, pdir); 756 | } 757 | // 758 | return res; 759 | } 760 | --------------------------------------------------------------------------------