aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author浅倉麗子2020-07-12 12:07:06 -0400
committer浅倉麗子2020-07-12 12:07:06 -0400
commite06dd0c780a3645c1a0181979180e95031bea7d7 (patch)
treec71152e79bde84e220ad77261c665a8a62ab2d33
parentBuild with latest SDK and refactor CMake script (diff)
downloadsharpscale-e06dd0c780a3645c1a0181979180e95031bea7d7.tar.gz
Remove newlib
-rw-r--r--CMakeLists.txt8
-rw-r--r--config-app/CMakeLists.txt4
-rw-r--r--config-app/main.c13
-rw-r--r--scaling-test/CMakeLists.txt4
-rw-r--r--scaling-test/main.c33
5 files changed, 38 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 280b9cc..5afb681 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,10 @@ if(LOG_FILE)
add_compile_definitions(LOG_FILE)
endif()
+add_link_options(
+ -nostdlib
+)
+
# Build self
set(ELF "sharpscale.elf")
@@ -50,10 +54,6 @@ add_executable("${ELF}"
config.c
)
-target_link_options("${ELF}"
- PRIVATE -nostdlib
-)
-
target_link_libraries("${ELF}"
m
SceDebugForDriver_stub
diff --git a/config-app/CMakeLists.txt b/config-app/CMakeLists.txt
index 71ad12b..260747d 100644
--- a/config-app/CMakeLists.txt
+++ b/config-app/CMakeLists.txt
@@ -30,6 +30,7 @@ target_include_directories("${ELF}"
target_link_libraries("${ELF}"
vita2d_sys
m
+ gcc
Sharpscale_stub
SceAppMgr_stub
SceCtrl_stub
@@ -37,6 +38,7 @@ target_link_libraries("${ELF}"
SceGxm_stub
SceLibKernel_stub
ScePgf_stub
+ SceSysmem_stub
SceSysmodule_stub
)
@@ -55,7 +57,7 @@ dolce_create_self("${SELF}"
set(VPK "sharpscale-config.vpk")
set(TITLE_NAME "Sharpscale Configuration Menu")
set(TITLE_ID "AKRK00005")
-set(TITLE_VER "01.07")
+set(TITLE_VER "01.08")
dolce_create_vpk("${VPK}" "${TITLE_ID}" "${SELF}"
NAME "${TITLE_NAME}"
diff --git a/config-app/main.c b/config-app/main.c
index dbf629a..8c348a8 100644
--- a/config-app/main.c
+++ b/config-app/main.c
@@ -19,12 +19,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <psp2/appmgr.h>
#include <psp2/ctrl.h>
#include <psp2/kernel/clib.h>
+#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/sysmem.h>
#include <vita2d_sys.h>
#include "sharpscale.h"
-// do not need newlib heap
-int _newlib_heap_size_user = 4 * 1024;
+void *memset(void *dest, int ch, size_t count) {
+ return sceClibMemset(dest, ch, count);
+}
+
#define CLIB_HEAP_SIZE 256 * 1024
#define BG_COLOUR 0xFFDFDFDF
@@ -41,7 +44,7 @@ static int text_yellow(int a) {
return a ? TEXT_YELLOW : TEXT_BLACK;
}
-int main(int argc, char **argv) { (void)argc; (void)argv;
+void _start(int args, void *argp) { (void)args; (void)argp;
SceAppMgrBudgetInfo info = {0};
info.size = sizeof(info);
@@ -57,6 +60,7 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
CLIB_HEAP_SIZE,
NULL);
+ if (memid < 0) { goto done; }
void *membase;
sceKernelGetMemBlockBase(memid, &membase);
@@ -181,5 +185,6 @@ int main(int argc, char **argv) { (void)argc; (void)argv;
vita2d_end_shfb();
}
- return 0;
+done:
+ sceKernelExitProcess(0);
}
diff --git a/scaling-test/CMakeLists.txt b/scaling-test/CMakeLists.txt
index f8464bc..06f9703 100644
--- a/scaling-test/CMakeLists.txt
+++ b/scaling-test/CMakeLists.txt
@@ -50,7 +50,9 @@ target_link_libraries("${ELF}"
fnblit
SceCtrl_stub
SceDisplay_stub
+ SceIofilemgr_stub
SceLibKernel_stub
+ SceSysmem_stub
)
dolce_create_self("${SELF}"
@@ -62,7 +64,7 @@ dolce_create_self("${SELF}"
set(VPK "sharpscale-scaling-test.vpk")
set(TITLE_NAME "Sharpscale Scaling Test")
set(TITLE_ID "AKRK00004")
-set(TITLE_VER "01.05")
+set(TITLE_VER "01.06")
dolce_create_vpk("${VPK}" "${TITLE_ID}" "${SELF}"
NAME "${TITLE_NAME}"
diff --git a/scaling-test/main.c b/scaling-test/main.c
index de6bc93..940c952 100644
--- a/scaling-test/main.c
+++ b/scaling-test/main.c
@@ -25,7 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <psp2/kernel/sysmem.h>
#include <fnblit.h>
-#define SFN_FILE_BUF_LEN 0x100000
+#define SFN_FILE_BUF_LEN SCE_KERNEL_1MiB
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
@@ -96,9 +96,16 @@ static void render(int *fb_base, int width, int pitch, int height) {
}
}
-int main() {
- void *sfn_file = malloc(SFN_FILE_BUF_LEN);
- if (!sfn_file) { goto done; }
+void _start(int args, void *argp) { (void)args; (void)argp;
+
+ SceUID font_mem_id = sceKernelAllocMemBlock(
+ "FontFileMem",
+ SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+ ALIGN(SFN_FILE_BUF_LEN, SCE_KERNEL_4KiB),
+ NULL);
+ if (font_mem_id < 0) { goto done; }
+ void *sfn_file;
+ sceKernelGetMemBlockBase(font_mem_id, &sfn_file);
SceUID sfn_file_fd = sceIoOpen("app0:font.sfn", SCE_O_RDONLY, 0);
if (sfn_file_fd < 0) { goto done; }
@@ -111,14 +118,14 @@ int main() {
fnblit_set_fg(WHITE);
fnblit_set_bg(BLACK);
- SceUID mem_id = sceKernelAllocMemBlock(
- "ScalingTestMemblock",
+ SceUID fb_mem_id = sceKernelAllocMemBlock(
+ "FramebufferMem",
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
- ALIGN(FB_LEN, 0x40000),
+ ALIGN(FB_LEN, SCE_KERNEL_256KiB),
NULL);
- if (mem_id < 0) { goto done; }
+ if (fb_mem_id < 0) { goto done; }
int *fb_base;
- if (sceKernelGetMemBlockBase(mem_id, (void**)&fb_base) < 0) { goto free_mem; }
+ sceKernelGetMemBlockBase(fb_mem_id, (void**)&fb_base);
int width = 0;
int pitch = 0;
@@ -142,11 +149,11 @@ int main() {
select_res(res_idx);
SceCtrlData last_ctrl;
- memset(&last_ctrl, 0x00, sizeof(last_ctrl));
+ sceClibMemset(&last_ctrl, 0x00, sizeof(last_ctrl));
for (;;) {
SceCtrlData ctrl;
- memset(&ctrl, 0x00, sizeof(ctrl));
+ sceClibMemset(&ctrl, 0x00, sizeof(ctrl));
if (sceCtrlReadBufferPositive(0, &ctrl, 1) == 1) {
int btns = ~last_ctrl.buttons & ctrl.buttons;
@@ -174,8 +181,6 @@ int main() {
sceDisplayWaitVblankStartMulti(2);
}
-free_mem:
- sceKernelFreeMemBlock(mem_id);
done:
- return sceKernelExitProcess(0);
+ sceKernelExitProcess(0);
}