├── .gitignore
├── sce_sys
├── icon0.png
└── livearea
│ └── contents
│ ├── bg.png
│ ├── startup.png
│ └── template.xml
├── modules
├── patch
│ ├── exports.yml
│ ├── CMakeLists.txt
│ └── main.c
├── user
│ ├── exports.yml
│ ├── CMakeLists.txt
│ ├── vitashell_user.h
│ └── main.c
└── kernel
│ ├── exports.yml
│ ├── CMakeLists.txt
│ ├── vitashell_kernel.h
│ └── main.c
├── src
├── debugScreen_custom.h
├── pfs.h
├── init.h
├── vitashell_user.h
├── main.h
├── vitashell_kernel.h
├── strnatcmp.h
├── vitashell_error.h
├── debugScreen.h
├── pfs.c
├── main.c
├── init.c
├── file.h
├── strnatcmp.c
├── debugScreenFont.c
├── file.c
└── debugScreen.c
├── README.md
├── CMakeLists.txt
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | build
3 |
--------------------------------------------------------------------------------
/sce_sys/icon0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cy33hc/copyicons/HEAD/sce_sys/icon0.png
--------------------------------------------------------------------------------
/sce_sys/livearea/contents/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cy33hc/copyicons/HEAD/sce_sys/livearea/contents/bg.png
--------------------------------------------------------------------------------
/sce_sys/livearea/contents/startup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cy33hc/copyicons/HEAD/sce_sys/livearea/contents/startup.png
--------------------------------------------------------------------------------
/modules/patch/exports.yml:
--------------------------------------------------------------------------------
1 | VitaShellPatch:
2 | attributes: 0
3 | version:
4 | major: 1
5 | minor: 0
6 | main:
7 | start: module_start
8 | stop: module_stop
9 |
--------------------------------------------------------------------------------
/sce_sys/livearea/contents/template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | bg.png
6 |
7 |
8 |
9 | startup.png
10 |
11 |
12 |
--------------------------------------------------------------------------------
/modules/user/exports.yml:
--------------------------------------------------------------------------------
1 | VitaShellUser:
2 | attributes: 0
3 | version:
4 | major: 1
5 | minor: 0
6 | main:
7 | start: module_start
8 | stop: module_stop
9 | modules:
10 | VitaShellUserLibrary:
11 | syscall: false
12 | functions:
13 | - shellUserIsUx0Redirected
14 | - shellUserRedirectUx0
15 | - shellUserMountById
16 | - shellUserGetRifVitaKey
17 |
--------------------------------------------------------------------------------
/modules/kernel/exports.yml:
--------------------------------------------------------------------------------
1 | VitaShellKernel2:
2 | attributes: 0
3 | version:
4 | major: 1
5 | minor: 0
6 | main:
7 | start: module_start
8 | stop: module_stop
9 | modules:
10 | VitaShellKernel2Library:
11 | syscall: true
12 | functions:
13 | - shellKernelIsUx0Redirected
14 | - shellKernelRedirectUx0
15 | - shellKernelMountById
16 | - shellKernelGetRifVitaKey
17 |
--------------------------------------------------------------------------------
/modules/patch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8)
2 |
3 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4 | if(DEFINED ENV{VITASDK})
5 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
6 | else()
7 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
8 | endif()
9 | endif()
10 |
11 | project(patch)
12 | include("${VITASDK}/share/vita.cmake" REQUIRED)
13 |
14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
16 |
17 | add_executable(patch
18 | main.c
19 | )
20 |
21 | target_link_libraries(patch
22 | taihenForKernel_stub
23 | )
24 |
25 | vita_create_self(patch.skprx patch CONFIG exports.yml UNSAFE)
26 |
--------------------------------------------------------------------------------
/src/debugScreen_custom.h:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG_SCREEN_CUSTOM_H
2 | #define DEBUG_SCREEN_CUSTOM_H
3 |
4 | //#define SCREEN_TAB_SIZE (8)
5 |
6 | // backward compatibility for sources based on older Vita SDK versions
7 | //#define DEBUG_SCREEN_CODE_INCLUDE // not recommended for your own projects, but for sake of backward compatibility
8 | #define psvDebugScreenSetFgColor(rgb) psvDebugScreenPrintf("\e[38;2;%lu;%lu;%lum", ((uint32_t)(rgb)>>16)&0xFF, ((uint32_t)(rgb)>>8)&0xFF, (uint32_t)(rgb)&0xFF)
9 | #define psvDebugScreenSetBgColor(rgb) psvDebugScreenPrintf("\e[48;2;%lu;%lu;%lum", ((uint32_t)(rgb)>>16)&0xFF, ((uint32_t)(rgb)>>8)&0xFF, (uint32_t)(rgb)&0xFF)
10 | #define psvDebugScreenClear(rgb) psvDebugScreenSetBgColor(rgb); psvDebugScreenPuts("\e[H\e[2J")
11 |
12 | // custom changes for non-Vita builds
13 | #ifndef __vita__
14 | #define psvDebugScreenInitReplacement(...) setvbuf(stdout,NULL,_IONBF,0)
15 | #endif
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/src/pfs.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __PFS_H__
20 | #define __PFS_H__
21 |
22 | #define MAX_PATH_LENGTH 1024
23 | #define MAX_MOUNT_POINT_LENGTH 16
24 |
25 | int pfsMount(const char *path);
26 | int pfsUmount();
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/modules/user/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8)
2 |
3 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4 | if(DEFINED ENV{VITASDK})
5 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
6 | else()
7 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
8 | endif()
9 | endif()
10 |
11 | project(user)
12 | include("${VITASDK}/share/vita.cmake" REQUIRED)
13 |
14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
16 |
17 | include_directories(
18 | ../kernel
19 | )
20 |
21 | add_executable(user
22 | main.c
23 | )
24 |
25 | add_dependencies(user vitashell_kernel_stubs)
26 |
27 | target_link_libraries(user
28 | ${CMAKE_CURRENT_BINARY_DIR}/../kernel/libVitaShellKernel2_stub.a
29 | SceLibKernel_stub
30 | SceIofilemgr_stub
31 | )
32 |
33 | vita_create_self(user.suprx user CONFIG exports.yml UNSAFE)
34 |
35 | vita_create_stubs(vitashell_user_stubs user exports.yml)
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # copyicons
2 |
3 | This application is used for bulk copying of icon0.png/pic0.png from the ux0:app/GAME_ID/sce_sys to the ur0:appmeta/GAME_ID folder
4 |
5 | The psvita can only load 500 bubbles. If you have more then 500 apps/games installed. The vita will not create the icon0.png and pic0.png files in the ur0:appmeta folder for those games that don't have bubbles.
6 |
7 | This is used in conjuction with my Launcher app https://github.com/cy33hc/vita-launcher for getting icons to display for the games.
8 |
9 | ## Features
10 |
11 | 1. Decrypt the icon0.png/pic0.png and copy to ur0:appmeta.
12 | 2. Like mentioned this app scans every game in the ux0:app folder and copies the icon0.png/pic0.png if it's not found in ur0:appmeta
13 |
14 | ## Controls
15 | There are no controls. Just run the app and wait for it to complete. Progress is shown on the screen.
16 |
17 | ## Credits
18 | Thx to theFlow for Vitashell. I had copied the modules from Vitashell needed to pfs mount the game to decypt the content.
19 | https://github.com/TheOfficialFloW/VitaShell
20 |
--------------------------------------------------------------------------------
/modules/kernel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8)
2 |
3 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4 | if(DEFINED ENV{VITASDK})
5 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
6 | else()
7 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
8 | endif()
9 | endif()
10 |
11 | project(kernel)
12 | include("${VITASDK}/share/vita.cmake" REQUIRED)
13 |
14 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
16 |
17 | add_executable(kernel
18 | main.c
19 | )
20 |
21 | target_link_libraries(kernel
22 | SceIofilemgrForDriver_stub
23 | SceSysclibForDriver_stub
24 | SceSysmemForDriver_stub
25 | SceModulemgrForDriver_stub
26 | SceThreadmgrForDriver_stub
27 | SceProcessmgrForDriver_stub
28 | SceNpDrmForDriver_stub
29 | taihenForKernel_stub
30 | taihenModuleUtils_stub
31 | )
32 |
33 | vita_create_self(kernel.skprx kernel CONFIG exports.yml UNSAFE)
34 |
35 | vita_create_stubs(vitashell_kernel_stubs kernel exports.yml KERNEL)
36 |
--------------------------------------------------------------------------------
/src/init.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __INIT_H__
20 | #define __INIT_H__
21 |
22 | typedef struct {
23 | const char *path;
24 | void *buffer;
25 | int size;
26 | int replace;
27 | } DefaultFile;
28 |
29 | extern int is_safe_mode;
30 |
31 | extern SceUID kernel_modid, user_modid;
32 |
33 | void initCopyIcons();
34 | void finishCopyIcons();
35 | int WriteFile(const char *file, const void *buf, int size);
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/src/vitashell_user.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __VITASHELL_USER_H__
20 | #define __VITASHELL_USER_H__
21 |
22 | #include "vitashell_kernel.h"
23 |
24 | int shellUserIsUx0Redirected(const char *blkdev, const char *blkdev2);
25 | int shellUserRedirectUx0(const char *blkdev, const char *blkdev2);
26 | int shellUserMountById(ShellMountIdArgs *args);
27 | int shellUserGetRifVitaKey(const void *license_buf, void *klicensee);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/modules/user/vitashell_user.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __VITASHELL_USER_H__
20 | #define __VITASHELL_USER_H__
21 |
22 | #include "vitashell_kernel.h"
23 |
24 | int shellUserIsUx0Redirected(const char *blkdev, const char *blkdev2);
25 | int shellUserRedirectUx0(const char *blkdev, const char *blkdev2);
26 | int shellUserMountById(ShellMountIdArgs *args);
27 | int shellUserGetRifVitaKey(const void *license_buf, void *klicensee);
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/src/main.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __MAIN_H__
20 | #define __MAIN_H__
21 |
22 | #include
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | #include
38 | #include
39 | #include "vitashell_error.h"
40 |
41 | #define VITASHELL_TITLEID "VITASHELL"
42 |
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/src/vitashell_kernel.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __VITASHELL_KERNEL_H__
20 | #define __VITASHELL_KERNEL_H__
21 |
22 | typedef struct {
23 | int id;
24 | const char *process_titleid;
25 | const char *path;
26 | const char *desired_mount_point;
27 | const void *klicensee;
28 | char *mount_point;
29 | } ShellMountIdArgs;
30 |
31 | int shellKernelIsUx0Redirected(const char *blkdev, const char *blkdev2);
32 | int shellKernelRedirectUx0(const char *blkdev, const char *blkdev2);
33 | int shellKernelMountById(ShellMountIdArgs *args);
34 | int shellKernelGetRifVitaKey(const void *license_buf, void *klicensee);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/modules/kernel/vitashell_kernel.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __VITASHELL_KERNEL_H__
20 | #define __VITASHELL_KERNEL_H__
21 |
22 | typedef struct {
23 | int id;
24 | const char *process_titleid;
25 | const char *path;
26 | const char *desired_mount_point;
27 | const void *klicensee;
28 | char *mount_point;
29 | } ShellMountIdArgs;
30 |
31 | int shellKernelIsUx0Redirected(const char *blkdev, const char *blkdev2);
32 | int shellKernelRedirectUx0(const char *blkdev, const char *blkdev2);
33 | int shellKernelMountById(ShellMountIdArgs *args);
34 | int shellKernelGetRifVitaKey(const void *license_buf, void *klicensee);
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/src/strnatcmp.h:
--------------------------------------------------------------------------------
1 | /* -*- mode: c; c-file-style: "k&r" -*-
2 |
3 | strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
4 | Copyright (C) 2000, 2004 by Martin Pool
5 |
6 | This software is provided 'as-is', without any express or implied
7 | warranty. In no event will the authors be held liable for any damages
8 | arising from the use of this software.
9 |
10 | Permission is granted to anyone to use this software for any purpose,
11 | including commercial applications, and to alter it and redistribute it
12 | freely, subject to the following restrictions:
13 |
14 | 1. The origin of this software must not be misrepresented; you must not
15 | claim that you wrote the original software. If you use this software
16 | in a product, an acknowledgment in the product documentation would be
17 | appreciated but is not required.
18 | 2. Altered source versions must be plainly marked as such, and must not be
19 | misrepresented as being the original software.
20 | 3. This notice may not be removed or altered from any source distribution.
21 | */
22 |
23 |
24 | /* CUSTOMIZATION SECTION
25 | *
26 | * You can change this typedef, but must then also change the inline
27 | * functions in strnatcmp.c */
28 | typedef char nat_char;
29 |
30 | int strnatcmp(nat_char const *a, nat_char const *b);
31 | int strnatcasecmp(nat_char const *a, nat_char const *b);
32 |
--------------------------------------------------------------------------------
/modules/user/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "vitashell_user.h"
28 |
29 | int shellUserIsUx0Redirected(const char *blkdev, const char *blkdev2) {
30 | return shellKernelIsUx0Redirected(blkdev, blkdev2);
31 | }
32 |
33 | int shellUserRedirectUx0(const char *blkdev, const char *blkdev2) {
34 | return shellKernelRedirectUx0(blkdev, blkdev2);
35 | }
36 |
37 | int shellUserMountById(ShellMountIdArgs *args) {
38 | return shellKernelMountById(args);
39 | }
40 |
41 | int shellUserGetRifVitaKey(const void *license_buf, void *klicensee) {
42 | return shellKernelGetRifVitaKey(license_buf, klicensee);
43 | }
44 |
45 | void _start() __attribute__ ((weak, alias("module_start")));
46 | int module_start(SceSize args, void *argp) {
47 | return SCE_KERNEL_START_SUCCESS;
48 | }
49 |
50 | int module_stop(SceSize args, void *argp) {
51 | return SCE_KERNEL_STOP_SUCCESS;
52 | }
53 |
--------------------------------------------------------------------------------
/src/vitashell_error.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __VITASHELL_ERROR_H__
20 | #define __VITASHELL_ERROR_H__
21 |
22 | enum VitaShellErrors {
23 | VITASHELL_ERROR_INTERNAL = 0xF0010000,
24 | VITASHELL_ERROR_NO_MEMORY = 0xF0010001,
25 | VITASHELL_ERROR_NOT_FOUND = 0xF0010002,
26 | VITASHELL_ERROR_INVALID_ARGUMENT = 0xF0010003,
27 | VITASHELL_ERROR_INVALID_MAGIC = 0xF0010004,
28 | VITASHELL_ERROR_INVALID_TYPE = 0xF0010005,
29 | VITASHELL_ERROR_ILLEGAL_ADDR = 0xF0010006,
30 | VITASHELL_ERROR_ALREADY_RUNNING = 0xF0010007,
31 | VITASHELL_ERROR_NOT_RUNNING = 0xF0010008,
32 |
33 | VITASHELL_ERROR_SRC_AND_DST_IDENTICAL = 0xF0020000,
34 | VITASHELL_ERROR_DST_IS_SUBFOLDER_OF_SRC = 0xF0020001,
35 |
36 | VITASHELL_ERROR_INVALID_TITLEID = 0xF0030000,
37 |
38 | VITASHELL_ERROR_SYMLINK_INVALID_PATH = 0xF0040000,
39 | VITASHELL_ERROR_SYMLINK_CANT_RESOLVE_BASEDIR = 0xF0040001,
40 | VITASHELL_ERROR_SYMLINK_CANT_RESOLVE_FILENAME = 0xF0040002,
41 | VITASHELL_ERROR_SYMLINK_INTERNAL = 0xF0040003,
42 |
43 | VITASHELL_ERROR_NAVIGATION = 0xF0050000,
44 |
45 |
46 |
47 |
48 | };
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/src/debugScreen.h:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG_SCREEN_H
2 | #define DEBUG_SCREEN_H
3 |
4 | #include "debugScreen_custom.h"
5 |
6 | typedef struct ColorState {
7 | int fgTrueColorFlag; // flag if truecolors or ANSI/VTERM/GREYSCALE colors are used
8 | int bgTrueColorFlag; // flag if truecolors or ANSI/VTERM/GREYSCALE colors are used
9 | // truecolors
10 | uint32_t fgTrueColor; // color in RGB (internal BGR)
11 | uint32_t bgTrueColor; // color in RGB (internal BGR)
12 | // ANSI/VTERM/GREYSCALE colors
13 | unsigned char fgIndex; // ANSI/VTERM/GREYSCALE color code (0-255)
14 | unsigned char fgIntensity; // 22=normal, 1=increased ("bright"), 2=decreased ("dark")
15 | unsigned char bgIndex; // ANSI/VTERM/GREYSCALE color code (0-255)
16 | unsigned char bgIntensity; // 22=normal, 1=increased ("bright")
17 | int inversion; // flag if bg/fg colors are inverted
18 |
19 | // default colors (ANSI/VTERM/GREYSCALE)
20 | unsigned char fgIndexDefault; // default ANSI/VTERM/GREYSCALE color code
21 | unsigned char fgIntensityDefault; // 22=normal, 1=increased, 2=decreased
22 | unsigned char bgIndexDefault; // default ANSI/VTERM/GREYSCALE color code
23 | unsigned char bgIntensityDefault; // 22=normal, 1=increased
24 | int inversionDefault; // flag if bg/fg colors are inverted
25 |
26 | // current colors (e.g. inverted)
27 | uint32_t color_fg; // color in RGB (internal BGR)
28 | uint32_t color_bg; // color in RGB (internal BGR)
29 | } ColorState;
30 |
31 | typedef struct PsvDebugScreenFont {
32 | unsigned char *glyphs, width, height, first, last, size_w, size_h; // only values 0-255
33 | } PsvDebugScreenFont;
34 |
35 | #define SCREEN_WIDTH (960) // screen resolution x
36 | #define SCREEN_HEIGHT (544) // screen resolution y
37 |
38 | #ifdef DEBUG_SCREEN_CODE_INCLUDE // not recommended for your own projects, but for sake of backward compatibility
39 | #include "debugScreen.c"
40 | #else
41 | #ifdef __cplusplus
42 | extern "C" {
43 | #endif
44 | int psvDebugScreenInit();
45 | int psvDebugScreenPuts(const char * _text);
46 | int psvDebugScreenPrintf(const char *format, ...);
47 | void psvDebugScreenGetColorStateCopy(ColorState *copy);
48 | void psvDebugScreenGetCoordsXY(int *x, int *y);
49 | void psvDebugScreenSetCoordsXY(int *x, int *y);
50 | PsvDebugScreenFont *psvDebugScreenGetFont(void);
51 | PsvDebugScreenFont *psvDebugScreenSetFont(PsvDebugScreenFont *font);
52 | PsvDebugScreenFont *psvDebugScreenScaleFont2x(PsvDebugScreenFont *source_font);
53 | #ifdef __cplusplus
54 | }
55 | #endif
56 | #endif
57 |
58 | #endif /* DEBUG_SCREEN_H */
59 |
--------------------------------------------------------------------------------
/src/pfs.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include "main.h"
20 | #include "pfs.h"
21 | #include "vitashell_user.h"
22 |
23 | /*
24 | SceAppMgr mount IDs:
25 | 0x64: ux0:picture
26 | 0x65: ur0:user/00/psnfriend
27 | 0x66: ur0:user/00/psnmsg
28 | 0x69: ux0:music
29 | 0x6E: ux0:appmeta
30 | 0xC8: ur0:temp/sqlite
31 | 0xCD: ux0:cache
32 | 0x12E: ur0:user/00/trophy/data/sce_trop
33 | 0x12F: ur0:user/00/trophy/data
34 | 0x3E8: ux0:app, vs0:app, gro0:app
35 | 0x3E9: ux0:patch
36 | 0x3EB: ?
37 | 0x3EA: ux0:addcont
38 | 0x3EC: ux0:theme
39 | 0x3ED: ux0:user/00/savedata
40 | 0x3EE: ur0:user/00/savedata
41 | 0x3EF: vs0:sys/external
42 | 0x3F0: vs0:data/external
43 | */
44 |
45 | char pfs_mounted_path[MAX_PATH_LENGTH];
46 | char pfs_mount_point[MAX_MOUNT_POINT_LENGTH];
47 | int read_only;
48 |
49 | int known_pfs_ids[] = {
50 | 0x6E,
51 | 0x12E,
52 | 0x12F,
53 | 0x3ED,
54 | };
55 |
56 | int pfsMount(const char *path) {
57 | int res;
58 | char klicensee[0x10];
59 | ShellMountIdArgs args;
60 |
61 | memset(klicensee, 0, sizeof(klicensee));
62 |
63 | args.process_titleid = "COPYICONS_TITLEID";
64 | args.path = path;
65 | args.desired_mount_point = NULL;
66 | args.klicensee = klicensee;
67 | args.mount_point = pfs_mount_point;
68 |
69 | read_only = 0;
70 |
71 | int i;
72 | for (i = 0; i < sizeof(known_pfs_ids) / sizeof(int); i++) {
73 | args.id = known_pfs_ids[i];
74 |
75 | res = shellUserMountById(&args);
76 | if (res >= 0)
77 | return res;
78 | }
79 |
80 | read_only = 1;
81 | return sceAppMgrGameDataMount(path, 0, 0, pfs_mount_point);
82 | }
83 |
84 | int pfsUmount() {
85 | if (pfs_mount_point[0] == 0)
86 | return -1;
87 |
88 | int res = sceAppMgrUmount(pfs_mount_point);
89 | if (res >= 0) {
90 | memset(pfs_mount_point, 0, sizeof(pfs_mount_point));
91 | memset(pfs_mounted_path, 0, sizeof(pfs_mounted_path));
92 | }
93 |
94 | return res;
95 | }
--------------------------------------------------------------------------------
/modules/patch/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 |
22 | static SceUID hooks[2];
23 |
24 | void _start() __attribute__ ((weak, alias("module_start")));
25 | int module_start(SceSize args, void *argp) {
26 | // Get tai module info
27 | tai_module_info_t info;
28 | info.size = sizeof(tai_module_info_t);
29 | if (taiGetModuleInfoForKernel(KERNEL_PID, "SceAppMgr", &info) < 0)
30 | return SCE_KERNEL_START_SUCCESS;
31 |
32 | // Patch to allow Memory Card remount
33 | uint32_t nop_nop_opcode = 0xBF00BF00;
34 | switch (info.module_nid) {
35 | case 0x94CEFE4B: // 3.55 retail
36 | case 0xDFBC288C: // 3.57 retail
37 | case 0xDBB29DB7: // 3.60 retail
38 | case 0x1C9879D6: // 3.65 retail
39 | hooks[0] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB338, &nop_nop_opcode, 4);
40 | hooks[1] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB368, &nop_nop_opcode, 2);
41 | break;
42 |
43 | case 0x54E2E984: // 3.67 retail
44 | case 0xC3C538DE: // 3.68 retail
45 | hooks[0] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB344, &nop_nop_opcode, 4);
46 | hooks[1] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB374, &nop_nop_opcode, 2);
47 | break;
48 |
49 | case 0x321E4852: // 3.69 retail
50 | case 0x700DA0CD: // 3.70 retail
51 | case 0xF7846B4E: // 3.71 retail
52 | case 0xA8E80BA8: // 3.72 retail
53 | case 0xB299D195: // 3.73 retail
54 | hooks[0] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB34C, &nop_nop_opcode, 4);
55 | hooks[1] = taiInjectDataForKernel(KERNEL_PID, info.modid, 0, 0xB37C, &nop_nop_opcode, 2);
56 | break;
57 | }
58 |
59 | return SCE_KERNEL_START_SUCCESS;
60 | }
61 |
62 | int module_stop(SceSize args, void *argp) {
63 | if (hooks[1] >= 0)
64 | taiInjectReleaseForKernel(hooks[1]);
65 |
66 | if (hooks[0] >= 0)
67 | taiInjectReleaseForKernel(hooks[0]);
68 |
69 | return SCE_KERNEL_STOP_SUCCESS;
70 | }
71 |
--------------------------------------------------------------------------------
/src/main.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include "main.h"
4 | #include "init.h"
5 | #include "pfs.h"
6 | #include "file.h"
7 | #include "debugScreen.h"
8 |
9 | #define printf psvDebugScreenPrintf
10 | #define BUFFER_SIZE 4096
11 |
12 | int main(int argc, char *argv[]) {
13 | initCopyIcons();
14 | psvDebugScreenInit();
15 |
16 | SceUID dfd = sceIoDopen("ux0:app");
17 | if (dfd < 0)
18 | sceKernelExitProcess(0);
19 |
20 | int res = 0;
21 | char game_path[512];
22 | char pfs_path[512];
23 | char icon_path[512];
24 | char meta_icon_path[512];
25 | char pic_path[512];
26 | char meta_pic_path[512];
27 | char meta_path[512];
28 |
29 | do {
30 | SceIoDirent dir;
31 | memset(&dir, 0, sizeof(SceIoDirent));
32 |
33 | res = sceIoDread(dfd, &dir);
34 | if (res > 0) {
35 | sprintf(game_path, "ux0:app/%s", dir.d_name);
36 | sprintf(meta_path, "ur0:appmeta/%s", dir.d_name);
37 | sprintf(pfs_path, "ux0:app/%s/sce_pfs", dir.d_name);
38 | sprintf(icon_path, "ux0:app/%s/sce_sys/icon0.png", dir.d_name);
39 | sprintf(meta_icon_path, "ur0:appmeta/%s/icon0.png", dir.d_name);
40 | sprintf(pic_path, "ux0:app/%s/sce_sys/pic0.png", dir.d_name);
41 | sprintf(meta_pic_path, "ur0:appmeta/%s/pic0.png", dir.d_name);
42 |
43 | printf("Looking for icons to copy for %s\n", dir.d_name);
44 |
45 | int pfs_path_exists = checkFolderExist(pfs_path);
46 | int icon_path_exists = checkFileExist(icon_path);
47 | int meta_icon_path_exists = checkFileExist(meta_icon_path);
48 | int pic_path_exists = checkFileExist(pic_path);
49 | int meta_pic_path_exists = checkFileExist(meta_pic_path);
50 |
51 | if (pfs_path_exists && ((icon_path_exists && !meta_icon_path_exists) || (pic_path_exists && !meta_pic_path_exists)))
52 | {
53 | createDirectory(meta_path);
54 | if (pfsMount(game_path) == 0)
55 | {
56 | if (icon_path_exists && !meta_icon_path_exists)
57 | {
58 | copyFile(icon_path, meta_icon_path, NULL);
59 | printf("copied %s to %s\n", icon_path, meta_icon_path);
60 | }
61 |
62 | if (pic_path_exists && !meta_pic_path_exists)
63 | {
64 | copyFile(pic_path, meta_pic_path, NULL);
65 | printf("copied %s to %s\n", pic_path, meta_pic_path);
66 | }
67 | pfsUmount();
68 | }
69 | }
70 | else if ((icon_path_exists && !meta_icon_path_exists) || (pic_path_exists && !meta_pic_path_exists))
71 | {
72 | createDirectory(meta_path);
73 | if (icon_path_exists && !meta_icon_path_exists)
74 | {
75 | copyFile(icon_path, meta_icon_path, NULL);
76 | printf("copied %s to %s\n", icon_path, meta_icon_path);
77 | }
78 |
79 | if (pic_path_exists && !meta_pic_path_exists)
80 | {
81 | copyFile(pic_path, meta_pic_path, NULL);
82 | printf("copied %s to %s\n", pic_path, meta_pic_path);
83 | }
84 | }
85 | }
86 | } while (res > 0);
87 |
88 | finishCopyIcons();
89 | sceKernelExitProcess(0);
90 | return 0;
91 | }
92 |
--------------------------------------------------------------------------------
/src/init.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include "main.h"
20 | #include "vitashell_user.h"
21 | #include "init.h"
22 | #include "file.h"
23 |
24 | extern unsigned char _binary_modules_kernel_kernel_skprx_start;
25 | extern unsigned char _binary_modules_kernel_kernel_skprx_size;
26 | extern unsigned char _binary_modules_user_user_suprx_start;
27 | extern unsigned char _binary_modules_user_user_suprx_size;
28 | extern unsigned char _binary_modules_patch_patch_skprx_start;
29 | extern unsigned char _binary_modules_patch_patch_skprx_size;
30 |
31 | #define DEFAULT_FILE(path, name, replace) { path, (void *)&_binary_resources_##name##_start, (int)&_binary_resources_##name##_size, replace }
32 |
33 | static DefaultFile default_files[] = {
34 | { "ux0:data/CopyIcons/module/kernel.skprx", (void *)&_binary_modules_kernel_kernel_skprx_start,
35 | (int)&_binary_modules_kernel_kernel_skprx_size, 1 },
36 | { "ux0:data/CopyIcons/module/user.suprx", (void *)&_binary_modules_user_user_suprx_start,
37 | (int)&_binary_modules_user_user_suprx_size, 1 },
38 | { "ux0:data/CopyIcons/module/patch.skprx", (void *)&_binary_modules_patch_patch_skprx_start,
39 | (int)&_binary_modules_patch_patch_skprx_size, 1 },
40 | };
41 |
42 | SceUID patch_modid = -1, kernel_modid = -1, user_modid = -1;
43 |
44 |
45 | void installDefaultFiles() {
46 | // Make CopyIcons folders
47 | sceIoMkdir("ux0:data/CopyIcons", 0777);
48 | sceIoMkdir("ux0:data/CopyIcons/module", 0777);
49 |
50 | // Write default files if they don't exist
51 | int i;
52 | for (i = 0; i < (sizeof(default_files) / sizeof(DefaultFile)); i++) {
53 | SceIoStat stat;
54 | memset(&stat, 0, sizeof(stat));
55 | if (sceIoGetstat(default_files[i].path, &stat) < 0 || (default_files[i].replace && (int)stat.st_size != default_files[i].size))
56 | WriteFile(default_files[i].path, default_files[i].buffer, default_files[i].size);
57 | }
58 | }
59 |
60 | void initCopyIcons() {
61 | installDefaultFiles();
62 |
63 | // Load modules
64 | int search_unk[2];
65 | SceUID search_modid;
66 | search_modid = _vshKernelSearchModuleByName("VitaShellPatch", search_unk);
67 | if(search_modid < 0) {
68 | patch_modid = taiLoadKernelModule("ux0:data/CopyIcons/module/patch.skprx", 0, NULL);
69 | if (patch_modid >= 0) {
70 | int res = taiStartKernelModule(patch_modid, 0, NULL, 0, NULL, NULL);
71 | if (res < 0)
72 | taiStopUnloadKernelModule(patch_modid, 0, NULL, 0, NULL, NULL);
73 | }
74 | }
75 | search_modid = _vshKernelSearchModuleByName("VitaShellKernel2", search_unk);
76 | if(search_modid < 0) {
77 | kernel_modid = taiLoadKernelModule("ux0:data/CopyIcons/module/kernel.skprx", 0, NULL);
78 | if (kernel_modid >= 0) {
79 | int res = taiStartKernelModule(kernel_modid, 0, NULL, 0, NULL, NULL);
80 | if (res < 0)
81 | taiStopUnloadKernelModule(kernel_modid, 0, NULL, 0, NULL, NULL);
82 | }
83 | }
84 | user_modid = sceKernelLoadStartModule("ux0:data/CopyIcons/module/user.suprx", 0, NULL, 0, NULL, NULL);
85 |
86 | }
87 |
88 | void finishCopyIcons() {
89 | }
90 |
--------------------------------------------------------------------------------
/src/file.h:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #ifndef __FILE_H__
20 | #define __FILE_H__
21 |
22 | #define SCE_ERROR_ERRNO_EEXIST 0x80010011
23 | #define SCE_ERROR_ERRNO_ENODEV 0x80010013
24 |
25 | #define MAX_PATH_LENGTH 1024
26 | #define MAX_NAME_LENGTH 256
27 | #define MAX_SHORT_NAME_LENGTH 64
28 | #define MAX_MOUNT_POINT_LENGTH 16
29 |
30 | #define DIRECTORY_SIZE (4 * 1024)
31 | #define TRANSFER_SIZE (128 * 1024)
32 |
33 | #define SYMLINK_HEADER_SIZE 4
34 | #define SYMLINK_MAX_SIZE (SYMLINK_HEADER_SIZE + MAX_PATH_LENGTH)
35 | #define SYMLINK_EXT "lnk"
36 | extern const char symlink_header_bytes[SYMLINK_HEADER_SIZE];
37 |
38 |
39 | enum FileTypes {
40 | FILE_TYPE_UNKNOWN,
41 | FILE_TYPE_ARCHIVE,
42 | FILE_TYPE_BMP,
43 | FILE_TYPE_INI,
44 | FILE_TYPE_JPEG,
45 | FILE_TYPE_MP3,
46 | FILE_TYPE_MP4,
47 | FILE_TYPE_OGG,
48 | FILE_TYPE_PNG,
49 | FILE_TYPE_PSP2DMP,
50 | FILE_TYPE_SFO,
51 | FILE_TYPE_TXT,
52 | FILE_TYPE_VPK,
53 | FILE_TYPE_XML,
54 | };
55 |
56 | enum FileSortFlags {
57 | SORT_NONE,
58 | SORT_BY_NAME,
59 | SORT_BY_SIZE,
60 | SORT_BY_DATE,
61 | };
62 |
63 | enum FileMoveFlags {
64 | MOVE_INTEGRATE = 0x1, // Integrate directories
65 | MOVE_REPLACE = 0x2, // Replace files
66 | };
67 |
68 | typedef struct {
69 | int to_file; // 1: to file, 0: to directory
70 | char *target_path;
71 | int target_path_length;
72 | } Symlink;
73 |
74 | typedef struct {
75 | uint64_t *value;
76 | uint64_t max;
77 | void (* SetProgress)(uint64_t value, uint64_t max);
78 | int (* cancelHandler)();
79 | } FileProcessParam;
80 |
81 | typedef struct FileListEntry {
82 | struct FileListEntry *next;
83 | struct FileListEntry *previous;
84 | char *name;
85 | int name_length;
86 | int is_folder;
87 | int type;
88 | int is_symlink;
89 | Symlink *symlink;
90 | SceOff size;
91 | SceOff size2;
92 | SceDateTime ctime;
93 | SceDateTime mtime;
94 | SceDateTime atime;
95 | } FileListEntry;
96 |
97 | typedef struct {
98 | FileListEntry *head;
99 | FileListEntry *tail;
100 | int length;
101 | char path[MAX_PATH_LENGTH];
102 | int files;
103 | int folders;
104 | int is_in_archive;
105 | } FileList;
106 |
107 | int allocateReadFile(const char *file, void **buffer);
108 | int ReadFile(const char *file, void *buf, int size);
109 | int WriteFile(const char *file, const void *buf, int size);
110 |
111 | int checkFileExist(const char *file);
112 | int checkFolderExist(const char *folder);
113 | int createDirectory(const char* folder);
114 |
115 | char * getBaseDirectory(const char *path);
116 | char * getFilename(const char *path);
117 |
118 | int getFileSize(const char *file);
119 | int getPathInfo(const char *path, uint64_t *size, uint32_t *folders, uint32_t *files, int (* handler)(const char *path));
120 | int removePath(const char *path, FileProcessParam *param);
121 | int copyFile(const char *src_path, const char *dst_path, FileProcessParam *param);
122 | int copyPath(const char *src_path, const char *dst_path, FileProcessParam *param);
123 | int movePath(const char *src_path, const char *dst_path, int flags, FileProcessParam *param);
124 | int hasEndSlash(const char *path);
125 | int removeEndSlash(char *path);
126 | int addEndSlash(char *path);
127 |
128 |
129 | #endif
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ## This file is a quick tutorial on writing CMakeLists for targeting the Vita
2 | cmake_minimum_required(VERSION 2.8)
3 |
4 | ## This includes the Vita toolchain, must go before project definition
5 | # It is a convenience so you do not have to type
6 | # -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake for cmake. It is
7 | # highly recommended that you include this block for all projects.
8 | if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
9 | if(DEFINED ENV{VITASDK})
10 | set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
11 | else()
12 | message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
13 | endif()
14 | endif()
15 |
16 | ## Define project parameters here
17 | # Name of the project
18 | project(CopyIcons)
19 | # This line adds Vita helper macros, must go after project definition in order
20 | # to build Vita specific artifacts (self/vpk).
21 | include("${VITASDK}/share/vita.cmake" REQUIRED)
22 |
23 | ## Configuration options for this app
24 | # Display name (under bubble in LiveArea)
25 | set(VITA_APP_NAME "Copy Icons")
26 | # Unique ID must be exactly 9 characters. Recommended: XXXXYYYYY where X =
27 | # unique string of developer and Y = a unique number for this app
28 | set(VITA_TITLEID "CPIC00001")
29 | # Optional version string to show in LiveArea's more info screen
30 | set(VITA_VERSION "01.01")
31 |
32 | ## Flags and includes for building
33 | # Note that we make sure not to overwrite previous flags
34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
36 | # Optional. You can specify more param.sfo flags this way.
37 | set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1")
38 |
39 | add_subdirectory(modules/kernel)
40 | add_subdirectory(modules/user)
41 | add_subdirectory(modules/patch)
42 |
43 | include_directories(
44 | modules/kernel
45 | modules/user
46 | )
47 |
48 | # Add any additional library paths here
49 | # ${CMAKE_CURRENT_BINARY_DIR} lets you use any library currently being built
50 | link_directories(
51 | ${CMAKE_CURRENT_BINARY_DIR}
52 | )
53 |
54 | # Builds
55 | FUNCTION(ADD_RESOURCES out_var)
56 | SET(result)
57 | FOREACH(ref_f ${ARGN})
58 | if (IS_ABSOLUTE "${ref_f}")
59 | SET(out_f "${ref_f}.o")
60 | STRING(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" in_f "${ref_f}")
61 | SET(work_dir "${CMAKE_CURRENT_BINARY_DIR}")
62 | else()
63 | SET(out_f "${CMAKE_CURRENT_BINARY_DIR}/${ref_f}.o")
64 | SET(in_f "${ref_f}")
65 | SET(work_dir "${CMAKE_SOURCE_DIR}")
66 | endif()
67 | GET_FILENAME_COMPONENT(out_dir ${out_f} DIRECTORY)
68 | ADD_CUSTOM_COMMAND(OUTPUT ${out_f}
69 | COMMAND ${CMAKE_COMMAND} -E make_directory ${out_dir}
70 | COMMAND ${CMAKE_LINKER} -r -b binary -o ${out_f} ${in_f}
71 | DEPENDS ${ref_f}
72 | WORKING_DIRECTORY ${work_dir}
73 | COMMENT "Building resource ${out_f}"
74 | VERBATIM
75 | )
76 | LIST(APPEND result ${out_f})
77 | ENDFOREACH()
78 | SET(${out_var} "${result}" PARENT_SCOPE)
79 | ENDFUNCTION()
80 |
81 | # ugly hack
82 | add_resources(vitashell_res
83 | ${CMAKE_CURRENT_BINARY_DIR}/modules/kernel/kernel.skprx
84 | ${CMAKE_CURRENT_BINARY_DIR}/modules/user/user.suprx
85 | ${CMAKE_CURRENT_BINARY_DIR}/modules/patch/patch.skprx
86 | )
87 |
88 | ## Build and link
89 | # Add all the files needed to compile here
90 | add_executable(${PROJECT_NAME}
91 | ${vitashell_res}
92 | src/main.c
93 | src/pfs.c
94 | src/init.c
95 | src/file.c
96 | src/strnatcmp.c
97 | src/debugScreen.c
98 | )
99 |
100 | add_dependencies(${PROJECT_NAME} vitashell_user_stubs)
101 | add_dependencies(${PROJECT_NAME} kernel.skprx)
102 | add_dependencies(${PROJECT_NAME} user.suprx)
103 | add_dependencies(${PROJECT_NAME} patch.skprx)
104 |
105 | # Library to link to (drop the -l prefix). This will mostly be stubs.
106 | target_link_libraries(${PROJECT_NAME}
107 | VitaShellUser_stub_weak
108 | VitaShellKernel2_stub_weak
109 | taihen_stub
110 | taihenForKernel_stub
111 | taihenModuleUtils_stub
112 | SceAppMgr_stub
113 | SceAppUtil_stub
114 | SceLibKernel_stub
115 | SceDisplay_stub
116 | SceNpDrm_stub
117 | SceSysmodule_stub
118 | ScePower_stub
119 | SceNet_stub
120 | SceNetCtl_stub
121 | SceVshBridge_stub
122 | )
123 |
124 | ## Create Vita files
125 | vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE)
126 | # The FILE directive lets you add additional files to the VPK, the syntax is
127 | # FILE src_path dst_path_in_vpk. In this case, we add the LiveArea paths.
128 | vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} eboot.bin
129 | VERSION ${VITA_VERSION}
130 | NAME ${VITA_APP_NAME}
131 | FILE sce_sys/icon0.png sce_sys/icon0.png
132 | FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
133 | FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
134 | FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
135 | )
136 |
--------------------------------------------------------------------------------
/src/strnatcmp.c:
--------------------------------------------------------------------------------
1 | /* -*- mode: c; c-file-style: "k&r" -*-
2 |
3 | strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
4 | Copyright (C) 2000, 2004 by Martin Pool
5 |
6 | This software is provided 'as-is', without any express or implied
7 | warranty. In no event will the authors be held liable for any damages
8 | arising from the use of this software.
9 |
10 | Permission is granted to anyone to use this software for any purpose,
11 | including commercial applications, and to alter it and redistribute it
12 | freely, subject to the following restrictions:
13 |
14 | 1. The origin of this software must not be misrepresented; you must not
15 | claim that you wrote the original software. If you use this software
16 | in a product, an acknowledgment in the product documentation would be
17 | appreciated but is not required.
18 | 2. Altered source versions must be plainly marked as such, and must not be
19 | misrepresented as being the original software.
20 | 3. This notice may not be removed or altered from any source distribution.
21 | */
22 |
23 |
24 | /* partial change history:
25 | *
26 | * 2004-10-10 mbp: Lift out character type dependencies into macros.
27 | *
28 | * Eric Sosman pointed out that ctype functions take a parameter whose
29 | * value must be that of an unsigned int, even on platforms that have
30 | * negative chars in their default char type.
31 | */
32 |
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | #include "strnatcmp.h"
39 |
40 |
41 | /* These are defined as macros to make it easier to adapt this code to
42 | * different characters types or comparison functions. */
43 | static inline int
44 | nat_isdigit(nat_char a)
45 | {
46 | return isdigit((unsigned char) a);
47 | }
48 |
49 |
50 | static inline int
51 | nat_isspace(nat_char a)
52 | {
53 | return isspace((unsigned char) a);
54 | }
55 |
56 |
57 | static inline nat_char
58 | nat_toupper(nat_char a)
59 | {
60 | return toupper((unsigned char) a);
61 | }
62 |
63 |
64 |
65 | static int
66 | compare_right(nat_char const *a, nat_char const *b)
67 | {
68 | int bias = 0;
69 |
70 | /* The longest run of digits wins. That aside, the greatest
71 | value wins, but we can't know that it will until we've scanned
72 | both numbers to know that they have the same magnitude, so we
73 | remember it in BIAS. */
74 | for (;; a++, b++) {
75 | if (!nat_isdigit(*a) && !nat_isdigit(*b))
76 | return bias;
77 | else if (!nat_isdigit(*a))
78 | return -1;
79 | else if (!nat_isdigit(*b))
80 | return +1;
81 | else if (*a < *b) {
82 | if (!bias)
83 | bias = -1;
84 | } else if (*a > *b) {
85 | if (!bias)
86 | bias = +1;
87 | } else if (!*a && !*b)
88 | return bias;
89 | }
90 |
91 | return 0;
92 | }
93 |
94 |
95 | static int
96 | compare_left(nat_char const *a, nat_char const *b)
97 | {
98 | /* Compare two left-aligned numbers: the first to have a
99 | different value wins. */
100 | for (;; a++, b++) {
101 | if (!nat_isdigit(*a) && !nat_isdigit(*b))
102 | return 0;
103 | else if (!nat_isdigit(*a))
104 | return -1;
105 | else if (!nat_isdigit(*b))
106 | return +1;
107 | else if (*a < *b)
108 | return -1;
109 | else if (*a > *b)
110 | return +1;
111 | }
112 |
113 | return 0;
114 | }
115 |
116 |
117 | static int strnatcmp0(nat_char const *a, nat_char const *b, int fold_case)
118 | {
119 | int ai, bi;
120 | nat_char ca, cb;
121 | int fractional, result;
122 |
123 | assert(a && b);
124 | ai = bi = 0;
125 | while (1) {
126 | ca = a[ai]; cb = b[bi];
127 |
128 | /* skip over leading spaces or zeros */
129 | while (nat_isspace(ca))
130 | ca = a[++ai];
131 |
132 | while (nat_isspace(cb))
133 | cb = b[++bi];
134 |
135 | /* process run of digits */
136 | if (nat_isdigit(ca) && nat_isdigit(cb)) {
137 | fractional = (ca == '0' || cb == '0');
138 |
139 | if (fractional) {
140 | if ((result = compare_left(a+ai, b+bi)) != 0)
141 | return result;
142 | } else {
143 | if ((result = compare_right(a+ai, b+bi)) != 0)
144 | return result;
145 | }
146 | }
147 |
148 | if (!ca && !cb) {
149 | /* The strings compare the same. Perhaps the caller
150 | will want to call strcmp to break the tie. */
151 | return 0;
152 | }
153 |
154 | if (fold_case) {
155 | ca = nat_toupper(ca);
156 | cb = nat_toupper(cb);
157 | }
158 |
159 | if (ca < cb)
160 | return -1;
161 | else if (ca > cb)
162 | return +1;
163 |
164 | ++ai; ++bi;
165 | }
166 | }
167 |
168 |
169 |
170 | int strnatcmp(nat_char const *a, nat_char const *b) {
171 | return strnatcmp0(a, b, 0);
172 | }
173 |
174 |
175 | /* Compare, recognizing numeric string and ignoring case. */
176 | int strnatcasecmp(nat_char const *a, nat_char const *b) {
177 | return strnatcmp0(a, b, 1);
178 | }
179 |
--------------------------------------------------------------------------------
/src/debugScreenFont.c:
--------------------------------------------------------------------------------
1 | /*
2 | * PSP Software Development Kit - http://www.pspdev.org
3 | * -----------------------------------------------------------------------
4 | * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 | *
6 | * font.c - Debug Font.
7 | *
8 | * Copyright (c) 2005 Marcus R. Brown
9 | * Copyright (c) 2005 James Forshaw
10 | * Copyright (c) 2005 John Kelley
11 | *
12 | * $Id: font.c 540 2005-07-08 19:35:10Z warren $
13 | */
14 |
15 | PsvDebugScreenFont psvDebugScreenFont = { glyphs:(unsigned char*)
16 | "\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c"
17 | "\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00"
18 | "\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00"
19 | "\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00"
20 | "\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00"
21 | "\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70"
22 | "\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0"
23 | "\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00"
24 | "\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00"
25 | "\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10"
26 | "\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10"
27 | "\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00"
28 | "\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10"
29 | "\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00"
30 | "\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80"
31 | "\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00"
32 | "\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00"
33 | "\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00"
34 | "\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00"
35 | "\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00"
36 | "\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00"
37 | "\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00"
38 | "\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00"
39 | "\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00"
40 | "\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00"
41 | "\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00"
42 | "\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00"
43 | "\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00"
44 | "\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00"
45 | "\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40"
46 | "\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00"
47 | "\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00"
48 | "\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00"
49 | "\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00"
50 | "\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00"
51 | "\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00"
52 | "\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00"
53 | "\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00"
54 | "\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00"
55 | "\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00"
56 | "\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00"
57 | "\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00"
58 | "\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00"
59 | "\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00"
60 | "\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00"
61 | "\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00"
62 | "\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00"
63 | "\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00"
64 | "\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00"
65 | "\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00"
66 | "\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00"
67 | "\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70"
68 | "\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00"
69 | "\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00"
70 | "\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00"
71 | "\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00"
72 | "\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08"
73 | "\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00"
74 | "\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00"
75 | "\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00"
76 | "\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70"
77 | "\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00"
78 | "\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00"
79 | "\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00"
80 | "\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00"
81 | "\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00"
82 | "\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00"
83 | "\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60"
84 | "\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00"
85 | "\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00"
86 | "\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00"
87 | "\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00"
88 | "\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00"
89 | "\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00"
90 | "\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00"
91 | "\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00"
92 | "\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00"
93 | "\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20"
94 | "\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00"
95 | "\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40"
96 | "\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00"
97 | "\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00"
98 | "\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00"
99 | "\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0"
100 | "\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00"
101 | "\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c"
102 | "\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00"
103 | "\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00"
104 | "\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00"
105 | "\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00"
106 | "\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00"
107 | "\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00"
108 | "\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20"
109 | "\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00"
110 | "\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00"
111 | "\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70"
112 | "\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f"
113 | "\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00"
114 | "\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00"
115 | "\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0"
116 | "\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03"
117 | "\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88"
118 | "\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00"
119 | "\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00"
120 | "\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff"
121 | "\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00"
122 | "\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00"
123 | "\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc"
124 | "\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00"
125 | "\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff"
126 | "\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0"
127 | "\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00"
128 | "\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0"
129 | "\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00"
130 | "\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00"
131 | "\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00"
132 | "\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00"
133 | "\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20"
134 | "\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00"
135 | "\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00"
136 | "\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00"
137 | "\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00"
138 | "\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40"
139 | "\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00"
140 | "\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00"
141 | "\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00"
142 | "\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00"
143 | "\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00\x00",
144 | width :8, height:8, first:0, last:255, size_w:8, size_h:8};
--------------------------------------------------------------------------------
/modules/kernel/main.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | #include
26 | #include
27 |
28 | #include
29 |
30 | #include "vitashell_kernel.h"
31 |
32 | #define MOUNT_POINT_ID 0x800
33 |
34 | int module_get_export_func(SceUID pid, const char *modname, uint32_t libnid, uint32_t funcnid, uintptr_t *func);
35 | int module_get_offset(SceUID pid, SceUID modid, int segidx, size_t offset, uintptr_t *addr);
36 |
37 | int ksceNpDrmGetRifVitaKey(void *license_buf, uint8_t *klicensee, uint32_t *flags,
38 | uint32_t *sku_flag, uint64_t *start_time, uint64_t *expiration_time);
39 |
40 | typedef struct {
41 | const char *dev;
42 | const char *dev2;
43 | const char *blkdev;
44 | const char *blkdev2;
45 | int id;
46 | } SceIoDevice;
47 |
48 | typedef struct {
49 | int id;
50 | const char *dev_unix;
51 | int unk;
52 | int dev_major;
53 | int dev_minor;
54 | const char *dev_filesystem;
55 | int unk2;
56 | SceIoDevice *dev;
57 | int unk3;
58 | SceIoDevice *dev2;
59 | int unk4;
60 | int unk5;
61 | int unk6;
62 | int unk7;
63 | } SceIoMountPoint;
64 |
65 | static char ux0_blkdev[64], ux0_blkdev2[64];
66 |
67 | static SceIoDevice ux0_dev = { "ux0:", "exfatux0", ux0_blkdev, ux0_blkdev2, MOUNT_POINT_ID };
68 |
69 | static SceIoMountPoint *(* sceIoFindMountPoint)(int id) = NULL;
70 |
71 | static SceUID hookid = -1;
72 |
73 | static tai_hook_ref_t ksceSysrootIsSafeModeRef;
74 |
75 | static tai_hook_ref_t ksceSblAimgrIsDolceRef;
76 |
77 | static int ksceSysrootIsSafeModePatched() {
78 | return 1;
79 | }
80 |
81 | static int ksceSblAimgrIsDolcePatched() {
82 | return 1;
83 | }
84 |
85 | int shellKernelIsUx0Redirected(const char *blkdev, const char *blkdev2) {
86 | char k_blkdev[64], k_blkdev2[64];
87 |
88 | uint32_t state;
89 | ENTER_SYSCALL(state);
90 |
91 | SceIoMountPoint *mount = sceIoFindMountPoint(MOUNT_POINT_ID);
92 | if (!mount) {
93 | EXIT_SYSCALL(state);
94 | return 0;
95 | }
96 |
97 | ksceKernelStrncpyUserToKernel(k_blkdev, (uintptr_t)blkdev, sizeof(k_blkdev)-1);
98 | ksceKernelStrncpyUserToKernel(k_blkdev2, (uintptr_t)blkdev2, sizeof(k_blkdev2)-1);
99 |
100 | if (mount && mount->dev && mount->dev->blkdev && strcmp(mount->dev->blkdev, k_blkdev) == 0) {
101 | EXIT_SYSCALL(state);
102 | return 1;
103 | }
104 |
105 | EXIT_SYSCALL(state);
106 | return 0;
107 | }
108 |
109 | int shellKernelRedirectUx0(const char *blkdev, const char *blkdev2) {
110 | uint32_t state;
111 | ENTER_SYSCALL(state);
112 |
113 | SceIoMountPoint *mount = sceIoFindMountPoint(MOUNT_POINT_ID);
114 | if (!mount) {
115 | EXIT_SYSCALL(state);
116 | return -1;
117 | }
118 |
119 | ksceKernelStrncpyUserToKernel(ux0_blkdev, (uintptr_t)blkdev, sizeof(ux0_blkdev)-1);
120 | ksceKernelStrncpyUserToKernel(ux0_blkdev2, (uintptr_t)blkdev2, sizeof(ux0_blkdev2)-1);
121 |
122 | mount->dev = &ux0_dev;
123 | mount->dev2 = &ux0_dev;
124 |
125 | EXIT_SYSCALL(state);
126 | return 0;
127 | }
128 |
129 | int _shellKernelMountById(ShellMountIdArgs *args) {
130 | int res;
131 |
132 | void *(* sceAppMgrFindProcessInfoByPid)(void *data, SceUID pid);
133 | int (* sceAppMgrMountById)(SceUID pid, void *info, int id, const char *titleid, const char *path,
134 | const char *desired_mount_point, const void *klicensee, char *mount_point);
135 | int (* _ksceKernelGetModuleInfo)(SceUID pid, SceUID modid, SceKernelModuleInfo *info);
136 |
137 | // Get tai module info
138 | tai_module_info_t tai_info;
139 | tai_info.size = sizeof(tai_module_info_t);
140 | if (taiGetModuleInfoForKernel(KERNEL_PID, "SceAppMgr", &tai_info) < 0)
141 | return SCE_KERNEL_START_SUCCESS;
142 |
143 | switch (tai_info.module_nid) {
144 | case 0x94CEFE4B: // 3.55 retail
145 | case 0xDFBC288C: // 3.57 retail
146 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
147 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E15, (uintptr_t *)&sceAppMgrMountById);
148 | break;
149 |
150 | case 0xDBB29DB7: // 3.60 retail
151 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
152 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19B51, (uintptr_t *)&sceAppMgrMountById);
153 | break;
154 |
155 | case 0x1C9879D6: // 3.65 retail
156 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
157 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E61, (uintptr_t *)&sceAppMgrMountById);
158 | break;
159 |
160 | case 0x54E2E984: // 3.67 retail
161 | case 0xC3C538DE: // 3.68 retail
162 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE1, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
163 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E6D, (uintptr_t *)&sceAppMgrMountById);
164 | break;
165 |
166 | case 0x321E4852: // 3.69 retail
167 | case 0x700DA0CD: // 3.70 retail
168 | case 0xF7846B4E: // 3.71 retail
169 | case 0xA8E80BA8: // 3.72 retail
170 | case 0xB299D195: // 3.73 retail
171 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x2DE9, (uintptr_t *)&sceAppMgrFindProcessInfoByPid);
172 | module_get_offset(KERNEL_PID, tai_info.modid, 0, 0x19E95, (uintptr_t *)&sceAppMgrMountById);
173 | break;
174 | }
175 |
176 | res = module_get_export_func(KERNEL_PID, "SceKernelModulemgr",
177 | 0xC445FA63, 0xD269F915, (uintptr_t *)&_ksceKernelGetModuleInfo);
178 | if (res < 0)
179 | res = module_get_export_func(KERNEL_PID, "SceKernelModulemgr",
180 | 0x92C9FFC2, 0xDAA90093, (uintptr_t *)&_ksceKernelGetModuleInfo);
181 | if (res < 0)
182 | return res;
183 |
184 | // Module info
185 | SceKernelModuleInfo mod_info;
186 | mod_info.size = sizeof(SceKernelModuleInfo);
187 | res = _ksceKernelGetModuleInfo(KERNEL_PID, tai_info.modid, &mod_info);
188 | if (res < 0)
189 | return res;
190 |
191 | uint32_t appmgr_data_addr = (uint32_t)mod_info.segments[1].vaddr;
192 |
193 | SceUID process_id = ksceKernelGetProcessId();
194 |
195 | void *info = sceAppMgrFindProcessInfoByPid((void *)(appmgr_data_addr + 0x500), process_id);
196 | if (!info)
197 | return -1;
198 |
199 | char process_titleid[12];
200 | char path[256];
201 | char desired_mount_point[16];
202 | char mount_point[16];
203 | char klicensee[16];
204 |
205 | memset(mount_point, 0, sizeof(mount_point));
206 |
207 | if (args->process_titleid)
208 | ksceKernelStrncpyUserToKernel(process_titleid, (uintptr_t)args->process_titleid, 11);
209 | if (args->path)
210 | ksceKernelStrncpyUserToKernel(path, (uintptr_t)args->path, 255);
211 | if (args->desired_mount_point)
212 | ksceKernelStrncpyUserToKernel(desired_mount_point, (uintptr_t)args->desired_mount_point, 15);
213 | if (args->klicensee)
214 | ksceKernelMemcpyUserToKernel(klicensee, (uintptr_t)args->klicensee, 0x10);
215 |
216 | res = sceAppMgrMountById(process_id,
217 | info + 0x580,
218 | args->id,
219 | args->process_titleid ? process_titleid : NULL,
220 | args->path ? path : NULL,
221 | args->desired_mount_point ? desired_mount_point : NULL,
222 | args->klicensee ? klicensee : NULL,
223 | mount_point);
224 |
225 | if (args->mount_point)
226 | ksceKernelStrncpyKernelToUser((uintptr_t)args->mount_point, mount_point, 15);
227 |
228 | return res;
229 | }
230 |
231 | int shellKernelMountById(ShellMountIdArgs *args) {
232 | uint32_t state;
233 | ENTER_SYSCALL(state);
234 |
235 | ShellMountIdArgs k_args;
236 | ksceKernelMemcpyUserToKernel(&k_args, (uintptr_t)args, sizeof(ShellMountIdArgs));
237 |
238 | int res = ksceKernelRunWithStack(0x2000, (void *)_shellKernelMountById, &k_args);
239 |
240 | EXIT_SYSCALL(state);
241 | return res;
242 | }
243 |
244 | int shellKernelGetRifVitaKey(const void *license_buf, void *klicensee) {
245 | char k_license_buf[0x200];
246 | char k_klicensee[0x10];
247 |
248 | memset(k_klicensee, 0, sizeof(k_klicensee));
249 |
250 | if (license_buf)
251 | ksceKernelMemcpyUserToKernel(k_license_buf, (uintptr_t)license_buf, sizeof(k_license_buf));
252 |
253 | int res = ksceNpDrmGetRifVitaKey(k_license_buf, (uint8_t *)k_klicensee, NULL, NULL, NULL, NULL);
254 |
255 | if (klicensee)
256 | ksceKernelMemcpyKernelToUser((uintptr_t)klicensee, k_klicensee, sizeof(k_klicensee));
257 |
258 | return res;
259 | }
260 |
261 | void _start() __attribute__ ((weak, alias("module_start")));
262 | int module_start(SceSize args, void *argp) {
263 | SceUID tmp1, tmp2;
264 | // Get tai module info
265 | tai_module_info_t info;
266 | info.size = sizeof(tai_module_info_t);
267 | if (taiGetModuleInfoForKernel(KERNEL_PID, "SceIofilemgr", &info) < 0)
268 | return SCE_KERNEL_START_SUCCESS;
269 |
270 | // Get important function
271 | switch (info.module_nid) {
272 | case 0x7A1DBDE6: // 3.55 retail
273 | case 0xEF58597E: // 3.57 retail
274 | case 0x9642948C: // 3.60 retail
275 | module_get_offset(KERNEL_PID, info.modid, 0, 0x138C1, (uintptr_t *)&sceIoFindMountPoint);
276 | break;
277 |
278 | case 0xA96ACE9D: // 3.65 retail
279 | case 0x3347A95F: // 3.67 retail
280 | case 0x90DA33DE: // 3.68 retail
281 | module_get_offset(KERNEL_PID, info.modid, 0, 0x182F5, (uintptr_t *)&sceIoFindMountPoint);
282 | break;
283 |
284 | case 0xF16E72C7: // 3.69 retail
285 | case 0x81A49C2B: // 3.70 retail
286 | case 0xF2D59083: // 3.71 retail
287 | case 0x9C16D40A: // 3.72 retail
288 | case 0xF7794A6C: // 3.73 retail
289 | module_get_offset(KERNEL_PID, info.modid, 0, 0x18735, (uintptr_t *)&sceIoFindMountPoint);
290 | break;
291 |
292 | default:
293 | return SCE_KERNEL_START_SUCCESS;
294 | }
295 |
296 | // Fake safe mode so that SceUsbMass can be loaded
297 | tmp1 = taiHookFunctionExportForKernel(KERNEL_PID, &ksceSysrootIsSafeModeRef, "SceSysmem",
298 | 0x2ED7F97A, 0x834439A7, ksceSysrootIsSafeModePatched);
299 | if (tmp1 < 0)
300 | return SCE_KERNEL_START_SUCCESS;
301 | // this patch is only needed on handheld units
302 | tmp2 = taiHookFunctionExportForKernel(KERNEL_PID, &ksceSblAimgrIsDolceRef, "SceSysmem",
303 | 0xFD00C69A, 0x71608CA3, ksceSblAimgrIsDolcePatched);
304 | if (tmp2 < 0)
305 | return SCE_KERNEL_START_SUCCESS;
306 |
307 | // Load SceUsbMass
308 | SceUID modid = ksceKernelLoadStartModule("ux0:VitaShell/module/umass.skprx", 0, NULL, 0, NULL, NULL);
309 |
310 | // Release patch
311 | taiHookReleaseForKernel(tmp1, ksceSysrootIsSafeModeRef);
312 | taiHookReleaseForKernel(tmp2, ksceSblAimgrIsDolceRef);
313 |
314 | // Check result
315 | if (modid < 0)
316 | return SCE_KERNEL_START_SUCCESS;
317 |
318 | // Fake safe mode in SceUsbServ
319 | hookid = taiHookFunctionImportForKernel(KERNEL_PID, &ksceSysrootIsSafeModeRef, "SceUsbServ",
320 | 0x2ED7F97A, 0x834439A7, ksceSysrootIsSafeModePatched);
321 |
322 | return SCE_KERNEL_START_SUCCESS;
323 | }
324 |
325 | int module_stop(SceSize args, void *argp) {
326 | if (hookid >= 0)
327 | taiHookReleaseForKernel(hookid, ksceSysrootIsSafeModeRef);
328 |
329 | return SCE_KERNEL_STOP_SUCCESS;
330 | }
331 |
--------------------------------------------------------------------------------
/src/file.c:
--------------------------------------------------------------------------------
1 | /*
2 | VitaShell
3 | Copyright (C) 2015-2018, TheFloW
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 | */
18 |
19 | #include "main.h"
20 | #include "init.h"
21 | #include "file.h"
22 | #include "strnatcmp.h"
23 |
24 | int allocateReadFile(const char *file, void **buffer) {
25 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
26 | if (fd < 0)
27 | return fd;
28 |
29 | int size = sceIoLseek32(fd, 0, SCE_SEEK_END);
30 | sceIoLseek32(fd, 0, SCE_SEEK_SET);
31 |
32 | *buffer = malloc(size);
33 | if (!*buffer) {
34 | sceIoClose(fd);
35 | return VITASHELL_ERROR_NO_MEMORY;
36 | }
37 |
38 | int read = sceIoRead(fd, *buffer, size);
39 | sceIoClose(fd);
40 |
41 | return read;
42 | }
43 |
44 | int ReadFile(const char *file, void *buf, int size) {
45 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
46 | if (fd < 0)
47 | return fd;
48 |
49 | int read = sceIoRead(fd, buf, size);
50 |
51 | sceIoClose(fd);
52 | return read;
53 | }
54 |
55 | int WriteFile(const char *file, const void *buf, int size) {
56 | SceUID fd = sceIoOpen(file, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
57 | if (fd < 0)
58 | return fd;
59 |
60 | int written = sceIoWrite(fd, buf, size);
61 |
62 | sceIoClose(fd);
63 | return written;
64 | }
65 |
66 | int getFileSize(const char *file) {
67 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
68 | if (fd < 0)
69 | return fd;
70 |
71 | int fileSize = sceIoLseek(fd, 0, SCE_SEEK_END);
72 |
73 | sceIoClose(fd);
74 | return fileSize;
75 | }
76 |
77 | int checkFileExist(const char *file) {
78 | SceUID fd = sceIoOpen(file, SCE_O_RDONLY, 0);
79 | if (fd < 0)
80 | return 0;
81 |
82 | sceIoClose(fd);
83 | return 1;
84 | }
85 |
86 | int checkFolderExist(const char *folder) {
87 | SceUID dfd = sceIoDopen(folder);
88 | if (dfd < 0)
89 | return 0;
90 |
91 | sceIoDclose(dfd);
92 | return 1;
93 | }
94 |
95 | int createDirectory(const char* folder) {
96 | int ret = sceIoMkdir(folder, 0777);
97 | return ret;
98 | }
99 |
100 | int getPathInfo(const char *path, uint64_t *size, uint32_t *folders,
101 | uint32_t *files, int (* handler)(const char *path)) {
102 | SceUID dfd = sceIoDopen(path);
103 | if (dfd >= 0) {
104 | int res = 0;
105 |
106 | do {
107 | SceIoDirent dir;
108 | memset(&dir, 0, sizeof(SceIoDirent));
109 |
110 | res = sceIoDread(dfd, &dir);
111 | if (res > 0) {
112 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
113 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
114 |
115 | if (handler && handler(new_path)) {
116 | free(new_path);
117 | continue;
118 | }
119 |
120 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
121 | int ret = getPathInfo(new_path, size, folders, files, handler);
122 | if (ret <= 0) {
123 | free(new_path);
124 | sceIoDclose(dfd);
125 | return ret;
126 | }
127 | } else {
128 | if (size)
129 | (*size) += dir.d_stat.st_size;
130 |
131 | if (files)
132 | (*files)++;
133 | }
134 |
135 | free(new_path);
136 | }
137 | } while (res > 0);
138 |
139 | sceIoDclose(dfd);
140 |
141 | if (folders)
142 | (*folders)++;
143 | } else {
144 | if (handler && handler(path))
145 | return 1;
146 |
147 | if (size) {
148 | SceIoStat stat;
149 | memset(&stat, 0, sizeof(SceIoStat));
150 |
151 | int res = sceIoGetstat(path, &stat);
152 | if (res < 0)
153 | return res;
154 |
155 | (*size) += stat.st_size;
156 | }
157 |
158 | if (files)
159 | (*files)++;
160 | }
161 |
162 | return 1;
163 | }
164 |
165 | int removePath(const char *path, FileProcessParam *param) {
166 | SceUID dfd = sceIoDopen(path);
167 | if (dfd >= 0) {
168 | int res = 0;
169 |
170 | do {
171 | SceIoDirent dir;
172 | memset(&dir, 0, sizeof(SceIoDirent));
173 |
174 | res = sceIoDread(dfd, &dir);
175 | if (res > 0) {
176 | char *new_path = malloc(strlen(path) + strlen(dir.d_name) + 2);
177 | snprintf(new_path, MAX_PATH_LENGTH, "%s%s%s", path, hasEndSlash(path) ? "" : "/", dir.d_name);
178 |
179 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
180 | int ret = removePath(new_path, param);
181 | if (ret <= 0) {
182 | free(new_path);
183 | sceIoDclose(dfd);
184 | return ret;
185 | }
186 | } else {
187 | int ret = sceIoRemove(new_path);
188 | if (ret < 0) {
189 | free(new_path);
190 | sceIoDclose(dfd);
191 | return ret;
192 | }
193 |
194 | if (param) {
195 | if (param->value)
196 | (*param->value)++;
197 |
198 | if (param->SetProgress)
199 | param->SetProgress(param->value ? *param->value : 0, param->max);
200 |
201 | if (param->cancelHandler && param->cancelHandler()) {
202 | free(new_path);
203 | sceIoDclose(dfd);
204 | return 0;
205 | }
206 | }
207 | }
208 |
209 | free(new_path);
210 | }
211 | } while (res > 0);
212 |
213 | sceIoDclose(dfd);
214 |
215 | int ret = sceIoRmdir(path);
216 | if (ret < 0)
217 | return ret;
218 |
219 | if (param) {
220 | if (param->value)
221 | (*param->value)++;
222 |
223 | if (param->SetProgress)
224 | param->SetProgress(param->value ? *param->value : 0, param->max);
225 |
226 | if (param->cancelHandler && param->cancelHandler()) {
227 | return 0;
228 | }
229 | }
230 | } else {
231 | int ret = sceIoRemove(path);
232 | if (ret < 0)
233 | return ret;
234 |
235 | if (param) {
236 | if (param->value)
237 | (*param->value)++;
238 |
239 | if (param->SetProgress)
240 | param->SetProgress(param->value ? *param->value : 0, param->max);
241 |
242 | if (param->cancelHandler && param->cancelHandler()) {
243 | return 0;
244 | }
245 | }
246 | }
247 |
248 | return 1;
249 | }
250 |
251 | int copyFile(const char *src_path, const char *dst_path, FileProcessParam *param) {
252 | // The source and destination paths are identical
253 | if (strcasecmp(src_path, dst_path) == 0) {
254 | return VITASHELL_ERROR_SRC_AND_DST_IDENTICAL;
255 | }
256 |
257 | // The destination is a subfolder of the source folder
258 | int len = strlen(src_path);
259 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
260 | return VITASHELL_ERROR_DST_IS_SUBFOLDER_OF_SRC;
261 | }
262 |
263 | SceUID fdsrc = sceIoOpen(src_path, SCE_O_RDONLY, 0);
264 | if (fdsrc < 0)
265 | return fdsrc;
266 |
267 | SceUID fddst = sceIoOpen(dst_path, SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
268 | if (fddst < 0) {
269 | sceIoClose(fdsrc);
270 | return fddst;
271 | }
272 |
273 | void *buf = memalign(4096, TRANSFER_SIZE);
274 |
275 | while (1) {
276 | int read = sceIoRead(fdsrc, buf, TRANSFER_SIZE);
277 |
278 | if (read < 0) {
279 | free(buf);
280 |
281 | sceIoClose(fddst);
282 | sceIoClose(fdsrc);
283 |
284 | sceIoRemove(dst_path);
285 |
286 | return read;
287 | }
288 |
289 | if (read == 0)
290 | break;
291 |
292 | int written = sceIoWrite(fddst, buf, read);
293 |
294 | if (written < 0) {
295 | free(buf);
296 |
297 | sceIoClose(fddst);
298 | sceIoClose(fdsrc);
299 |
300 | sceIoRemove(dst_path);
301 |
302 | return written;
303 | }
304 |
305 | if (param) {
306 | if (param->value)
307 | (*param->value) += read;
308 |
309 | if (param->SetProgress)
310 | param->SetProgress(param->value ? *param->value : 0, param->max);
311 |
312 | if (param->cancelHandler && param->cancelHandler()) {
313 | free(buf);
314 |
315 | sceIoClose(fddst);
316 | sceIoClose(fdsrc);
317 |
318 | sceIoRemove(dst_path);
319 |
320 | return 0;
321 | }
322 | }
323 | }
324 |
325 | free(buf);
326 |
327 | // Inherit file stat
328 | SceIoStat stat;
329 | memset(&stat, 0, sizeof(SceIoStat));
330 | sceIoGetstatByFd(fdsrc, &stat);
331 | sceIoChstatByFd(fddst, &stat, 0x3B);
332 |
333 | sceIoClose(fddst);
334 | sceIoClose(fdsrc);
335 |
336 | return 1;
337 | }
338 |
339 | int copyPath(const char *src_path, const char *dst_path, FileProcessParam *param) {
340 | // The source and destination paths are identical
341 | if (strcasecmp(src_path, dst_path) == 0) {
342 | return VITASHELL_ERROR_SRC_AND_DST_IDENTICAL;
343 | }
344 |
345 | // The destination is a subfolder of the source folder
346 | int len = strlen(src_path);
347 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
348 | return VITASHELL_ERROR_DST_IS_SUBFOLDER_OF_SRC;
349 | }
350 |
351 | SceUID dfd = sceIoDopen(src_path);
352 | if (dfd >= 0) {
353 | SceIoStat stat;
354 | memset(&stat, 0, sizeof(SceIoStat));
355 | sceIoGetstatByFd(dfd, &stat);
356 |
357 | stat.st_mode |= SCE_S_IWUSR;
358 |
359 | int ret = sceIoMkdir(dst_path, stat.st_mode & 0xFFF);
360 | if (ret < 0 && ret != SCE_ERROR_ERRNO_EEXIST) {
361 | sceIoDclose(dfd);
362 | return ret;
363 | }
364 |
365 | if (ret == SCE_ERROR_ERRNO_EEXIST) {
366 | sceIoChstat(dst_path, &stat, 0x3B);
367 | }
368 |
369 | if (param) {
370 | if (param->value)
371 | (*param->value) += DIRECTORY_SIZE;
372 |
373 | if (param->SetProgress)
374 | param->SetProgress(param->value ? *param->value : 0, param->max);
375 |
376 | if (param->cancelHandler && param->cancelHandler()) {
377 | sceIoDclose(dfd);
378 | return 0;
379 | }
380 | }
381 |
382 | int res = 0;
383 |
384 | do {
385 | SceIoDirent dir;
386 | memset(&dir, 0, sizeof(SceIoDirent));
387 |
388 | res = sceIoDread(dfd, &dir);
389 | if (res > 0) {
390 | char *new_src_path = malloc(strlen(src_path) + strlen(dir.d_name) + 2);
391 | snprintf(new_src_path, MAX_PATH_LENGTH, "%s%s%s", src_path, hasEndSlash(src_path) ? "" : "/", dir.d_name);
392 |
393 | char *new_dst_path = malloc(strlen(dst_path) + strlen(dir.d_name) + 2);
394 | snprintf(new_dst_path, MAX_PATH_LENGTH, "%s%s%s", dst_path, hasEndSlash(dst_path) ? "" : "/", dir.d_name);
395 |
396 | int ret = 0;
397 |
398 | if (SCE_S_ISDIR(dir.d_stat.st_mode)) {
399 | ret = copyPath(new_src_path, new_dst_path, param);
400 | } else {
401 | ret = copyFile(new_src_path, new_dst_path, param);
402 | }
403 |
404 | free(new_dst_path);
405 | free(new_src_path);
406 |
407 | if (ret <= 0) {
408 | sceIoDclose(dfd);
409 | return ret;
410 | }
411 | }
412 | } while (res > 0);
413 |
414 | sceIoDclose(dfd);
415 | } else {
416 | return copyFile(src_path, dst_path, param);
417 | }
418 |
419 | return 1;
420 | }
421 |
422 | int movePath(const char *src_path, const char *dst_path, int flags, FileProcessParam *param) {
423 | // The source and destination paths are identical
424 | if (strcasecmp(src_path, dst_path) == 0) {
425 | return VITASHELL_ERROR_SRC_AND_DST_IDENTICAL;
426 | }
427 |
428 | // The destination is a subfolder of the source folder
429 | int len = strlen(src_path);
430 | if (strncasecmp(src_path, dst_path, len) == 0 && (dst_path[len] == '/' || dst_path[len - 1] == '/')) {
431 | return VITASHELL_ERROR_DST_IS_SUBFOLDER_OF_SRC;
432 | }
433 |
434 | int res = sceIoRename(src_path, dst_path);
435 |
436 | if (res == SCE_ERROR_ERRNO_EEXIST && flags & (MOVE_INTEGRATE | MOVE_REPLACE)) {
437 | // Src stat
438 | SceIoStat src_stat;
439 | memset(&src_stat, 0, sizeof(SceIoStat));
440 | res = sceIoGetstat(src_path, &src_stat);
441 | if (res < 0)
442 | return res;
443 |
444 | // Dst stat
445 | SceIoStat dst_stat;
446 | memset(&dst_stat, 0, sizeof(SceIoStat));
447 | res = sceIoGetstat(dst_path, &dst_stat);
448 | if (res < 0)
449 | return res;
450 |
451 | // Is dir
452 | int src_is_dir = SCE_S_ISDIR(src_stat.st_mode);
453 | int dst_is_dir = SCE_S_ISDIR(dst_stat.st_mode);
454 |
455 | // One of them is a file and the other a directory, no replacement or integration possible
456 | if (src_is_dir != dst_is_dir)
457 | return VITASHELL_ERROR_INVALID_TYPE;
458 |
459 | // Replace file
460 | if (!src_is_dir && !dst_is_dir && flags & MOVE_REPLACE) {
461 | sceIoRemove(dst_path);
462 |
463 | res = sceIoRename(src_path, dst_path);
464 | if (res < 0)
465 | return res;
466 |
467 | return 1;
468 | }
469 |
470 | // Integrate directory
471 | if (src_is_dir && dst_is_dir && flags & MOVE_INTEGRATE) {
472 | SceUID dfd = sceIoDopen(src_path);
473 | if (dfd < 0)
474 | return dfd;
475 |
476 | int res = 0;
477 |
478 | do {
479 | SceIoDirent dir;
480 | memset(&dir, 0, sizeof(SceIoDirent));
481 |
482 | res = sceIoDread(dfd, &dir);
483 | if (res > 0) {
484 | char *new_src_path = malloc(strlen(src_path) + strlen(dir.d_name) + 2);
485 | snprintf(new_src_path, MAX_PATH_LENGTH, "%s%s%s", src_path, hasEndSlash(src_path) ? "" : "/", dir.d_name);
486 |
487 | char *new_dst_path = malloc(strlen(dst_path) + strlen(dir.d_name) + 2);
488 | snprintf(new_dst_path, MAX_PATH_LENGTH, "%s%s%s", dst_path, hasEndSlash(dst_path) ? "" : "/", dir.d_name);
489 |
490 | // Recursive move
491 | int ret = movePath(new_src_path, new_dst_path, flags, param);
492 |
493 | free(new_dst_path);
494 | free(new_src_path);
495 |
496 | if (ret <= 0) {
497 | sceIoDclose(dfd);
498 | return ret;
499 | }
500 | }
501 | } while (res > 0);
502 |
503 | sceIoDclose(dfd);
504 |
505 | // Integrated, now remove this directory
506 | sceIoRmdir(src_path);
507 | }
508 | }
509 |
510 | return 1;
511 | }
512 |
513 | // get directory path from filename
514 | // result has slash at the end
515 | char * getBaseDirectory(const char * path) {
516 | int i;
517 | int sep_ind = -1;
518 | int len = strlen(path);
519 | if (len > MAX_PATH_LENGTH - 1 || len <= 0) return NULL;
520 | for(i = len - 1; i >=0; i --) {
521 | if (path[i] == '/' || path[i] == ':') {
522 | sep_ind = i;
523 | break;
524 | }
525 | }
526 | if (sep_ind == -1) return NULL;
527 |
528 | char * res = (char *) malloc(MAX_PATH_LENGTH);
529 | if (!res) return NULL;
530 |
531 | strncpy(res, path, MAX_PATH_LENGTH);
532 | res[sep_ind + 1] = '\0';
533 | return res;
534 | }
535 |
536 | // returns NULL when no filename found or error
537 | // result is at most MAX_PATH_LEN
538 | char * getFilename(const char *path) {
539 | int i;
540 | int sep_ind = -1;
541 | int len = strlen(path);
542 | if (len > MAX_PATH_LENGTH || len <= 0) return NULL;
543 | if (path[len - 1] == '/' || path[len - 1] == ':') return NULL; // no file
544 |
545 | for(i = len - 1; i >=0; i --) {
546 | if (path[i] == '/' || path[i] == ':') {
547 | sep_ind = i;
548 | break;
549 | }
550 | }
551 | if (sep_ind == -1) return NULL;
552 | char * res = (char *) malloc(MAX_PATH_LENGTH);
553 | if (!res) return NULL;
554 |
555 | int new_len = len - (sep_ind + 1);
556 | strncpy(res, path + (sep_ind + 1), new_len); // dont copy separation char
557 | if (new_len + 1 < MAX_PATH_LENGTH)
558 | res[new_len] = '\0';
559 | else
560 | res[MAX_PATH_LENGTH - 1] = '\0';
561 | return res;
562 | }
563 |
564 | int hasEndSlash(const char *path) {
565 | return path[strlen(path) - 1] == '/';
566 | }
567 |
568 | int removeEndSlash(char *path) {
569 | int len = strlen(path);
570 |
571 | if (path[len - 1] == '/') {
572 | path[len - 1] = '\0';
573 | return 1;
574 | }
575 |
576 | return 0;
577 | }
578 |
579 | int addEndSlash(char *path) {
580 | int len = strlen(path);
581 | if (len < MAX_PATH_LENGTH - 2) {
582 | if (path[len - 1] != '/') {
583 | path[len] = '/';
584 | path[len + 1] = '\0';
585 | return 1;
586 | }
587 | }
588 |
589 | return 0;
590 | }
591 |
--------------------------------------------------------------------------------
/src/debugScreen.c:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG_SCREEN_C
2 | #define DEBUG_SCREEN_C
3 |
4 | /*
5 | * debugScreen.c of Vita SDK
6 | *
7 | * - psvDebugScreenInit()
8 | * Initializes debug screen for output.
9 | *
10 | * - psvDebugScreenPuts()
11 | * Similar to the C library function puts() writes a string to the debug
12 | * screen up to but not including the NUL character.
13 | * Supports the most important CSI sequences of ECMA-48 / ISO/IEC 6429:1992.
14 | * Graphic Rendition Combination Mode (GRCM) supported is Cumulative.
15 | * Modifications:
16 | * - CSI SGR codes 30-37/38/39 & 40-47/48/49 set standard/fitting/default intensity, so instead of "\e[1;31m" use "\e31;1m"
17 | * - ANSI color #8 is made darker (40<>80), so that "dark" white is still lighter than "bright" dark
18 | * - support 16 save storages for CSI s and CSI u, e.g "\e[8s" and "\e[8u"
19 | * [1] https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences
20 | * [2] https://jonasjacek.github.io/colors/
21 | * [3] https://www.ecma-international.org/publications/standards/Ecma-048.htm
22 | * [4] https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
23 | * [5] http://man7.org/linux/man-pages/man4/console_codes.4.html
24 | *
25 | * (CSI = "\e[")
26 | * CSI [n] s = Save Cursor Position to slot #n (0-15). Default 0.
27 | * CSI [n] u = Restore Cursor Position from slot #n (0-15). Default 0.
28 | * CSI n A = Cursor Up times.
29 | * CSI n B = Cursor Down times.
30 | * CSI n C = Cursor Forward times.
31 | * CSI n D = Cursor Back times.
32 | * CSI n E = Cursor Next Line times and to Beginning of that Line.
33 | * CSI n F = Cursor Previous Line times and to Beginning of that Line.
34 | * CSI n G = Cursor to Column . The value is 1-based and defaults to 1 (first column) if omitted.
35 | * CSI n ; m H = Cursor to Row and Column . The values are 1-based and default to 1 (top left corner) if omitted.
36 | * CSI n ; m f = Cursor to Row and Column . The values are 1-based and default to 1 (top left corner) if omitted.
37 | * CSI [n] J = Clears part of the screen. Cursor position does not change.
38 | * 0 (default) from cursor to end of screen.
39 | * 1 from cursor to beginning of the screen.
40 | * 2 entire screen
41 | * CSI [n] K = Clears part of the line. Cursor position does not change.
42 | * 0 (default) from cursor to end of line.
43 | * 1 from cursor to beginning of line.
44 | * 2 clear entire line.
45 | * CSI [n] m = Sets the appearance of the following characters.
46 | * 0 Reset all (colors and inversion) (default)
47 | * 1 Increased intensity ("bright" color)
48 | * 2 Decreased intensity ("faint"/"dark" color)
49 | * 7 Enable inversion
50 | * 22 Standard intensity ("normal" color)
51 | * 27 Disable inversion
52 | * 30–37 Set ANSI foreground color with standard intensity
53 | * 38 Set foreground color. Arguments are 5; or 2;;;
54 | * 39 Default foreground color
55 | * 40–47 Set standard ANSI background color with standard intensity
56 | * 48 Set background color. Arguments are 5; or 2;;;
57 | * 49 Default background color
58 | * 90–97 Set ANSI foreground color with increased intensity
59 | * 100–107 Set ANSI background color with increased intensity
60 | *
61 | * - psvDebugScreenPrintf()
62 | * Similar to the C library function printf() formats a string and ouputs
63 | * it via psvDebugScreenPuts() to the debug screen.
64 | *
65 | * - psvDebugScreenGetColorStateCopy(ColorState *copy)
66 | * Get copy of current color state.
67 | *
68 | * - psvDebugScreenGetCoordsXY(int *x, int *y)
69 | * Get copy of current pixel coordinates.
70 | * Allows for multiple and custom position stores.
71 | * Allows correct positioning when using different font sizes.
72 | *
73 | * - psvDebugScreenSetCoordsXY(int *x, int *y)
74 | * Set pixel coordinates.
75 | * Allows for multiple and custom position stores.
76 | * Allows correct positioning when using different font sizes.
77 | *
78 | * - PsvDebugScreenFont *psvDebugScreenGetFont()
79 | * Get current font.
80 | *
81 | * - PsvDebugScreenFont *psvDebugScreenSetFont(PsvDebugScreenFont *font) {
82 | * Set font. Returns current font.
83 | *
84 | * - PsvDebugScreenFont *psvDebugScreenScaleFont2x(PsvDebugScreenFont *source_font) {
85 | * Scales a font by 2 (e.g. 8x8 to 16x16) and returns new scaled font.
86 | *
87 | * Also see the following samples:
88 | * - debugscreen
89 | * - debug_print
90 | *
91 | */
92 |
93 | #include // for malloc(), free()
94 | #include // for vsnprintf()
95 | #include // for memset(), memcpy()
96 | #include // for va_list, va_start(), va_end()
97 | #include
98 |
99 | #include "debugScreen.h"
100 |
101 | #include "debugScreenFont.c"
102 |
103 | #define SCREEN_FB_WIDTH (960) // frame buffer aligned width for accessing vram
104 | #define SCREEN_FB_SIZE (2 * 1024 * 1024) // Must be 256KB aligned
105 | #ifndef SCREEN_TAB_SIZE // this allows easy overriding
106 | #define SCREEN_TAB_SIZE (8)
107 | #endif
108 | #define SCREEN_TAB_W ((F)->size_w * (SCREEN_TAB_SIZE))
109 | #define F psvDebugScreenFontCurrent
110 |
111 | #define FROM_FULL_RGB(r,g,b ) ( ((b)<<16) | ((g)<<8) | (r) )
112 | #define CONVERT_RGB_BGR(rgb) rgb = ( (((rgb)&0x0000FF)<<16) | ((rgb)&0x00FF00) | (((rgb)&0xFF0000)>>16) )
113 |
114 | #define CLEARSCRNBLOCK(H,toH,W,toW,color) for (int h = (H); h < (toH); h++) for (int w = (W); w < (toW); w++) ((uint32_t*)base)[h*(SCREEN_FB_WIDTH) + w] = (color);
115 | #define CLEARSCRNLINES(H,toH,color) { uint32_t *pixel = (uint32_t *)base + ((H) * (SCREEN_FB_WIDTH)); int i = (((toH) - (H)) * (SCREEN_FB_WIDTH)); for (; i > 0; i--) *pixel++ = (color); }
116 |
117 | #define SAVE_STORAGES 16
118 |
119 | static int mutex, coordX, coordY;
120 | static int savedX[SAVE_STORAGES] = { 0 }, savedY[SAVE_STORAGES] = { 0 };
121 | static ColorState colors = {
122 | 0, 0, // truecolor flags
123 | 0, 0, // truecolors
124 | 0, 0, 0, 0, 0, // ANSI/VTERM/GREYSCALE colors
125 | 7, 22, 0, 22, 0, // default colors (ANSI/VTERM/GREYSCALE)
126 | };
127 |
128 | static PsvDebugScreenFont *psvDebugScreenFontCurrent = &psvDebugScreenFont;
129 |
130 | #ifdef __vita__
131 | #include
132 | #include
133 | #include
134 | static void* base; // pointer to frame buffer
135 | #else
136 | #define NO_psvDebugScreenInit
137 | #ifndef psvDebugScreenInitReplacement
138 | #define psvDebugScreenInitReplacement(...)
139 | #endif
140 | #define sceKernelLockMutex(m,v,x) m=v
141 | #define sceKernelUnlockMutex(m,v) m=v
142 | static char base[(SCREEN_FB_WIDTH) * (SCREEN_HEIGHT) * 4];
143 | #endif
144 |
145 | static uint32_t DARK_COLORS_BGR[8] = {
146 | 0x000000, 0x000040, 0x004000, 0x004040, 0x400000, 0x400040, 0x404000, 0x808080, // 0-7
147 | };
148 |
149 | // ANSI/VTERM/GREYSCALE palette: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
150 | // modifications:
151 | // - #8 is made darker (40<>80), so that "dark" white is still lighter than "bright" dark
152 | static uint32_t ANSI_COLORS_BGR[256] = {
153 | 0x000000, 0x000080, 0x008000, 0x008080, 0x800000, 0x800080, 0x808000, 0xc0c0c0, // 0-7
154 | 0x404040, 0x0000ff, 0x00ff00, 0x00ffff, 0xff0000, 0xff00ff, 0xffff00, 0xffffff, // 8-15
155 | 0x000000, 0x5f0000, 0x870000, 0xaf0000, 0xd70000, 0xff0000, 0x005f00, 0x5f5f00, // 16-23
156 | 0x875f00, 0xaf5f00, 0xd75f00, 0xff5f00, 0x008700, 0x5f8700, 0x878700, 0xaf8700, // 24-31
157 | 0xd78700, 0xff8700, 0x00af00, 0x5faf00, 0x87af00, 0xafaf00, 0xd7af00, 0xffaf00, // 32-39
158 | 0x00d700, 0x5fd700, 0x87d700, 0xafd700, 0xd7d700, 0xffd700, 0x00ff00, 0x5fff00, // 40-47
159 | 0x87ff00, 0xafff00, 0xd7ff00, 0xffff00, 0x00005f, 0x5f005f, 0x87005f, 0xaf005f, // 48-55
160 | 0xd7005f, 0xff005f, 0x005f5f, 0x5f5f5f, 0x875f5f, 0xaf5f5f, 0xd75f5f, 0xff5f5f, // 56-63
161 | 0x00875f, 0x5f875f, 0x87875f, 0xaf875f, 0xd7875f, 0xff875f, 0x00af5f, 0x5faf5f, // 64-71
162 | 0x87af5f, 0xafaf5f, 0xd7af5f, 0xffaf5f, 0x00d75f, 0x5fd75f, 0x87d75f, 0xafd75f, // 72-79
163 | 0xd7d75f, 0xffd75f, 0x00ff5f, 0x5fff5f, 0x87ff5f, 0xafff5f, 0xd7ff5f, 0xffff5f, // 80-87
164 | 0x000087, 0x5f0087, 0x870087, 0xaf0087, 0xd70087, 0xff0087, 0x005f87, 0x5f5f87, // 88-95
165 | 0x875f87, 0xaf5f87, 0xd75f87, 0xff5f87, 0x008787, 0x5f8787, 0x878787, 0xaf8787, // 96-103
166 | 0xd78787, 0xff8787, 0x00af87, 0x5faf87, 0x87af87, 0xafaf87, 0xd7af87, 0xffaf87, // 104-111
167 | 0x00d787, 0x5fd787, 0x87d787, 0xafd787, 0xd7d787, 0xffd787, 0x00ff87, 0x5fff87, // 112-119
168 | 0x87ff87, 0xafff87, 0xd7ff87, 0xffff87, 0x0000af, 0x5f00af, 0x8700af, 0xaf00af, // 120-127
169 | 0xd700af, 0xff00af, 0x005faf, 0x5f5faf, 0x875faf, 0xaf5faf, 0xd75faf, 0xff5faf, // 128-135
170 | 0x0087af, 0x5f87af, 0x8787af, 0xaf87af, 0xd787af, 0xff87af, 0x00afaf, 0x5fafaf, // 136-143
171 | 0x87afaf, 0xafafaf, 0xd7afaf, 0xffafaf, 0x00d7af, 0x5fd7af, 0x87d7af, 0xafd7af, // 144-151
172 | 0xd7d7af, 0xffd7af, 0x00ffaf, 0x5fffaf, 0x87ffaf, 0xafffaf, 0xd7ffaf, 0xffffaf, // 152-159
173 | 0x0000d7, 0x5f00d7, 0x8700d7, 0xaf00d7, 0xd700d7, 0xff00d7, 0x005fd7, 0x5f5fd7, // 160-167
174 | 0x875fd7, 0xaf5fd7, 0xd75fd7, 0xff5fd7, 0x0087d7, 0x5f87d7, 0x8787d7, 0xaf87d7, // 168-175
175 | 0xd787d7, 0xff87d7, 0x00afd7, 0x5fafd7, 0x87afd7, 0xafafd7, 0xd7afd7, 0xffafd7, // 176-183
176 | 0x00d7d7, 0x5fd7d7, 0x87d7d7, 0xafd7d7, 0xd7d7d7, 0xffd7d7, 0x00ffd7, 0x5fffd7, // 184-191
177 | 0x87ffd7, 0xafffd7, 0xd7ffd7, 0xffffd7, 0x0000ff, 0x5f00ff, 0x8700ff, 0xaf00ff, // 192-199
178 | 0xd700ff, 0xff00ff, 0x005fff, 0x5f5fff, 0x875fff, 0xaf5fff, 0xd75fff, 0xff5fff, // 200-207
179 | 0x0087ff, 0x5f87ff, 0x8787ff, 0xaf87ff, 0xd787ff, 0xff87ff, 0x00afff, 0x5fafff, // 208-215
180 | 0x87afff, 0xafafff, 0xd7afff, 0xffafff, 0x00d7ff, 0x5fd7ff, 0x87d7ff, 0xafd7ff, // 216-223
181 | 0xd7d7ff, 0xffd7ff, 0x00ffff, 0x5fffff, 0x87ffff, 0xafffff, 0xd7ffff, 0xffffff, // 224-231
182 | 0x080808, 0x121212, 0x1c1c1c, 0x262626, 0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e, // 232-239
183 | 0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e, // 240-247
184 | 0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee, // 248-255
185 | };
186 |
187 | /*
188 | * Reset foreground color to default
189 | */
190 | static void psvDebugScreenResetFgColor(void) {
191 | colors.fgTrueColorFlag = 0;
192 | colors.fgTrueColor = 0;
193 | colors.fgIndex = colors.fgIndexDefault;
194 | colors.fgIntensity = colors.fgIntensityDefault;
195 | }
196 |
197 | /*
198 | * Reset background color to default
199 | */
200 | static void psvDebugScreenResetBgColor(void) {
201 | colors.bgTrueColorFlag = 0;
202 | colors.bgTrueColor = 0;
203 | colors.bgIndex = colors.bgIndexDefault;
204 | colors.bgIntensity = colors.bgIntensityDefault;
205 | }
206 |
207 | /*
208 | * Reset inversion state to default
209 | */
210 | static void psvDebugScreenResetInversion(void) {
211 | colors.inversion = colors.inversionDefault;
212 | }
213 |
214 | /*
215 | * Determine colors according to current color state
216 | */
217 | static void psvDebugScreenSetColors(void) {
218 | uint32_t *color_fg, *color_bg;
219 |
220 | // special case: inversion
221 | if (!colors.inversion) {
222 | color_fg = &colors.color_fg;
223 | color_bg = &colors.color_bg;
224 | } else {
225 | color_fg = &colors.color_bg;
226 | color_bg = &colors.color_fg;
227 | }
228 |
229 | // foregound color
230 | if ((colors.fgIndex<=7) && (colors.fgIntensity==1)) { // ANSI palette with increased intensity
231 | colors.fgIndex |= 0x8;
232 | } else if ((colors.fgIndex<=15) && (colors.fgIntensity!=1)) { // ANSI palette with standard/decreased intensity
233 | colors.fgIndex &= 0x7;
234 | }
235 | if (colors.fgTrueColorFlag) {
236 | *color_fg = colors.fgTrueColor;
237 | } else {
238 | if ((colors.fgIndex<=7) && (colors.fgIntensity==2)) { // "ANSI" palette with decreased intensity
239 | *color_fg = DARK_COLORS_BGR[colors.fgIndex];
240 | } else { // ANSI/VTERM/GREYSCALE palette
241 | *color_fg = ANSI_COLORS_BGR[colors.fgIndex];
242 | }
243 | }
244 | *color_fg |= 0xFF000000; // opaque
245 |
246 | // backgound color
247 | if ((colors.bgIndex<=7) && (colors.bgIntensity==1)) { // ANSI palette with increased intensity
248 | colors.bgIndex |= 0x8;
249 | } else if ((colors.bgIndex<=15) && (colors.bgIntensity!=1)) { // ANSI palette with standard/decreased intensity
250 | colors.bgIndex &= 0x7;
251 | }
252 | if (colors.bgTrueColorFlag) {
253 | *color_bg = colors.bgTrueColor;
254 | } else {
255 | if ((colors.bgIndex<=7) && (colors.bgIntensity==2)) { // "ANSI" palette with decreased intensity
256 | *color_bg = DARK_COLORS_BGR[colors.bgIndex];
257 | } else { // ANSI/VTERM/GREYSCALE palette
258 | *color_bg = ANSI_COLORS_BGR[colors.bgIndex];
259 | }
260 | }
261 | *color_bg |= 0xFF000000; // opaque
262 | }
263 |
264 | /*
265 | * Parse CSI sequences
266 | */
267 | static size_t psvDebugScreenEscape(const unsigned char *str) {
268 | unsigned int i, argc, arg[32] = { 0 };
269 | unsigned int c;
270 | uint32_t unit, mode;
271 | int *colorTrueColorFlag;
272 | uint32_t *colorTrueColor;
273 | unsigned char *colorIndex, *colorIntensity;
274 | for (i = 0, argc = 0; (argc < (sizeof(arg)/sizeof(*arg))) && (str[i] != '\0'); i++) {
275 | switch (str[i]) {
276 | // numeric char
277 | case '0':
278 | case '1':
279 | case '2':
280 | case '3':
281 | case '4':
282 | case '5':
283 | case '6':
284 | case '7':
285 | case '8':
286 | case '9':
287 | arg[argc] = (arg[argc] * 10) + (str[i] - '0');
288 | continue;
289 | // argument separator
290 | case ';': argc++; continue;
291 | // CSI commands
292 | // save/restore position
293 | case 's':
294 | if (arg[0]size_h; return i;
301 | case 'B': coordY += arg[0] * (F)->size_h; return i;
302 | case 'C': coordX += arg[0] * (F)->size_w; return i;
303 | case 'D': coordX -= arg[0] * (F)->size_w; return i;
304 | // cursor movement to beginning of next/previous line(s)
305 | case 'E': coordY += arg[0] * (F)->size_h; coordX = 0; return i;
306 | case 'F': coordY -= arg[0] * (F)->size_h; coordX = 0; return i;
307 | // cursor positioning
308 | case 'G': coordX = (arg[0]-1) * (F)->size_w; return i;
309 | case 'H':
310 | case 'f':
311 | coordY = (arg[0]-1) * (F)->size_h;
312 | coordX = (arg[1]-1) * (F)->size_w;
313 | return i;
314 | // clear part of "J"=screen or "K"=Line, so J code re-uses part of K
315 | case 'J':
316 | case 'K':
317 | if (arg[0]==0) { // from cursor to end of line/screen
318 | CLEARSCRNBLOCK(coordY, coordY + (F)->size_h, coordX, (SCREEN_WIDTH), colors.color_bg); // line
319 | if (str[i]=='J') CLEARSCRNLINES(coordY + (F)->size_h, (SCREEN_HEIGHT), colors.color_bg); // screen
320 | } else if (arg[0]==1) { // from beginning of line/screen to cursor
321 | CLEARSCRNBLOCK(coordY, coordY + (F)->size_h, 0, coordX, colors.color_bg); // line
322 | if (str[i]=='J') CLEARSCRNLINES(0, coordY, colors.color_bg); // screen
323 | } else if (arg[0]==2) { // whole line/screen
324 | if (str[i]=='K') CLEARSCRNLINES(coordY, coordY + (F)->size_h, colors.color_bg) // line
325 | else if (str[i]=='J') CLEARSCRNLINES(0, (SCREEN_HEIGHT), colors.color_bg); // screen
326 | }
327 | return i;
328 | // color
329 | case 'm':
330 | for (c = 0; c <= argc; c++) {
331 | switch (arg[c]) {
332 | // reset all
333 | case 0:
334 | psvDebugScreenResetFgColor();
335 | psvDebugScreenResetBgColor();
336 | psvDebugScreenResetInversion();
337 | continue;
338 | break;
339 | // intensity
340 | case 1: // increased = "bright" color
341 | case 2: // decreased = "dark" color
342 | case 22: // standard = "normal" color
343 | colors.fgIntensity = arg[c];
344 | continue;
345 | break;
346 | // inversion
347 | case 7: // enable
348 | colors.inversion = 1;
349 | continue;
350 | break;
351 | case 27: // disable
352 | colors.inversion = 0;
353 | continue;
354 | break;
355 | // set from color map or truecolor
356 | case 38: // foreground color
357 | case 48: // background color
358 | mode = arg[c] / 10;
359 | colorTrueColorFlag = mode&1 ? &colors.fgTrueColorFlag : &colors.bgTrueColorFlag;
360 | if (arg[c+1]==5) { // 8-bit: [0-15][16-231][232-255] color map
361 | *colorTrueColorFlag = 0;
362 | colorIndex = mode&1 ? &colors.fgIndex : &colors.bgIndex;
363 | *colorIndex = arg[c+2] & 0xFF;
364 | colorIntensity = mode&1 ? &colors.fgIntensity : &colors.bgIntensity;
365 | *colorIntensity = ((*colorIndex>=8) && (*colorIndex<=15)) ? 1 : 22;
366 | c+=2; // extra arguments
367 | } else if (arg[c+1]==2) { // 24-bit color space
368 | *colorTrueColorFlag = 1;
369 | colorTrueColor = mode&1 ? &colors.fgTrueColor : &colors.bgTrueColor;
370 | *colorTrueColor = FROM_FULL_RGB(arg[c+2], arg[c+3], arg[c+4]);
371 | c+=4; // extra arguments
372 | }
373 | continue;
374 | break;
375 | // default color
376 | case 39: // foreground color
377 | psvDebugScreenResetFgColor();
378 | continue;
379 | break;
380 | case 49: // background color
381 | psvDebugScreenResetBgColor();
382 | continue;
383 | break;
384 | // custom color reset
385 | default:
386 | // ANSI colors (30-37, 40-47, 90-97, 100-107)
387 | mode = arg[c] / 10;
388 | if ((mode!=3) && (mode!=4) && (mode!=9) && (mode!=10)) continue; // skip unsupported modes
389 | unit = arg[c] % 10;
390 | if (unit>7) continue; // skip unsupported modes
391 | colorTrueColorFlag = mode&1 ? &colors.fgTrueColorFlag : &colors.bgTrueColorFlag;
392 | *colorTrueColorFlag = 0;
393 | colorIndex = mode&1 ? &colors.fgIndex : &colors.bgIndex;
394 | *colorIndex = unit;
395 | colorIntensity = mode&1 ? &colors.fgIntensity : &colors.bgIntensity;
396 | *colorIntensity = mode&8 ? 1 : 22;
397 | break;
398 | }
399 | }
400 | psvDebugScreenSetColors();
401 | return i;
402 | }
403 | }
404 | return 0;
405 | }
406 |
407 | /*
408 | * Initialize debug screen
409 | */
410 | int psvDebugScreenInit() {
411 | psvDebugScreenResetFgColor();
412 | psvDebugScreenResetBgColor();
413 | psvDebugScreenResetInversion();
414 | psvDebugScreenSetColors();
415 |
416 | #ifdef NO_psvDebugScreenInit
417 | psvDebugScreenInitReplacement();
418 | return 0; // avoid linking non-initializer (prx) with sceDisplay/sceMemory
419 | #else
420 | mutex = sceKernelCreateMutex("log_mutex", 0, 0, NULL);
421 | SceUID displayblock = sceKernelAllocMemBlock("display", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, (SCREEN_FB_SIZE), NULL);
422 | sceKernelGetMemBlockBase(displayblock, (void**)&base);
423 | SceDisplayFrameBuf frame = { sizeof(frame), base, (SCREEN_FB_WIDTH), 0, (SCREEN_WIDTH), (SCREEN_HEIGHT) };
424 | return sceDisplaySetFrameBuf(&frame, SCE_DISPLAY_SETBUF_NEXTFRAME);
425 | #endif
426 | }
427 |
428 | /*
429 | * Draw text onto debug screen
430 | */
431 | int psvDebugScreenPuts(const char * _text) {
432 | const unsigned char*text = (const unsigned char*)_text;
433 | int c;
434 | unsigned char t;
435 | unsigned char drawDummy;
436 | //
437 | uint32_t *vram;
438 | int bits_per_glyph = ((F)->width * (F)->height);
439 | int bitmap_offset;
440 | unsigned char *font;
441 | int row;
442 | int max_row;
443 | int col;
444 | unsigned char mask;
445 | uint32_t *pixel;
446 |
447 | sceKernelLockMutex(mutex, 1, NULL);
448 | for (c = 0; text[c] ; c++) {
449 | t = text[c];
450 | // handle CSI sequence
451 | if ((t == '\e') && (text[c+1] == '[')) {
452 | c += psvDebugScreenEscape(text + c + 2) + 2;
453 | if (coordX < 0) coordX = 0; // CSI position are 1-based,
454 | if (coordY < 0) coordY = 0; // prevent 0-based coordinate from producing a negative X/Y
455 | continue;
456 | }
457 | // handle non-printable characters #1 (line-dependent codes)
458 | if (t == '\n') {
459 | coordX = 0;
460 | coordY += (F)->size_h;
461 | continue;
462 | }
463 | if (t == '\r') {
464 | coordX = 0;
465 | continue;
466 | }
467 | // check if glyph fits in line
468 | if ((coordX + (F)->width) > (SCREEN_WIDTH)) {
469 | coordY += (F)->size_h;
470 | coordX = 0;
471 | }
472 | // check if glyph fits in screen
473 | if ((coordY + (F)->height) > (SCREEN_HEIGHT)) {
474 | coordX = coordY = 0;
475 | }
476 | // handle non-printable characters #2
477 | if (t == '\t') {
478 | coordX += (SCREEN_TAB_W) - (coordX % (SCREEN_TAB_W));
479 | continue;
480 | }
481 |
482 | // draw glyph or dummy glyph (dotted line in the middle)
483 | // works also with not byte-aligned glyphs
484 | vram = ((uint32_t*)base) + coordX + (coordY * (SCREEN_FB_WIDTH));
485 | row = 0;
486 | // check if glyph is available in font
487 | if ((t > (F)->last) || (t < (F)->first)) {
488 | drawDummy = 1;
489 | } else {
490 | drawDummy = 0;
491 | bitmap_offset = (t - (F)->first) * bits_per_glyph;
492 | font = &(F)->glyphs[ (bitmap_offset / 8) ];
493 | mask = 1 << 7;
494 | for (col = (bitmap_offset % 8); col > 0; col--, mask >>= 1);
495 | }
496 | // special case: dummy glyph, clear to middle height
497 | max_row = 0;
498 | if (drawDummy) {
499 | max_row = (F)->height / 2;
500 | for (; row < max_row; row++, vram += (SCREEN_FB_WIDTH)) {
501 | pixel = vram;
502 | col = 0;
503 | for (; col < (F)->size_w ; col++) {
504 | *pixel++ = colors.color_bg;
505 | }
506 | }
507 | }
508 | // draw font glyph or dummy glyph
509 | if (drawDummy) {
510 | max_row++;
511 | if (max_row > (F)->height) max_row = (F)->height;
512 | } else {
513 | max_row = (F)->height;
514 | }
515 | for (; row < max_row; row++, vram += (SCREEN_FB_WIDTH)) {
516 | pixel = vram;
517 | col = 0;
518 | for (; col < (F)->width ; col++, mask >>= 1) {
519 | if (drawDummy) {
520 | *pixel++ = (col&1) ? colors.color_fg : colors.color_bg;
521 | } else {
522 | if (!mask) { font++; mask = 1 << 7; } // no more bits: we exhausted this byte
523 | *pixel++ = (*font&mask) ? colors.color_fg : colors.color_bg;
524 | }
525 | }
526 | // right margin
527 | for (; col < (F)->size_w ; col++)
528 | *pixel++ = colors.color_bg;
529 | }
530 | // draw bottom margin
531 | max_row = (F)->size_h;
532 | for (; row < (F)->size_h; row++, vram += (SCREEN_FB_WIDTH))
533 | for (pixel = vram, col = 0; col < (F)->size_w ; col++)
534 | *pixel++ = colors.color_bg;
535 | // advance X position
536 | coordX += (F)->size_w;
537 | }
538 | sceKernelUnlockMutex(mutex, 1);
539 | return c;
540 | }
541 |
542 |
543 | /*
544 | * Printf text onto debug screen
545 | */
546 | __attribute__((__format__ (__printf__, 1, 2)))
547 | int psvDebugScreenPrintf(const char *format, ...) {
548 | char buf[4096];
549 |
550 | va_list opt;
551 | va_start(opt, format);
552 | int ret = vsnprintf(buf, sizeof(buf), format, opt);
553 | psvDebugScreenPuts(buf);
554 | va_end(opt);
555 |
556 | return ret;
557 | }
558 |
559 | /*
560 | * Return copy of color state
561 | */
562 | void psvDebugScreenGetColorStateCopy(ColorState *copy) {
563 | if (copy) {
564 | memcpy(copy, &colors, sizeof(ColorState));
565 | CONVERT_RGB_BGR(copy->fgTrueColor);
566 | CONVERT_RGB_BGR(copy->bgTrueColor);
567 | CONVERT_RGB_BGR(copy->color_fg);
568 | CONVERT_RGB_BGR(copy->color_bg);
569 | }
570 | }
571 |
572 | /*
573 | * Return copy of pixel coordinates
574 | */
575 | void psvDebugScreenGetCoordsXY(int *x, int *y) {
576 | if (x) *x = coordX;
577 | if (y) *y = coordY;
578 | }
579 |
580 | /*
581 | * Set pixel coordinates
582 | */
583 | void psvDebugScreenSetCoordsXY(int *x, int *y) {
584 | if (x) {
585 | coordX = *x;
586 | if (coordX < 0) coordX = 0;
587 | }
588 | if (y) {
589 | coordY = *y;
590 | if (coordY < 0) coordY = 0;
591 | }
592 | }
593 |
594 | /*
595 | * Return pointer to current font
596 | */
597 | PsvDebugScreenFont *psvDebugScreenGetFont(void) {
598 | return F;
599 | }
600 |
601 | /*
602 | * Set font
603 | */
604 | PsvDebugScreenFont *psvDebugScreenSetFont(PsvDebugScreenFont *font) {
605 | if ((font) && (font->glyphs)) F = font;
606 | return F;
607 | }
608 |
609 | /*
610 | * Return scaled-by-2 copy of font
611 | */
612 | PsvDebugScreenFont *psvDebugScreenScaleFont2x(PsvDebugScreenFont *source_font) {
613 | // works also with not byte-aligned glyphs
614 | PsvDebugScreenFont *target_font;
615 | size_t size;
616 | size_t align;
617 | int glyph;
618 | int row;
619 | int col;
620 | int count;
621 | unsigned char *source_bitmap;
622 | unsigned char source_mask;
623 | unsigned char *target_bitmap, *target_bitmap2;
624 | unsigned char target_mask, target_mask2;
625 | int target_next_row_bytes, target_next_row_bits;
626 | unsigned char pixel;
627 |
628 | if (!source_font) return NULL;
629 |
630 | // allocate target structure and bitmap
631 | target_font = (PsvDebugScreenFont *)malloc(sizeof(PsvDebugScreenFont));
632 | memset(target_font, 0, sizeof(PsvDebugScreenFont));
633 | // copy and scale meta information
634 | target_font->width = 2 * source_font->width;
635 | target_font->height = 2 * source_font->height;
636 | target_font->first = source_font->first;
637 | target_font->last = source_font->last;
638 | target_font->size_w = 2 * source_font->size_w;
639 | target_font->size_h = 2 * source_font->size_h;
640 |
641 | // calculate size of target bitmap
642 | size = target_font->width * target_font->height * (target_font->last - target_font->first + 1);
643 | if (size <= 0) {
644 | free(target_font);
645 | return NULL;
646 | }
647 | align = size % 8;
648 | size /= 8;
649 | if (align) size++;
650 |
651 | // allocate and initialize target bitmap
652 | target_font->glyphs = (unsigned char *)malloc(size);
653 | memset(target_font->glyphs, 0, size);
654 |
655 | // scale source bitmap and store in target bitmap
656 | source_bitmap = source_font->glyphs;
657 | source_mask = 1 << 7;
658 | //
659 | target_bitmap = target_font->glyphs;
660 | target_mask = 1 << 7;
661 | target_next_row_bytes = target_font->width / 8;
662 | target_next_row_bits = target_font->width % 8;
663 | //
664 | for (glyph = source_font->first; glyph <= source_font->last; glyph++) {
665 | for (row = source_font->height; row > 0; row--) {
666 | // Find beginning of next target row
667 | target_bitmap2 = target_bitmap + target_next_row_bytes; // advance full bytes
668 | target_mask2 = target_mask; // advance remaining bits
669 | for (col = target_next_row_bits; col > 0; col--, target_mask2 >>= 1) {
670 | if (!target_mask2) { target_bitmap2++; target_mask2 = 1 << 7; } // no more bits: we advance to the next target byte
671 | }
672 | // Get pixel from source bitmap
673 | for (col = source_font->width; col > 0; col--, source_mask >>= 1) {
674 | if (!source_mask) { source_bitmap++; source_mask = 1 << 7; } // no more bits: we advance to the next source byte
675 | pixel = *source_bitmap & source_mask;
676 | // Put pixels into target bitmap
677 | for (count = 2; count > 0; count--) {
678 | // duplicate column in origial row
679 | if (!target_mask) { target_bitmap++; target_mask = 1 << 7; } // no more bits: we advance to the next target byte
680 | if (pixel) *target_bitmap |= target_mask;
681 | target_mask >>= 1;
682 | // duplicate column in duplicated row
683 | if (!target_mask2) { target_bitmap2++; target_mask2 = 1 << 7; } // no more bits: we advance to the next target byte
684 | if (pixel) *target_bitmap2 |= target_mask2;
685 | target_mask2 >>= 1;
686 | }
687 | }
688 | // Next target row is directly behind duplicated row
689 | target_bitmap = target_bitmap2;
690 | target_mask = target_mask2;
691 | }
692 | }
693 |
694 | return target_font;
695 | }
696 |
697 | #undef SCREEN_TAB_W
698 | #undef F
699 |
700 | #endif
701 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------